351 lines · plain
1# RUN: llc %s -o - -run-pass=livedebugvalues -mtriple=x86_64-unknown-unknown | FileCheck %s --check-prefix=CHECK2# RUN: llc %s -o - -start-before=livedebugvalues -filetype=obj -mtriple=x86_64-unknown-unknown | llvm-dwarfdump - | FileCheck %s --check-prefix=RANGES3# Check that livedebugvalues does the right thing when register and constant4# DBG_VALUEs interact, and that their ranges are correctly terminated by the5# debug printing backend.6--- |7 ; All these IR functions are duds, see the MIR below.8 source_filename = "<stdin>"9 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"10 11 define i32 @foo(ptr %bees, ptr %output, i1 %arg) !dbg !4 {12 entry:13 br i1 %arg, label %bb1, label %bb114 bb1:15 br label %bb316 bb2:17 br label %bb318 bb3:19 ret i32 020 }21 22 define i32 @bar(ptr %bees, ptr %output, i1 %arg) !dbg !40 {23 entry:24 br i1 %arg, label %bb1, label %bb125 bb1:26 br label %bb327 bb2:28 br label %bb329 bb3:30 ret i32 031 }32 33 define i32 @baz(ptr %bees, ptr %output, i1 %arg) !dbg !80 {34 entry:35 br i1 %arg, label %bb1, label %bb136 bb1:37 br label %bb338 bb2:39 br label %bb340 bb3:41 ret i32 042 }43 44 define i32 @qux(ptr %bees, ptr %output, i1 %arg) !dbg !120 {45 entry:46 br i1 %arg, label %bb1, label %bb147 bb1:48 br label %bb349 bb2:50 br label %bb351 bb3:52 ret i32 053 }54 55 ; Function Attrs: nounwind readnone speculatable56 declare void @llvm.dbg.value(metadata, metadata, metadata)57 58 ; Function Attrs: nounwind readnone speculatable59 declare void @llvm.dbg.declare(metadata, metadata, metadata)60 61 ; Function Attrs: nounwind62 declare void @llvm.stackprotector(ptr, ptr)63 64 !llvm.module.flags = !{!0, !100}65 !llvm.dbg.cu = !{!1}66 67 !100 = !{i32 2, !"Dwarf Version", i32 4}68 !0 = !{i32 2, !"Debug Info Version", i32 3}69 !1 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !2, producer: "beards", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug)70 !2 = !DIFile(filename: "bees.cpp", directory: ".")71 !3 = !DILocalVariable(name: "flannel", scope: !4, file: !2, line: 1, type: !16)72 !4 = distinct !DISubprogram(name: "nope", scope: !2, file: !2, line: 1, spFlags: DISPFlagDefinition, unit: !1, retainedNodes: !13, type: !14, isDefinition: true)73 !5 = !DILocation(line: 0, scope: !4)74 !6 = !DILocation(line: 1, scope: !4)75 !7 = !DILocation(line: 2, scope: !4)76 !8 = !DILocation(line: 4, scope: !4)77 !9 = !DILocation(line: 5, scope: !4)78 !10 = !DILocation(line: 6, scope: !4)79 !11 = !DILocation(line: 7, scope: !4)80 !12 = !DILocation(line: 8, scope: !4)81 !13 = !{!3}82 !14 = !DISubroutineType(types: !15)83 !15 = !{!16}84 !16 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)85 !40 = distinct !DISubprogram(name: "bar", scope: !2, file: !2, line: 1, spFlags: DISPFlagDefinition, unit: !1, retainedNodes: !43, type: !14, isDefinition: true)86 !41 = !DILocalVariable(name: "towel", scope: !40, file: !2, line: 1, type: !16)87 !42 = !DILocation(line: 40, scope: !40)88 !43 = !{!41}89 !80 = distinct !DISubprogram(name: "baz", scope: !2, file: !2, line: 1, spFlags: DISPFlagDefinition, unit: !1, retainedNodes: !83, type: !14, isDefinition: true)90 !81 = !DILocalVariable(name: "socks", scope: !80, file: !2, line: 1, type: !16)91 !82 = !DILocation(line: 40, scope: !80)92 !83 = !{!81}93 !120 = distinct !DISubprogram(name: "qux", scope: !2, file: !2, line: 1, spFlags: DISPFlagDefinition, unit: !1, retainedNodes: !123, type: !14, isDefinition: true)94 !121 = !DILocalVariable(name: "shoes", scope: !120, file: !2, line: 1, type: !16)95 !122 = !DILocation(line: 40, scope: !120)96 !123 = !{!121}97 98...99---100name: foo101alignment: 16102tracksRegLiveness: true103registers: []104liveins: 105 - { reg: '$rdi', virtual-reg: '' }106body: |107 108 ; Two DBG_VALUEs for eax merge into bb3, check that livedebugvalues propagates109 ; the location.110 ; CHECK-LABEL: name: foo111 ; CHECK-LABEL: bb.1.bb1112 ; CHECK: $eax = MOV32rr113 ; CHECK-NEXT: DBG_VALUE $eax114 ; CHECK-NEXT: JMP_1 %bb.3115 ; CHECK-LABEL: bb.2.bb2116 ; CHECK: $eax = ADD32ri8117 ; CHECK-NEXT: DBG_VALUE $eax118 ; CHECK-NEXT: JMP_1 %bb.3119 ; CHECK-LABEL: bb.3.bb3120 ; CHECK: DBG_VALUE $eax121 ; Test for there being a location-list gap between bb1 and bb2, as the122 ; variable does not have a location over the ADD32ri. The range should also123 ; extend over the final bb.124 ; RANGES-LABEL: DW_TAG_subprogram125 ; RANGES: DW_AT_high_pc (0x[[NOPEHIGHPC:[0-9a-f]+]])126 ; RANGES-LABEL: DW_AT_name ("nope")127 ; RANGES: DW_AT_location (0x{{[0-9a-f]+}}128 ; RANGES-NEXT: [0x{{[0-9a-f]+}}, 0x[[NOPEADDR:[0-9a-f]+]]): DW_OP_reg0 RAX129 ; RANGES-NEXT: [130 ; RANGES-NOT: 0x[[NOPEADDR]]131 ; RANGES-SAME: , 0x[[NOPEHIGHPC]]): DW_OP_reg0 RAX132 133 bb.0.entry:134 successors: %bb.1, %bb.2135 liveins: $rdi136 137 $ecx = XOR32rr undef $ecx, undef $ecx, implicit-def $eflags138 JCC_1 %bb.1, 2, implicit killed $eflags139 JMP_1 %bb.2140 141 bb.1.bb1 (align 4):142 successors: %bb.3143 liveins: $ecx, $rdi144 145 $eax = MOV32rr killed $ecx, implicit-def $rax146 DBG_VALUE $eax, $noreg, !3, !DIExpression(), debug-location !8147 JMP_1 %bb.3148 149 bb.2.bb2:150 successors: %bb.3151 liveins: $rax152 153 $eax = ADD32ri8 $eax, 3, implicit-def dead $eflags, implicit killed $rax, implicit-def $rax154 DBG_VALUE $eax, $noreg, !3, !DIExpression(), debug-location !8155 JMP_1 %bb.3156 157 bb.3.bb3:158 liveins: $rax159 RET64 $eax, debug-location !9160 161...162---163name: bar164alignment: 16165tracksRegLiveness: true166registers: []167liveins: 168 - { reg: '$rdi', virtual-reg: '' }169body: |170 ; Two DBG_VALUEs, one for eax, the other for zero, merge into bb3. Check that171 ; livedebugvalues does not propagate anything.172 ; the location.173 ; CHECK-LABEL: name: bar174 ; CHECK-LABEL: bb.1.bb1175 ; CHECK: $eax = MOV32rr176 ; CHECK-NEXT: DBG_VALUE 0177 ; CHECK-NEXT: JMP_1 %bb.3178 ; CHECK-LABEL: bb.2.bb2179 ; CHECK: $eax = ADD32ri8180 ; CHECK-NEXT: DBG_VALUE $eax181 ; CHECK-NEXT: JMP_1 %bb.3182 ; CHECK-LABEL: bb.3.bb3183 ; CHECK-NOT: DBG_VALUE184 ; Test for there being a location-list gap between bb1 and bb2, the variable185 ; should not have a location over the ADD32ri. The range of the last entry186 ; should not cover the last block.187 ; RANGES-LABEL: DW_TAG_subprogram188 ; RANGES: DW_AT_high_pc (0x[[BARHIGHPC:[0-9a-f]+]])189 ; RANGES-LABEL: DW_AT_name ("bar")190 ; RANGES: DW_AT_location (0x{{[0-9a-f]+}}191 ; RANGES-NEXT: [0x{{[0-9a-f]+}}, 0x[[BARADDR:[0-9a-f]+]]): DW_OP_consts +0, DW_OP_stack_value192 ; RANGES-NEXT: [193 ; RANGES-NOT: 0x[[BARADDR]]194 ; RANGES-NOT: 0x[[BARHIGHPC]]195 ; RANGES-SAME: ): DW_OP_reg0 RAX196 197 bb.0.entry:198 successors: %bb.1, %bb.2199 liveins: $rdi200 201 $ecx = XOR32rr undef $ecx, undef $ecx, implicit-def $eflags202 JCC_1 %bb.1, 2, implicit killed $eflags203 JMP_1 %bb.2204 205 bb.1.bb1 (align 4):206 successors: %bb.3207 liveins: $ecx, $rdi208 209 $eax = MOV32rr killed $ecx, implicit-def $rax210 DBG_VALUE 0, $noreg, !41, !DIExpression(), debug-location !42211 JMP_1 %bb.3212 213 bb.2.bb2:214 successors: %bb.3215 liveins: $rax216 217 $eax = ADD32ri8 $eax, 3, implicit-def dead $eflags, implicit killed $rax, implicit-def $rax218 DBG_VALUE $eax, $noreg, !41, !DIExpression(), debug-location !42219 JMP_1 %bb.3220 221 bb.3.bb3:222 liveins: $rax223 RET64 $eax, debug-location !42224 225...226---227name: baz228alignment: 16229tracksRegLiveness: true230registers: []231liveins: 232 - { reg: '$rdi', virtual-reg: '' }233body: |234 ; Two DBG_VALUEs, one for zero, the other for eax, merge into bb3. Check that235 ; livedebugvalues does not propagate anything.236 ; the location.237 ; CHECK-LABEL: name: baz238 ; CHECK-LABEL: bb.1.bb1239 ; CHECK: $eax = MOV32rr240 ; CHECK-NEXT: DBG_VALUE $eax241 ; CHECK-NEXT: JMP_1 %bb.3242 ; CHECK-LABEL: bb.2.bb2243 ; CHECK: $eax = ADD32ri8244 ; CHECK-NEXT: DBG_VALUE 0245 ; CHECK-NEXT: JMP_1 %bb.3246 ; CHECK-LABEL: bb.3.bb3247 ; CHECK-NOT: DBG_VALUE248 ; Test for there being a location-list gap between bb1 and bb2, the variable249 ; should not have a location over the ADD32ri. The range of the last item250 ; should not cover the last block.251 ; RANGES-LABEL: DW_TAG_subprogram252 ; RANGES: DW_AT_high_pc (0x[[BAZHIGHPC:[0-9a-f]+]])253 ; RANGES-LABEL: DW_AT_name ("baz")254 ; RANGES: DW_AT_location (0x{{[0-9a-f]+}}255 ; RANGES-NEXT: [0x{{[0-9a-f]+}}, 0x[[BAZADDR:[0-9a-f]+]]): DW_OP_reg0 RAX256 ; RANGES-NEXT: [257 ; RANGES-NOT: 0x[[BAZADDR]]258 ; RANGES-NOT: 0x[[BAZHIGHPC]]259 ; RANGES-SAME: ): DW_OP_consts +0, DW_OP_stack_value260 261 bb.0.entry:262 successors: %bb.1, %bb.2263 liveins: $rdi264 265 $ecx = XOR32rr undef $ecx, undef $ecx, implicit-def $eflags266 JCC_1 %bb.1, 2, implicit killed $eflags267 JMP_1 %bb.2268 269 bb.1.bb1 (align 4):270 successors: %bb.3271 liveins: $ecx, $rdi272 273 $eax = MOV32rr killed $ecx, implicit-def $rax274 DBG_VALUE $eax, $noreg, !81, !DIExpression(), debug-location !82275 JMP_1 %bb.3276 277 bb.2.bb2:278 successors: %bb.3279 liveins: $rax280 281 $eax = ADD32ri8 $eax, 3, implicit-def dead $eflags, implicit killed $rax, implicit-def $rax282 DBG_VALUE 0, $noreg, !81, !DIExpression(), debug-location !82283 JMP_1 %bb.3284 285 bb.3.bb3:286 liveins: $rax287 RET64 $eax, debug-location !82288 289...290---291name: qux292alignment: 16293tracksRegLiveness: true294registers: []295liveins: 296 - { reg: '$rdi', virtual-reg: '' }297body: |298 ; Two DBG_VALUEs for zero merging into bb3, Check that livedebugvalues does299 ; propagate the zero into the merging block.300 ; CHECK-LABEL: name: qux301 ; CHECK-LABEL: bb.1.bb1302 ; CHECK: $eax = MOV32rr303 ; CHECK-NEXT: DBG_VALUE 0304 ; CHECK-NEXT: JMP_1 %bb.3305 ; CHECK-LABEL: bb.2.bb2306 ; CHECK: $eax = ADD32ri8307 ; CHECK-NEXT: DBG_VALUE 0308 ; CHECK-NEXT: JMP_1 %bb.3309 ; CHECK-LABEL: bb.3.bb3310 ; CHECK: DBG_VALUE 0311 ; Test for there being a location-list gap between bb1 and bb2, the variable312 ; should not have a location over the ADD32ri. The final entry should cover313 ; the final block.314 ; RANGES-LABEL: DW_TAG_subprogram315 ; RANGES: DW_AT_high_pc (0x[[QUXHIGHPC:[0-9a-f]+]])316 ; RANGES-LABEL: DW_AT_name ("qux")317 ; RANGES: DW_AT_location (0x{{[0-9a-f]+}}318 ; RANGES-NEXT: [0x{{[0-9a-f]+}}, 0x[[QUXADDR:[0-9a-f]+]]): DW_OP_consts +0, DW_OP_stack_value319 ; RANGES-NOT: 0x[[QUXADDR]]320 ; RANGES-NEXT: [0x{{[0-9a-f]+}}, 0x[[QUXHIGHPC]]): DW_OP_consts +0, DW_OP_stack_value321 322 bb.0.entry:323 successors: %bb.1, %bb.2324 liveins: $rdi325 326 $ecx = XOR32rr undef $ecx, undef $ecx, implicit-def $eflags327 JCC_1 %bb.1, 2, implicit killed $eflags328 JMP_1 %bb.2329 330 bb.1.bb1 (align 4):331 successors: %bb.3332 liveins: $ecx, $rdi333 334 $eax = MOV32rr killed $ecx, implicit-def $rax335 DBG_VALUE 0, $noreg, !121, !DIExpression(), debug-location !122336 JMP_1 %bb.3337 338 bb.2.bb2:339 successors: %bb.3340 liveins: $rax341 342 $eax = ADD32ri8 $eax, 3, implicit-def dead $eflags, implicit killed $rax, implicit-def $rax343 DBG_VALUE 0, $noreg, !121, !DIExpression(), debug-location !122344 JMP_1 %bb.3345 346 bb.3.bb3:347 liveins: $rax348 RET64 $eax, debug-location !122349 350...351