xref: /llvm-project/llvm/test/DebugInfo/X86/fi-piece.ll (revision 10b03e66629aedad79a804e22d23b575077303b3)
1; RUN: llc %s -filetype=obj -o - | llvm-dwarfdump -v - | FileCheck %s
2; RUN: llc --try-experimental-debuginfo-iterators %s -filetype=obj -o - | llvm-dwarfdump -v - | FileCheck %s
3; Test that multi-DW_OP_piece expressions are emitted for FI variables.
4;
5; CHECK: .debug_info contents:
6; CHECK: DW_TAG_subprogram
7; CHECK:   DW_AT_abstract_origin
8; CHECK: DW_TAG_variable
9; CHECK-NEXT:   DW_AT_location [DW_FORM_exprloc]	(DW_OP_fbreg -4, DW_OP_piece 0x2, DW_OP_fbreg -8, DW_OP_piece 0x2)
10; CHECK-NEXT:   DW_AT_abstract_origin {{.*}}"a"
11; Inlined variable, not to be merged.
12; CHECK-NOT: DW_TAG
13; CHECK: DW_TAG_inlined_subroutine
14; CHECK-NOT: DW_TAG
15; CHECK:   DW_TAG_variable
16; CHECK-NEXT:     DW_AT_location
17; CHECK-NEXT:   DW_AT_abstract_origin {{.*}}"a"
18
19; ModuleID = '/tmp/t.c'
20source_filename = "/tmp/t.c"
21target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
22target triple = "x86_64-apple-macosx10.12.0"
23
24; Function Attrs: noinline nounwind optnone ssp uwtable
25define void @f() #0 !dbg !8 {
26entry:
27  %a = alloca i16, align 4
28  %b = alloca i16, align 4
29  call void @llvm.dbg.declare(metadata ptr %a, metadata !11, metadata !DIExpression(DW_OP_LLVM_fragment, 0, 16)), !dbg !14
30  store i16 1, ptr %a, align 4, !dbg !14
31  call void @llvm.dbg.declare(metadata ptr %b, metadata !11, metadata !DIExpression(DW_OP_LLVM_fragment, 16, 16)), !dbg !16
32  call void @llvm.dbg.declare(metadata ptr %a, metadata !11, metadata !13), !dbg !17
33  store i16 2, ptr %b, align 4, !dbg !17
34  ret void
35}
36
37; Function Attrs: nounwind readnone speculatable
38declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
39
40attributes #0 = { noinline nounwind optnone ssp uwtable }
41attributes #1 = { nounwind readnone speculatable }
42
43!llvm.dbg.cu = !{!0}
44!llvm.module.flags = !{!3, !4, !5, !6}
45
46!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "adrian", emissionKind: FullDebug)
47!1 = !DIFile(filename: "/tmp/t.c", directory: "/")
48!3 = !{i32 2, !"Dwarf Version", i32 4}
49!4 = !{i32 2, !"Debug Info Version", i32 3}
50!5 = !{i32 1, !"wchar_size", i32 4}
51!6 = !{i32 7, !"PIC Level", i32 2}
52!8 = distinct !DISubprogram(name: "f", scope: !1, file: !1, line: 1, type: !9, isLocal: false, isDefinition: true, scopeLine: 1, isOptimized: false, unit: !0)
53!9 = !DISubroutineType(types: !10)
54!10 = !{null}
55!11 = !DILocalVariable(name: "a", scope: !8, file: !1, line: 2, type: !12)
56!12 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
57!13 = !DIExpression()
58!14 = !DILocation(line: 2, column: 7, scope: !8)
59!15 = !DILocalVariable(name: "b", scope: !8, file: !1, line: 3, type: !12)
60!16 = !DILocation(line: 3, column: 7, scope: !8)
61!17 = !DILocation(line: 3, column: 7, scope: !8, inlinedAt: !16)
62