1 ; RUN: llc %s -stop-before finalize-isel -o - | FileCheck %s
3 ;--------------------------------------------------------------------
4 ; This test case is basically generated from the following C code.
5 ; Compiled with "--target=x86_64-apple-darwin -S -g -O3" to get debug
6 ; info for optimized code.
11 ; } S = { .a = 23, .b = -17 };
14 ; struct SS* foo1 = &S;
19 ; struct SS* foo2 = &S;
20 ; struct SS* bar2 = &S;
21 ; return (int)foo2 + (int)bar2;
25 ; struct SS* bar3 = &S;
26 ; struct SS* foo3 = &S;
27 ; return (int)foo3 + (int)bar3;
31 ; struct SS* foo4 = &S;
32 ; struct SS* bar4 = &S;
34 ; return (int)foo4 + (int)bar4;
38 ; struct SS* bar5 = &S;
39 ; struct SS* foo5 = &S;
41 ; return (int)foo5 + (int)bar5;
43 ;--------------------------------------------------------------------
45 ; CHECK: ![[FOO1:.*]] = !DILocalVariable(name: "foo1"
46 ; CHECK: ![[BAR1:.*]] = !DILocalVariable(name: "bar1"
47 ; CHECK: ![[FOO2:.*]] = !DILocalVariable(name: "foo2"
48 ; CHECK: ![[BAR2:.*]] = !DILocalVariable(name: "bar2"
49 ; CHECK: ![[FOO3:.*]] = !DILocalVariable(name: "bar3"
50 ; CHECK: ![[BAR3:.*]] = !DILocalVariable(name: "foo3"
51 ; CHECK: ![[FOO4:.*]] = !DILocalVariable(name: "foo4"
52 ; CHECK: ![[BAR4:.*]] = !DILocalVariable(name: "bar4"
53 ; CHECK: ![[BAR5:.*]] = !DILocalVariable(name: "bar5"
54 ; CHECK: ![[FOO5:.*]] = !DILocalVariable(name: "foo5"
57 source_filename = "sdag-dangling-dbgvalue.c"
58 target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
59 target triple = "x86_64-apple-macosx10.4.0"
61 %struct.SS = type { i32, i32 }
63 @S = global %struct.SS { i32 23, i32 -17 }, align 4, !dbg !0
65 ; Verify that the def comes before the for foo1.
66 define i32 @test1() local_unnamed_addr #0 !dbg !17 {
67 ; CHECK-LABEL: bb.0.entry1
68 ; CHECK-NEXT: DBG_VALUE 0, $noreg, ![[BAR1]], !DIExpression()
69 ; CHECK-NEXT: [[REG1:%[0-9]+]]:gr64 =
70 ; CHECK-NEXT: DBG_VALUE [[REG1]], $noreg, ![[FOO1]], !DIExpression()
72 call void @llvm.dbg.value(metadata %struct.SS* @S, metadata !20, metadata !DIExpression()), !dbg !23
73 call void @llvm.dbg.value(metadata %struct.SS* null, metadata !22, metadata !DIExpression()), !dbg !24
74 ret i32 ptrtoint (%struct.SS* @S to i32), !dbg !25
77 ; Verify that the def comes before the for foo2 and bar2.
78 define i32 @test2() local_unnamed_addr #0 !dbg !26 {
79 ; CHECK-LABEL: bb.0.entry2
80 ; CHECK-NEXT: [[REG2:%[0-9]+]]:gr64 =
81 ; CHECK-NEXT: DBG_VALUE [[REG2]], $noreg, ![[FOO2]], !DIExpression()
82 ; CHECK-NEXT: DBG_VALUE [[REG2]], $noreg, ![[BAR2]], !DIExpression()
84 call void @llvm.dbg.value(metadata %struct.SS* @S, metadata !28, metadata !DIExpression()), !dbg !30
85 call void @llvm.dbg.value(metadata %struct.SS* @S, metadata !29, metadata !DIExpression()), !dbg !31
86 ret i32 add (i32 ptrtoint (%struct.SS* @S to i32), i32 ptrtoint (%struct.SS* @S to i32)), !dbg !32
89 ; Verify that the def comes before the for foo3 and bar3.
90 define i32 @test3() local_unnamed_addr #0 !dbg !33 {
91 ; CHECK-LABEL: bb.0.entry3
92 ; CHECK-NEXT: [[REG3:%[0-9]+]]:gr64 =
93 ; CHECK-NEXT: DBG_VALUE [[REG3]], $noreg, ![[BAR3]], !DIExpression()
94 ; CHECK-NEXT: DBG_VALUE [[REG3]], $noreg, ![[FOO3]], !DIExpression()
96 call void @llvm.dbg.value(metadata %struct.SS* @S, metadata !36, metadata !DIExpression()), !dbg !38
97 call void @llvm.dbg.value(metadata %struct.SS* @S, metadata !35, metadata !DIExpression()), !dbg !37
98 ret i32 add (i32 ptrtoint (%struct.SS* @S to i32), i32 ptrtoint (%struct.SS* @S to i32)), !dbg !39
101 ; Verify that the def comes before the for bar4.
102 define i32 @test4() local_unnamed_addr #0 !dbg !40 {
103 ; CHECK-LABEL: bb.0.entry4
104 ; CHECK-NEXT: DBG_VALUE $noreg, $noreg, ![[FOO4]], !DIExpression()
105 ; CHECK-NEXT: DBG_VALUE 0, $noreg, ![[FOO4]], !DIExpression()
106 ; CHECK-NEXT: [[REG4:%[0-9]+]]:gr64 =
107 ; CHECK-NEXT: DBG_VALUE [[REG4]], $noreg, ![[BAR4]], !DIExpression()
109 call void @llvm.dbg.value(metadata %struct.SS* @S, metadata !42, metadata !DIExpression()), !dbg !44
110 call void @llvm.dbg.value(metadata %struct.SS* @S, metadata !43, metadata !DIExpression()), !dbg !45
111 call void @llvm.dbg.value(metadata %struct.SS* null, metadata !42, metadata !DIExpression()), !dbg !44
112 ret i32 ptrtoint (%struct.SS* @S to i32), !dbg !46
115 ; Verify that we do not get a DBG_VALUE that maps foo5 to @S here.
116 define i32 @test5() local_unnamed_addr #0 !dbg !47 {
117 ; CHECK-LABEL: bb.0.entry5:
118 ; CHECK-NEXT: DBG_VALUE $noreg, $noreg, ![[FOO5]], !DIExpression()
119 ; CHECK-NEXT: DBG_VALUE 0, $noreg, ![[FOO5]], !DIExpression()
120 ; CHECK-NEXT: [[REG5:%[0-9]+]]:gr64 =
121 ; CHECK-NEXT: DBG_VALUE [[REG5]], $noreg, ![[BAR5]], !DIExpression()
122 ; CHECK-NOT: DBG_VALUE [[REG5]], $noreg, ![[FOO5]], !DIExpression()
125 call void @llvm.dbg.value(metadata %struct.SS* @S, metadata !49, metadata !DIExpression()), !dbg !51
126 call void @llvm.dbg.value(metadata %struct.SS* @S, metadata !50, metadata !DIExpression()), !dbg !52
127 call void @llvm.dbg.value(metadata %struct.SS* null, metadata !50, metadata !DIExpression()), !dbg !52
128 ret i32 ptrtoint (%struct.SS* @S to i32), !dbg !53
131 ; Function Attrs: nounwind readnone speculatable
132 declare void @llvm.dbg.value(metadata, metadata, metadata) #1
134 attributes #0 = { nounwind readnone uwtable }
135 attributes #1 = { nounwind readnone speculatable }
138 !llvm.module.flags = !{!12, !13, !14, !15}
141 !0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
142 !1 = distinct !DIGlobalVariable(name: "S", scope: !2, file: !3, line: 4, type: !8, isLocal: false, isDefinition: true)
143 !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)
144 !3 = !DIFile(filename: "sdag-dangling-dbgvalue.c", directory: "/repo/uabbpet/llvm-master")
147 !6 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
149 !8 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "SS", file: !3, line: 1, size: 64, elements: !9)
151 !10 = !DIDerivedType(tag: DW_TAG_member, name: "a", scope: !8, file: !3, line: 2, baseType: !6, size: 32)
152 !11 = !DIDerivedType(tag: DW_TAG_member, name: "b", scope: !8, file: !3, line: 3, baseType: !6, size: 32, offset: 32)
153 !12 = !{i32 2, !"Dwarf Version", i32 2}
154 !13 = !{i32 2, !"Debug Info Version", i32 3}
155 !14 = !{i32 1, !"wchar_size", i32 4}
156 !15 = !{i32 7, !"PIC Level", i32 2}
157 !16 = !{!"clang version 7.0.0 (trunk 327229) (llvm/trunk 327239)"}
158 !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)
159 !18 = !DISubroutineType(types: !5)
161 !20 = !DILocalVariable(name: "foo1", scope: !17, file: !3, line: 7, type: !21)
162 !21 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !8, size: 64)
163 !22 = !DILocalVariable(name: "bar1", scope: !17, file: !3, line: 8, type: !21)
164 !23 = !DILocation(line: 7, column: 14, scope: !17)
165 !24 = !DILocation(line: 8, column: 14, scope: !17)
166 !25 = !DILocation(line: 9, column: 3, scope: !17)
167 !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)
169 !28 = !DILocalVariable(name: "foo2", scope: !26, file: !3, line: 13, type: !21)
170 !29 = !DILocalVariable(name: "bar2", scope: !26, file: !3, line: 14, type: !21)
171 !30 = !DILocation(line: 13, column: 14, scope: !26)
172 !31 = !DILocation(line: 14, column: 14, scope: !26)
173 !32 = !DILocation(line: 15, column: 3, scope: !26)
174 !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)
176 !35 = !DILocalVariable(name: "bar3", scope: !33, file: !3, line: 19, type: !21)
177 !36 = !DILocalVariable(name: "foo3", scope: !33, file: !3, line: 20, type: !21)
178 !37 = !DILocation(line: 19, column: 14, scope: !33)
179 !38 = !DILocation(line: 20, column: 14, scope: !33)
180 !39 = !DILocation(line: 21, column: 3, scope: !33)
181 !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)
183 !42 = !DILocalVariable(name: "foo4", scope: !40, file: !3, line: 25, type: !21)
184 !43 = !DILocalVariable(name: "bar4", scope: !40, file: !3, line: 26, type: !21)
185 !44 = !DILocation(line: 25, column: 14, scope: !40)
186 !45 = !DILocation(line: 26, column: 14, scope: !40)
187 !46 = !DILocation(line: 28, column: 3, scope: !40)
188 !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)
190 !49 = !DILocalVariable(name: "bar5", scope: !47, file: !3, line: 32, type: !21)
191 !50 = !DILocalVariable(name: "foo5", scope: !47, file: !3, line: 33, type: !21)
192 !51 = !DILocation(line: 32, column: 14, scope: !47)
193 !52 = !DILocation(line: 33, column: 14, scope: !47)
194 !53 = !DILocation(line: 35, column: 3, scope: !47)