1 ; RUN: llc %s -stop-before finalize-isel -o - \
2 ; RUN: -experimental-debug-variable-locations=false \
3 ; RUN: | FileCheck %s --check-prefixes=CHECK,DBGVALUE
4 ; RUN: llc %s -stop-before finalize-isel -o - \
5 ; RUN: -experimental-debug-variable-locations=true \
6 ; RUN: | FileCheck %s --check-prefixes=CHECK,INSTRREF
8 ; Repeat checks with experimental debginfo iterators.
9 ; RUN: llc %s -stop-before finalize-isel -o - \
10 ; RUN: -try-experimental-debuginfo-iterators \
11 ; RUN: -experimental-debug-variable-locations=false \
12 ; RUN: | FileCheck %s --check-prefixes=CHECK,DBGVALUE
13 ; RUN: llc %s -stop-before finalize-isel -o - \
14 ; RUN: -try-experimental-debuginfo-iterators \
15 ; RUN: -experimental-debug-variable-locations=true \
16 ; RUN: | FileCheck %s --check-prefixes=CHECK,INSTRREF
18 ;--------------------------------------------------------------------
19 ; This test case is basically generated from the following C code.
20 ; Compiled with "--target=x86_64-apple-darwin -S -g -O3" to get debug
21 ; info for optimized code.
26 ; } S = { .a = 23, .b = -17 };
29 ; struct SS* foo1 = &S;
34 ; struct SS* foo2 = &S;
35 ; struct SS* bar2 = &S;
36 ; return (int)foo2 + (int)bar2;
40 ; struct SS* bar3 = &S;
41 ; struct SS* foo3 = &S;
42 ; return (int)foo3 + (int)bar3;
46 ; struct SS* foo4 = &S;
47 ; struct SS* bar4 = &S;
49 ; return (int)foo4 + (int)bar4;
53 ; struct SS* bar5 = &S;
54 ; struct SS* foo5 = &S;
56 ; return (int)foo5 + (int)bar5;
58 ;--------------------------------------------------------------------
60 ; CHECK: ![[FOO1:.*]] = !DILocalVariable(name: "foo1"
61 ; CHECK: ![[BAR1:.*]] = !DILocalVariable(name: "bar1"
62 ; CHECK: ![[FOO2:.*]] = !DILocalVariable(name: "foo2"
63 ; CHECK: ![[BAR2:.*]] = !DILocalVariable(name: "bar2"
64 ; CHECK: ![[FOO3:.*]] = !DILocalVariable(name: "bar3"
65 ; CHECK: ![[BAR3:.*]] = !DILocalVariable(name: "foo3"
66 ; CHECK: ![[FOO4:.*]] = !DILocalVariable(name: "foo4"
67 ; CHECK: ![[BAR4:.*]] = !DILocalVariable(name: "bar4"
68 ; CHECK: ![[BAR5:.*]] = !DILocalVariable(name: "bar5"
69 ; CHECK: ![[FOO5:.*]] = !DILocalVariable(name: "foo5"
72 source_filename = "sdag-dangling-dbgvalue.c"
73 target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
74 target triple = "x86_64-apple-macosx10.4.0"
76 %struct.SS = type { i32, i32 }
78 @S = global %struct.SS { i32 23, i32 -17 }, align 4, !dbg !0
80 ; Verify that the def comes before the for foo1.
81 define i32 @test1() local_unnamed_addr #0 !dbg !17 {
82 ; CHECK-LABEL: bb.0.entry1
83 ; CHECK-NEXT: DBG_VALUE 0, $noreg, ![[BAR1]], !DIExpression()
84 ; CHECK-NEXT: [[REG1:%[0-9]+]]:gr64 = LEA64r
85 ; INSTRREF-SAME: debug-instr-number 1
86 ; INSTRREF-NEXT: DBG_INSTR_REF ![[FOO1]], !DIExpression(DW_OP_LLVM_arg, 0), dbg-instr-ref(1, 0)
87 ; DBGVALUE-NEXT: DBG_VALUE [[REG1]], $noreg, ![[FOO1]], !DIExpression()
89 call void @llvm.dbg.value(metadata ptr @S, metadata !20, metadata !DIExpression()), !dbg !23
90 call void @llvm.dbg.value(metadata ptr null, metadata !22, metadata !DIExpression()), !dbg !24
91 ret i32 ptrtoint (ptr @S to i32), !dbg !25
94 ; Verify that the def comes before the for foo2 and bar2.
95 define i32 @test2() local_unnamed_addr #0 !dbg !26 {
96 ; CHECK-LABEL: bb.0.entry2
97 ; CHECK-NEXT: [[REG2:%[0-9]+]]:gr64 = LEA64r
98 ; INSTRREF-SAME: debug-instr-number 1
99 ; INSTRREF-NEXT: DBG_INSTR_REF ![[FOO2]], !DIExpression(DW_OP_LLVM_arg, 0), dbg-instr-ref(1, 0)
100 ; INSTRREF-NEXT: DBG_INSTR_REF ![[BAR2]], !DIExpression(DW_OP_LLVM_arg, 0), dbg-instr-ref(1, 0)
101 ; DBGVALUE-NEXT: DBG_VALUE [[REG2]], $noreg, ![[FOO2]], !DIExpression
102 ; DBGVALUE-NEXT: DBG_VALUE [[REG2]], $noreg, ![[BAR2]], !DIExpression
104 call void @llvm.dbg.value(metadata ptr @S, metadata !28, metadata !DIExpression()), !dbg !30
105 call void @llvm.dbg.value(metadata ptr @S, metadata !29, metadata !DIExpression()), !dbg !31
106 ret i32 add (i32 ptrtoint (ptr @S to i32), i32 ptrtoint (ptr @S to i32)), !dbg !32
109 ; Verify that the def comes before the for foo3 and bar3.
110 define i32 @test3() local_unnamed_addr #0 !dbg !33 {
111 ; CHECK-LABEL: bb.0.entry3
112 ; CHECK-NEXT: [[REG3:%[0-9]+]]:gr64 = LEA64r
113 ; INSTRREF-SAME: debug-instr-number 1
114 ; INSTRREF-NEXT: DBG_INSTR_REF ![[BAR3]], !DIExpression(DW_OP_LLVM_arg, 0), dbg-instr-ref(1, 0)
115 ; INSTRREF-NEXT: DBG_INSTR_REF ![[FOO3]], !DIExpression(DW_OP_LLVM_arg, 0), dbg-instr-ref(1, 0)
116 ; DBGVALUE-NEXT: DBG_VALUE [[REG3]], $noreg, ![[BAR3]], !DIExpression()
117 ; DBGVALUE-NEXT: DBG_VALUE [[REG3]], $noreg, ![[FOO3]], !DIExpression()
119 call void @llvm.dbg.value(metadata ptr @S, metadata !36, metadata !DIExpression()), !dbg !38
120 call void @llvm.dbg.value(metadata ptr @S, metadata !35, metadata !DIExpression()), !dbg !37
121 ret i32 add (i32 ptrtoint (ptr @S to i32), i32 ptrtoint (ptr @S to i32)), !dbg !39
124 ; Verify that the def comes before the for bar4.
125 define i32 @test4() local_unnamed_addr #0 !dbg !40 {
126 ; CHECK-LABEL: bb.0.entry4
127 ; CHECK-NEXT: DBG_VALUE $noreg, $noreg, ![[FOO4]], !DIExpression()
128 ; CHECK-NEXT: DBG_VALUE 0, $noreg, ![[FOO4]], !DIExpression()
129 ; CHECK-NEXT: [[REG4:%[0-9]+]]:gr64 = LEA64r
130 ; INSTRREF-SAME: debug-instr-number 1
131 ; INSTRREF-NEXT: DBG_INSTR_REF ![[BAR4]], !DIExpression(DW_OP_LLVM_arg, 0), dbg-instr-ref(1, 0)
132 ; DBGVALUE-NEXT: DBG_VALUE [[REG4]], $noreg, ![[BAR4]], !DIExpression()
134 call void @llvm.dbg.value(metadata ptr @S, metadata !42, metadata !DIExpression()), !dbg !44
135 call void @llvm.dbg.value(metadata ptr @S, metadata !43, metadata !DIExpression()), !dbg !45
136 call void @llvm.dbg.value(metadata ptr null, metadata !42, metadata !DIExpression()), !dbg !44
137 ret i32 ptrtoint (ptr @S to i32), !dbg !46
140 ; Verify that we do not get a DBG_VALUE that maps foo5 to @S here.
141 define i32 @test5() local_unnamed_addr #0 !dbg !47 {
142 ; CHECK-LABEL: bb.0.entry5:
143 ; CHECK-NEXT: DBG_VALUE $noreg, $noreg, ![[FOO5]], !DIExpression()
144 ; CHECK-NEXT: DBG_VALUE 0, $noreg, ![[FOO5]], !DIExpression()
145 ; CHECK-NEXT: [[REG5:%[0-9]+]]:gr64 = LEA64r
146 ; INSTRREF-SAME: debug-instr-number 1
147 ; INSTRREF-NEXT: DBG_INSTR_REF ![[BAR5]], !DIExpression(DW_OP_LLVM_arg, 0), dbg-instr-ref(1, 0)
148 ; DBGVALUE-NEXT: DBG_VALUE [[REG5]], $noreg, ![[BAR5]], !DIExpression()
149 ; CHECK-NOT: DBG_{{.*}} ![[FOO5]], !DIExpression()
152 call void @llvm.dbg.value(metadata ptr @S, metadata !49, metadata !DIExpression()), !dbg !51
153 call void @llvm.dbg.value(metadata ptr @S, metadata !50, metadata !DIExpression()), !dbg !52
154 call void @llvm.dbg.value(metadata ptr null, metadata !50, metadata !DIExpression()), !dbg !52
155 ret i32 ptrtoint (ptr @S to i32), !dbg !53
158 ; Function Attrs: nounwind readnone speculatable
159 declare void @llvm.dbg.value(metadata, metadata, metadata) #1
161 attributes #0 = { nounwind readnone uwtable }
162 attributes #1 = { nounwind readnone speculatable }
165 !llvm.module.flags = !{!12, !13, !14, !15}
168 !0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
169 !1 = distinct !DIGlobalVariable(name: "S", scope: !2, file: !3, line: 4, type: !8, isLocal: false, isDefinition: true)
170 !2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3, producer: "clang version 7.0.0 (trunk 327229) (llvm/trunk 327239)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, retainedTypes: !5, globals: !7)
171 !3 = !DIFile(filename: "sdag-dangling-dbgvalue.c", directory: "/")
174 !6 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
176 !8 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "SS", file: !3, line: 1, size: 64, elements: !9)
178 !10 = !DIDerivedType(tag: DW_TAG_member, name: "a", scope: !8, file: !3, line: 2, baseType: !6, size: 32)
179 !11 = !DIDerivedType(tag: DW_TAG_member, name: "b", scope: !8, file: !3, line: 3, baseType: !6, size: 32, offset: 32)
180 !12 = !{i32 2, !"Dwarf Version", i32 2}
181 !13 = !{i32 2, !"Debug Info Version", i32 3}
182 !14 = !{i32 1, !"wchar_size", i32 4}
183 !15 = !{i32 7, !"PIC Level", i32 2}
184 !16 = !{!"clang version 7.0.0 (trunk 327229) (llvm/trunk 327239)"}
185 !17 = distinct !DISubprogram(name: "test1", scope: !3, file: !3, line: 6, type: !18, isLocal: false, isDefinition: true, scopeLine: 6, isOptimized: true, unit: !2, retainedNodes: !19)
186 !18 = !DISubroutineType(types: !5)
188 !20 = !DILocalVariable(name: "foo1", scope: !17, file: !3, line: 7, type: !21)
189 !21 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !8, size: 64)
190 !22 = !DILocalVariable(name: "bar1", scope: !17, file: !3, line: 8, type: !21)
191 !23 = !DILocation(line: 7, column: 14, scope: !17)
192 !24 = !DILocation(line: 8, column: 14, scope: !17)
193 !25 = !DILocation(line: 9, column: 3, scope: !17)
194 !26 = distinct !DISubprogram(name: "test2", scope: !3, file: !3, line: 12, type: !18, isLocal: false, isDefinition: true, scopeLine: 12, isOptimized: true, unit: !2, retainedNodes: !27)
196 !28 = !DILocalVariable(name: "foo2", scope: !26, file: !3, line: 13, type: !21)
197 !29 = !DILocalVariable(name: "bar2", scope: !26, file: !3, line: 14, type: !21)
198 !30 = !DILocation(line: 13, column: 14, scope: !26)
199 !31 = !DILocation(line: 14, column: 14, scope: !26)
200 !32 = !DILocation(line: 15, column: 3, scope: !26)
201 !33 = distinct !DISubprogram(name: "test3", scope: !3, file: !3, line: 18, type: !18, isLocal: false, isDefinition: true, scopeLine: 18, isOptimized: true, unit: !2, retainedNodes: !34)
203 !35 = !DILocalVariable(name: "bar3", scope: !33, file: !3, line: 19, type: !21)
204 !36 = !DILocalVariable(name: "foo3", scope: !33, file: !3, line: 20, type: !21)
205 !37 = !DILocation(line: 19, column: 14, scope: !33)
206 !38 = !DILocation(line: 20, column: 14, scope: !33)
207 !39 = !DILocation(line: 21, column: 3, scope: !33)
208 !40 = distinct !DISubprogram(name: "test4", scope: !3, file: !3, line: 24, type: !18, isLocal: false, isDefinition: true, scopeLine: 24, isOptimized: true, unit: !2, retainedNodes: !41)
210 !42 = !DILocalVariable(name: "foo4", scope: !40, file: !3, line: 25, type: !21)
211 !43 = !DILocalVariable(name: "bar4", scope: !40, file: !3, line: 26, type: !21)
212 !44 = !DILocation(line: 25, column: 14, scope: !40)
213 !45 = !DILocation(line: 26, column: 14, scope: !40)
214 !46 = !DILocation(line: 28, column: 3, scope: !40)
215 !47 = distinct !DISubprogram(name: "test5", scope: !3, file: !3, line: 31, type: !18, isLocal: false, isDefinition: true, scopeLine: 31, isOptimized: true, unit: !2, retainedNodes: !48)
217 !49 = !DILocalVariable(name: "bar5", scope: !47, file: !3, line: 32, type: !21)
218 !50 = !DILocalVariable(name: "foo5", scope: !47, file: !3, line: 33, type: !21)
219 !51 = !DILocation(line: 32, column: 14, scope: !47)
220 !52 = !DILocation(line: 33, column: 14, scope: !47)
221 !53 = !DILocation(line: 35, column: 3, scope: !47)