1--- | 2 ; RUN: llc -run-pass=livedebugvalues -march=x86-64 -o - %s | FileCheck %s 3 ; Created from: 4 ; void sink(int a); 5 ; void __attribute((always_inline)) f(int a) { sink(a); } 6 ; void foo(int i) { 7 ; f(i); 8 ; if (i) 9 ; f(i); 10 ; f(i); 11 ; } 12 ; 13 ; This test verifies that LiveDebugValues doesn't propagate DBG_VALUEs into 14 ; basic blocks that are beyond the scope of the source variable. 15 ; 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]+}}) 26 ; 27 ; CHECK: bb.1.if.then: 28 ; CHECK: DBG_VALUE debug-use $ebx, debug-use $noreg, ![[I_VAR]], !DIExpression(), debug-location ![[I_LOC]] 29 ; CHECK-NOT: DBG_VALUE debug-use $ebx, debug-use $noreg, ![[A_VAR]], !DIExpression(), debug-location 30 ; CHECK: DBG_VALUE debug-use $ebx, debug-use $noreg, ![[A_VAR]], !DIExpression(), debug-location ![[INLCS2]] 31 ; CHECK: bb.2.if.end: 32 ; CHECK: DBG_VALUE debug-use $ebx, debug-use $noreg, ![[I_VAR]], !DIExpression(), debug-location ![[I_LOC]] 33 ; CHECK-NOT: DBG_VALUE debug-use $ebx, debug-use $noreg, ![[A_VAR]], !DIExpression(), debug-location 34 ; CHECK: DBG_VALUE debug-use $ebx, debug-use $noreg, ![[A_VAR]], !DIExpression(), debug-location ![[INLCS3]] 35 ; 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" 40 41 ; Function Attrs: alwaysinline nounwind ssp uwtable 42 define void @f(i32 %a) local_unnamed_addr #0 !dbg !7 { 43 entry: 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 46 ret void, !dbg !16 47 } 48 49 declare void @sink(i32) local_unnamed_addr 50 51 ; Function Attrs: nounwind ssp uwtable 52 define void @foo(i32 %i) local_unnamed_addr #2 !dbg !17 { 53 entry: 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 59 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 64 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 68 ret void, !dbg !34 69 } 70 71 ; Function Attrs: nounwind readnone 72 declare void @llvm.dbg.value(metadata, i64, metadata, metadata) #3 73 74 ; Function Attrs: nounwind 75 declare void @llvm.stackprotector(i8*, i8**) #4 76 77 attributes #0 = { alwaysinline nounwind ssp uwtable } 78 attributes #2 = { nounwind ssp uwtable } 79 attributes #3 = { nounwind readnone } 80 attributes #4 = { nounwind } 81 82 !llvm.dbg.cu = !{!0} 83 !llvm.module.flags = !{!3, !4, !5} 84 !llvm.ident = !{!6} 85 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") 88 !2 = !{} 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) 95 !9 = !{null, !10} 96 !10 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed) 97 !11 = !{!12} 98 !12 = !DILocalVariable(name: "a", arg: 1, scope: !7, file: !1, line: 3, type: !10) 99 !13 = !DIExpression() 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) 104 !18 = !{!19} 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) 121 122... 123--- 124name: f 125alignment: 4 126exposesReturnsTwice: false 127legalized: false 128regBankSelected: false 129selected: false 130tracksRegLiveness: true 131liveins: 132 - { reg: '$edi' } 133calleeSavedRegisters: [ '$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' ] 137frameInfo: 138 isFrameAddressTaken: false 139 isReturnAddressTaken: false 140 hasStackMap: false 141 hasPatchPoint: false 142 stackSize: 8 143 offsetAdjustment: 0 144 maxAlignment: 0 145 adjustsStack: false 146 hasCalls: false 147 maxCallFrameSize: 0 148 hasOpaqueSPAdjustment: false 149 hasVAStart: false 150 hasMustTailInVarArgFunc: false 151fixedStack: 152 - { id: 0, type: spill-slot, offset: -16, size: 8, alignment: 16 } 153body: | 154 bb.0.entry: 155 liveins: $edi, $rbp 156 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 debug-use $edi, debug-use _, !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 165 166... 167--- 168name: foo 169alignment: 4 170exposesReturnsTwice: false 171legalized: false 172regBankSelected: false 173selected: false 174tracksRegLiveness: true 175liveins: 176 - { reg: '$edi' } 177calleeSavedRegisters: [ '$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' ] 181frameInfo: 182 isFrameAddressTaken: false 183 isReturnAddressTaken: false 184 hasStackMap: false 185 hasPatchPoint: false 186 stackSize: 24 187 offsetAdjustment: -8 188 maxAlignment: 0 189 adjustsStack: true 190 hasCalls: true 191 maxCallFrameSize: 0 192 hasOpaqueSPAdjustment: false 193 hasVAStart: false 194 hasMustTailInVarArgFunc: false 195fixedStack: 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 } 198body: | 199 bb.0.entry: 200 successors: %bb.2.if.end, %bb.1.if.then 201 liveins: $edi, $rbx, $rbp 202 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 debug-use $edi, debug-use _, !19, !13, debug-location !20 212 $ebx = MOV32rr $edi 213 DBG_VALUE debug-use $ebx, debug-use _, !12, !13, debug-location !21 214 DBG_VALUE debug-use $ebx, debug-use _, !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 JE_1 %bb.2.if.end, implicit $eflags 218 219 bb.1.if.then: 220 successors: %bb.2.if.end 221 liveins: $ebx, $rbp 222 223 DBG_VALUE debug-use $ebx, debug-use _, !19, !13, debug-location !20 224 DBG_VALUE debug-use $ebx, debug-use _, !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 227 228 bb.2.if.end: 229 liveins: $ebx, $rbp 230 231 DBG_VALUE debug-use $ebx, debug-use _, !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 debug-use $ebx, debug-use _, !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 238 239... 240