2 ; RUN: llc -run-pass=livedebugvalues -march=x86-64 -o - %s | FileCheck %s
5 ; void __attribute((always_inline)) f(int a) { sink(a); }
13 ; This test verifies that LiveDebugValues doesn't propagate DBG_VALUEs into
14 ; basic blocks that are beyond the scope of the source variable.
16 ; CHECK: ![[F_SP:[0-9]+]] = distinct !DISubprogram(name: "f", {{.*}})
17 ; CHECK: ![[A_VAR:[0-9]+]] = !DILocalVariable(name: "a",{{.*}})
18 ; CHECK: ![[I_VAR:[0-9]+]] = !DILocalVariable(name: "i",{{.*}})
19 ; CHECK: ![[I_LOC:[0-9]+]] = !DILocation(line: 4, column: 14, scope: !{{[0-9]+}})
20 ; CHECK: ![[INLCS1:[0-9]+]] = !DILocation(line: 3, column: 41, scope: ![[F_SP]], inlinedAt: ![[CS1:[0-9]+]])
21 ; CHECK: ![[CS1]] = distinct !DILocation(line: 5, column: 3, scope: !{{[0-9]+}})
22 ; CHECK: ![[INLCS2:[0-9]+]] = !DILocation(line: 3, column: 41, scope: ![[F_SP]], inlinedAt: ![[CS2:[0-9]+]])
23 ; CHECK: ![[CS2]] = distinct !DILocation(line: 7, column: 5, scope: !{{[0-9]+}})
24 ; CHECK: ![[INLCS3:[0-9]+]] = !DILocation(line: 3, column: 41, scope: ![[F_SP]], inlinedAt: ![[CS3:[0-9]+]])
25 ; CHECK: ![[CS3]] = distinct !DILocation(line: 8, column: 3, scope: !{{[0-9]+}})
27 ; CHECK: bb.1.if.then:
28 ; CHECK: DBG_VALUE $ebx, $noreg, ![[I_VAR]], !DIExpression(), debug-location ![[I_LOC]]
29 ; CHECK-NOT: DBG_VALUE $ebx, $noreg, ![[A_VAR]], !DIExpression(), debug-location
30 ; CHECK: DBG_VALUE $ebx, $noreg, ![[A_VAR]], !DIExpression(), debug-location ![[INLCS2]]
32 ; CHECK: DBG_VALUE $ebx, $noreg, ![[I_VAR]], !DIExpression(), debug-location ![[I_LOC]]
33 ; CHECK-NOT: DBG_VALUE $ebx, $noreg, ![[A_VAR]], !DIExpression(), debug-location
34 ; CHECK: DBG_VALUE $ebx, $noreg, ![[A_VAR]], !DIExpression(), debug-location ![[INLCS3]]
36 ; ModuleID = 'livedebugvalues-limit.ll'
37 source_filename = "livedebugvalues-limit.c"
38 target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
39 target triple = "x86_64-apple-macosx"
41 ; Function Attrs: alwaysinline nounwind ssp uwtable
42 define void @f(i32 %a) local_unnamed_addr #0 !dbg !7 {
44 tail call void @llvm.dbg.value(metadata i32 %a, i64 0, metadata !12, metadata !13), !dbg !14
45 tail call void @sink(i32 %a) #4, !dbg !15
49 declare void @sink(i32) local_unnamed_addr
51 ; Function Attrs: nounwind ssp uwtable
52 define void @foo(i32 %i) local_unnamed_addr #2 !dbg !17 {
54 tail call void @llvm.dbg.value(metadata i32 %i, i64 0, metadata !19, metadata !13), !dbg !20
55 tail call void @llvm.dbg.value(metadata i32 %i, i64 0, metadata !12, metadata !13) #4, !dbg !21
56 tail call void @sink(i32 %i) #4, !dbg !23
57 %tobool = icmp eq i32 %i, 0, !dbg !24
58 br i1 %tobool, label %if.end, label %if.then, !dbg !26
60 if.then: ; preds = %entry
61 tail call void @llvm.dbg.value(metadata i32 %i, i64 0, metadata !12, metadata !13) #4, !dbg !27
62 tail call void @sink(i32 %i) #4, !dbg !29
63 br label %if.end, !dbg !30
65 if.end: ; preds = %if.then, %entry
66 tail call void @llvm.dbg.value(metadata i32 %i, i64 0, metadata !12, metadata !13) #4, !dbg !31
67 tail call void @sink(i32 %i) #4, !dbg !33
71 ; Function Attrs: nounwind readnone
72 declare void @llvm.dbg.value(metadata, i64, metadata, metadata) #3
74 ; Function Attrs: nounwind
75 declare void @llvm.stackprotector(i8*, i8**) #4
77 attributes #0 = { alwaysinline nounwind ssp uwtable }
78 attributes #2 = { nounwind ssp uwtable }
79 attributes #3 = { nounwind readnone }
80 attributes #4 = { nounwind }
83 !llvm.module.flags = !{!3, !4, !5}
86 !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 4.0.0 (trunk 281923) (llvm/trunk 281916)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2)
87 !1 = !DIFile(filename: "livedebugvalues-limit.c", directory: "/Volumes/Fusion/Data/llvm")
89 !3 = !{i32 2, !"Dwarf Version", i32 4}
90 !4 = !{i32 2, !"Debug Info Version", i32 3}
91 !5 = !{i32 1, !"PIC Level", i32 2}
92 !6 = !{!"clang version 4.0.0 (trunk 281923) (llvm/trunk 281916)"}
93 !7 = distinct !DISubprogram(name: "f", scope: !1, file: !1, line: 3, type: !8, isLocal: false, isDefinition: true, scopeLine: 3, flags: DIFlagPrototyped, isOptimized: true, unit: !0, retainedNodes: !11)
94 !8 = !DISubroutineType(types: !9)
96 !10 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
98 !12 = !DILocalVariable(name: "a", arg: 1, scope: !7, file: !1, line: 3, type: !10)
100 !14 = !DILocation(line: 3, column: 41, scope: !7)
101 !15 = !DILocation(line: 3, column: 46, scope: !7)
102 !16 = !DILocation(line: 3, column: 55, scope: !7)
103 !17 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 4, type: !8, isLocal: false, isDefinition: true, scopeLine: 4, flags: DIFlagPrototyped, isOptimized: true, unit: !0, retainedNodes: !18)
105 !19 = !DILocalVariable(name: "i", arg: 1, scope: !17, file: !1, line: 4, type: !10)
106 !20 = !DILocation(line: 4, column: 14, scope: !17)
107 !21 = !DILocation(line: 3, column: 41, scope: !7, inlinedAt: !22)
108 !22 = distinct !DILocation(line: 5, column: 3, scope: !17)
109 !23 = !DILocation(line: 3, column: 46, scope: !7, inlinedAt: !22)
110 !24 = !DILocation(line: 6, column: 7, scope: !25)
111 !25 = distinct !DILexicalBlock(scope: !17, file: !1, line: 6, column: 7)
112 !26 = !DILocation(line: 6, column: 7, scope: !17)
113 !27 = !DILocation(line: 3, column: 41, scope: !7, inlinedAt: !28)
114 !28 = distinct !DILocation(line: 7, column: 5, scope: !25)
115 !29 = !DILocation(line: 3, column: 46, scope: !7, inlinedAt: !28)
116 !30 = !DILocation(line: 7, column: 5, scope: !25)
117 !31 = !DILocation(line: 3, column: 41, scope: !7, inlinedAt: !32)
118 !32 = distinct !DILocation(line: 8, column: 3, scope: !17)
119 !33 = !DILocation(line: 3, column: 46, scope: !7, inlinedAt: !32)
120 !34 = !DILocation(line: 9, column: 1, scope: !17)
126 exposesReturnsTwice: false
128 regBankSelected: false
130 tracksRegLiveness: true
133 calleeSavedRegisters: [ '$bh', '$bl', '$bp', '$bpl', '$bx', '$ebp', '$ebx',
134 '$rbp', '$rbx', '$r12', '$r13', '$r14', '$r15',
135 '$r12b', '$r13b', '$r14b', '$r15b', '$r12d', '$r13d',
136 '$r14d', '$r15d', '$r12w', '$r13w', '$r14w', '$r15w' ]
138 isFrameAddressTaken: false
139 isReturnAddressTaken: false
148 hasOpaqueSPAdjustment: false
150 hasMustTailInVarArgFunc: false
152 - { id: 0, type: spill-slot, offset: -16, size: 8, alignment: 16 }
157 frame-setup PUSH64r killed $rbp, implicit-def $rsp, implicit $rsp
158 CFI_INSTRUCTION def_cfa_offset 16
159 CFI_INSTRUCTION offset $rbp, -16
160 $rbp = frame-setup MOV64rr $rsp
161 CFI_INSTRUCTION def_cfa_register $rbp
162 DBG_VALUE $edi, _, !12, !13, debug-location !14
163 $rbp = POP64r implicit-def $rsp, implicit $rsp, debug-location !15
164 TAILJMPd64 @sink, csr_64, implicit $rsp, implicit $rsp, implicit $edi, debug-location !15
170 exposesReturnsTwice: false
172 regBankSelected: false
174 tracksRegLiveness: true
177 calleeSavedRegisters: [ '$bh', '$bl', '$bp', '$bpl', '$bx', '$ebp', '$ebx',
178 '$rbp', '$rbx', '$r12', '$r13', '$r14', '$r15',
179 '$r12b', '$r13b', '$r14b', '$r15b', '$r12d', '$r13d',
180 '$r14d', '$r15d', '$r12w', '$r13w', '$r14w', '$r15w' ]
182 isFrameAddressTaken: false
183 isReturnAddressTaken: false
192 hasOpaqueSPAdjustment: false
194 hasMustTailInVarArgFunc: false
196 - { id: 0, type: spill-slot, offset: -24, size: 8, alignment: 8, callee-saved-register: '$rbx' }
197 - { id: 1, type: spill-slot, offset: -16, size: 8, alignment: 16 }
200 successors: %bb.2.if.end, %bb.1.if.then
201 liveins: $edi, $rbx, $rbp
203 frame-setup PUSH64r killed $rbp, implicit-def $rsp, implicit $rsp
204 CFI_INSTRUCTION def_cfa_offset 16
205 CFI_INSTRUCTION offset $rbp, -16
206 $rbp = frame-setup MOV64rr $rsp
207 CFI_INSTRUCTION def_cfa_register $rbp
208 frame-setup PUSH64r killed $rbx, implicit-def $rsp, implicit $rsp
209 frame-setup PUSH64r undef $rax, implicit-def $rsp, implicit $rsp
210 CFI_INSTRUCTION offset $rbx, -24
211 DBG_VALUE $edi, _, !19, !13, debug-location !20
213 DBG_VALUE $ebx, _, !12, !13, debug-location !21
214 DBG_VALUE $ebx, _, !19, !13, debug-location !20
215 CALL64pcrel32 @sink, csr_64, implicit $rsp, implicit $edi, implicit-def $rsp, debug-location !23
216 TEST32rr $ebx, $ebx, implicit-def $eflags, debug-location !24
217 JCC_1 %bb.2.if.end, 4, implicit $eflags
220 successors: %bb.2.if.end
223 DBG_VALUE $ebx, _, !19, !13, debug-location !20
224 DBG_VALUE $ebx, _, !12, !13, debug-location !27
225 $edi = MOV32rr $ebx, debug-location !29
226 CALL64pcrel32 @sink, csr_64, implicit $rsp, implicit $edi, implicit-def $rsp, debug-location !29
231 DBG_VALUE $ebx, _, !19, !13, debug-location !20
232 $edi = MOV32rr killed $ebx, debug-location !33
233 $rsp = ADD64ri8 $rsp, 8, implicit-def dead $eflags, debug-location !33
234 DBG_VALUE $ebx, _, !12, !13, debug-location !31
235 $rbx = POP64r implicit-def $rsp, implicit $rsp, debug-location !33
236 $rbp = POP64r implicit-def $rsp, implicit $rsp, debug-location !33
237 TAILJMPd64 @sink, csr_64, implicit $rsp, implicit $rsp, implicit $edi, debug-location !33