• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: llc %s -stop-before expand-isel-pseudos -o - | FileCheck %s
2
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.
7;
8; struct SS {
9;   int a;
10;   int b;
11; } S = { .a = 23, .b = -17 };
12;
13; int test1() {
14;   struct SS* foo1 = &S;
15;   return (int)foo1;
16; }
17;
18; int test2() {
19;   struct SS* foo2 = &S;
20;   struct SS* bar2 = &S;
21;   return (int)foo2 + (int)bar2;
22; }
23;
24; int test3() {
25;   struct SS* bar3 = &S;
26;   struct SS* foo3 = &S;
27;   return (int)foo3 + (int)bar3;
28; }
29;
30; int test4() {
31;   struct SS* foo4 = &S;
32;   struct SS* bar4 = &S;
33;   foo = 0;
34;   return (int)foo4 + (int)bar4;
35; }
36;
37; int test5() {
38;   struct SS* bar5 = &S;
39;   struct SS* foo5 = &S;
40;   foo5 = 0;
41;   return (int)foo5 + (int)bar5;
42; }
43;--------------------------------------------------------------------
44
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"
55
56
57source_filename = "sdag-dangling-dbgvalue.c"
58target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
59target triple = "x86_64-apple-macosx10.4.0"
60
61%struct.SS = type { i32, i32 }
62
63@S = global %struct.SS { i32 23, i32 -17 }, align 4, !dbg !0
64
65; Verify that the def comes before the debug-use for foo1.
66; TODO: Currently dbg.value for bar1 is dropped(?), is that expected?
67define i32 @test1() local_unnamed_addr #0 !dbg !17 {
68; CHECK-LABEL: bb.0.entry1
69; CHECK-NEXT:    [[REG1:%[0-9]+]]:gr64 =
70; CHECK-NEXT:    DBG_VALUE debug-use [[REG1]], debug-use $noreg, ![[FOO1]], !DIExpression()
71entry1:
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
75}
76
77; Verify that the def comes before the debug-use for foo2 and bar2.
78define 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 debug-use [[REG2]], debug-use $noreg, ![[FOO2]], !DIExpression()
82; CHECK-NEXT:    DBG_VALUE debug-use [[REG2]], debug-use $noreg, ![[BAR2]], !DIExpression()
83entry2:
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
87}
88
89; Verify that the def comes before the debug-use for foo3 and bar3.
90define 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 debug-use [[REG3]], debug-use $noreg, ![[BAR3]], !DIExpression()
94; CHECK-NEXT:    DBG_VALUE debug-use [[REG3]], debug-use $noreg, ![[FOO3]], !DIExpression()
95entry3:
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
99}
100
101; Verify that the def comes before the debug-use for bar4.
102; TODO: Currently dbg.value for foo4 is dropped. It is set to null and not
103;       used. Just like in test1 it can be discussed if there should be a
104;       DBG_VALUE for foo4 here.
105define i32 @test4() local_unnamed_addr #0 !dbg !40 {
106; CHECK-LABEL: bb.0.entry4
107; CHECK-NEXT:    [[REG4:%[0-9]+]]:gr64 =
108; CHECK-NEXT:    DBG_VALUE debug-use [[REG4]], debug-use $noreg, ![[BAR4]], !DIExpression()
109entry4:
110  call void @llvm.dbg.value(metadata %struct.SS* @S, metadata !42, metadata !DIExpression()), !dbg !44
111  call void @llvm.dbg.value(metadata %struct.SS* @S, metadata !43, metadata !DIExpression()), !dbg !45
112  call void @llvm.dbg.value(metadata %struct.SS* null, metadata !42, metadata !DIExpression()), !dbg !44
113  ret i32 ptrtoint (%struct.SS* @S to i32), !dbg !46
114}
115
116; Verify that we do not get a DBG_VALUE that maps foo5 to @S here.
117; TODO: foo5 is set to null, and it is not really used. Just like in test1 it
118;       can be discussed if there should be a DBG_VALUE for foo5 here.
119define i32 @test5() local_unnamed_addr #0 !dbg !47 {
120; CHECK-LABEL: bb.0.entry5:
121; CHECK-NEXT:    [[REG5:%[0-9]+]]:gr64 =
122; CHECK-NEXT:    DBG_VALUE debug-use [[REG5]], debug-use $noreg, ![[BAR5]], !DIExpression()
123; CHECK-NOT:     DBG_VALUE debug-use [[REG5]], debug-use $noreg, ![[FOO5]], !DIExpression()
124; CHECK:         RET
125entry5:
126  call void @llvm.dbg.value(metadata %struct.SS* @S, metadata !49, metadata !DIExpression()), !dbg !51
127  call void @llvm.dbg.value(metadata %struct.SS* @S, metadata !50, metadata !DIExpression()), !dbg !52
128  call void @llvm.dbg.value(metadata %struct.SS* null, metadata !50, metadata !DIExpression()), !dbg !52
129  ret i32 ptrtoint (%struct.SS* @S to i32), !dbg !53
130}
131
132; Function Attrs: nounwind readnone speculatable
133declare void @llvm.dbg.value(metadata, metadata, metadata) #1
134
135attributes #0 = { nounwind readnone uwtable }
136attributes #1 = { nounwind readnone speculatable }
137
138!llvm.dbg.cu = !{!2}
139!llvm.module.flags = !{!12, !13, !14, !15}
140!llvm.ident = !{!16}
141
142!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
143!1 = distinct !DIGlobalVariable(name: "S", scope: !2, file: !3, line: 4, type: !8, isLocal: false, isDefinition: true)
144!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)
145!3 = !DIFile(filename: "sdag-dangling-dbgvalue.c", directory: "/repo/uabbpet/llvm-master")
146!4 = !{}
147!5 = !{!6}
148!6 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
149!7 = !{!0}
150!8 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "SS", file: !3, line: 1, size: 64, elements: !9)
151!9 = !{!10, !11}
152!10 = !DIDerivedType(tag: DW_TAG_member, name: "a", scope: !8, file: !3, line: 2, baseType: !6, size: 32)
153!11 = !DIDerivedType(tag: DW_TAG_member, name: "b", scope: !8, file: !3, line: 3, baseType: !6, size: 32, offset: 32)
154!12 = !{i32 2, !"Dwarf Version", i32 2}
155!13 = !{i32 2, !"Debug Info Version", i32 3}
156!14 = !{i32 1, !"wchar_size", i32 4}
157!15 = !{i32 7, !"PIC Level", i32 2}
158!16 = !{!"clang version 7.0.0 (trunk 327229) (llvm/trunk 327239)"}
159!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)
160!18 = !DISubroutineType(types: !5)
161!19 = !{!20, !22}
162!20 = !DILocalVariable(name: "foo1", scope: !17, file: !3, line: 7, type: !21)
163!21 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !8, size: 64)
164!22 = !DILocalVariable(name: "bar1", scope: !17, file: !3, line: 8, type: !21)
165!23 = !DILocation(line: 7, column: 14, scope: !17)
166!24 = !DILocation(line: 8, column: 14, scope: !17)
167!25 = !DILocation(line: 9, column: 3, scope: !17)
168!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!27 = !{!28, !29}
170!28 = !DILocalVariable(name: "foo2", scope: !26, file: !3, line: 13, type: !21)
171!29 = !DILocalVariable(name: "bar2", scope: !26, file: !3, line: 14, type: !21)
172!30 = !DILocation(line: 13, column: 14, scope: !26)
173!31 = !DILocation(line: 14, column: 14, scope: !26)
174!32 = !DILocation(line: 15, column: 3, scope: !26)
175!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!34 = !{!35, !36}
177!35 = !DILocalVariable(name: "bar3", scope: !33, file: !3, line: 19, type: !21)
178!36 = !DILocalVariable(name: "foo3", scope: !33, file: !3, line: 20, type: !21)
179!37 = !DILocation(line: 19, column: 14, scope: !33)
180!38 = !DILocation(line: 20, column: 14, scope: !33)
181!39 = !DILocation(line: 21, column: 3, scope: !33)
182!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!41 = !{!42, !43}
184!42 = !DILocalVariable(name: "foo4", scope: !40, file: !3, line: 25, type: !21)
185!43 = !DILocalVariable(name: "bar4", scope: !40, file: !3, line: 26, type: !21)
186!44 = !DILocation(line: 25, column: 14, scope: !40)
187!45 = !DILocation(line: 26, column: 14, scope: !40)
188!46 = !DILocation(line: 28, column: 3, scope: !40)
189!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!48 = !{!49, !50}
191!49 = !DILocalVariable(name: "bar5", scope: !47, file: !3, line: 32, type: !21)
192!50 = !DILocalVariable(name: "foo5", scope: !47, file: !3, line: 33, type: !21)
193!51 = !DILocation(line: 32, column: 14, scope: !47)
194!52 = !DILocation(line: 33, column: 14, scope: !47)
195!53 = !DILocation(line: 35, column: 3, scope: !47)
196