111 lines · plain
1# RUN: llc %s -mtriple=x86_64 -run-pass=livedebugvalues -experimental-debug-variable-locations -o - 2>&1 | FileCheck %s2#3# Test that when we have a subregister qualifiers in substitutions, that4# InstrRefBasedLDV correctly applies them to the variable location. Below, a5# call defines all of $rax, but the variable locations should only apply to6# the low order 8 bits.7--- |8 define i8 @test(i32 %bar) local_unnamed_addr !dbg !7 {9 entry:10 ret i8 0, !dbg !1211 }12 13 declare dso_local void @ext(i64)14 15 !llvm.dbg.cu = !{!0}16 !llvm.module.flags = !{!3, !4, !5, !6}17 !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug)18 !1 = !DIFile(filename: "foo.cpp", directory: ".")19 !2 = !DIBasicType(name: "int", size: 8, encoding: DW_ATE_signed)20 !3 = !{i32 2, !"Dwarf Version", i32 4}21 !4 = !{i32 2, !"Debug Info Version", i32 3}22 !5 = !{i32 1, !"wchar_size", i32 2}23 !6 = !{i32 7, !"PIC Level", i32 2}24 !7 = distinct !DISubprogram(name: "foo", linkageName: "foo", scope: !1, file: !1, line: 6, type: !8, scopeLine: 6, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !10)25 !8 = !DISubroutineType(types: !9)26 !9 = !{!2, !2}27 !10 = !{!11}28 !11 = !DILocalVariable(name: "baz", scope: !7, file: !1, line: 7, type: !2)29 !12 = !DILocation(line: 10, scope: !7)30...31---32name: test33tracksRegLiveness: true34debugInstrRef: true35liveins:36 - { reg: '$rdi', virtual-reg: '' }37debugValueSubstitutions:38 - { srcinst: 1, srcop: 0, dstinst: 2, dstop: 0, subreg: 1 } # sub_8bit39 - { srcinst: 2, srcop: 0, dstinst: 3, dstop: 0, subreg: 4 } # sub_16bit40 - { srcinst: 3, srcop: 0, dstinst: 4, dstop: 5, subreg: 6 } # sub_32bit41 # Substitution involving sub_8bit_hi, should land in $ah42 - { srcinst: 5, srcop: 0, dstinst: 6, dstop: 0, subreg: 2 } # sub_8bit_hi43 - { srcinst: 6, srcop: 0, dstinst: 7, dstop: 0, subreg: 4 } # sub_16bit44 - { srcinst: 7, srcop: 0, dstinst: 4, dstop: 5, subreg: 6 } # sub_32bit45 # Several redundant substitutions, representing extractions from a small46 # register, followed by larger spurious ones, for example:47 # %0:gr64 = COPY $rax48 # %1:gr32 = COPY %0.sub_32bit49 # %2:gr16 = COPY %1.sub_16bit50 # %3:gr64 = SUBREG_TO_REG %2, sub_8bit_hi51 # %4:gr32 = COPY %3.sub_32bit52 # %5:gr16 = COPY %2.sub_16bit53 # Should still come out as ah.54 - { srcinst: 8, srcop: 0, dstinst: 9, dstop: 0, subreg: 4 } # sub_16bit55 - { srcinst: 9, srcop: 0, dstinst: 10,dstop: 0, subreg: 6 } # sub_32bit56 - { srcinst: 10,srcop: 0, dstinst: 11,dstop: 0, subreg: 2 } # sub_8bit_hi57 - { srcinst: 11,srcop: 0, dstinst: 12,dstop: 0, subreg: 4 } # sub_16bit58 - { srcinst: 12,srcop: 0, dstinst: 4, dstop: 5, subreg: 6 } # sub_32bit59 # If some kind of really mal-formed code appears that extracts the high bits60 # out of a too-small location, we should drop it. It's not clear whether this61 # scenario could ever happen; but if it did, best to not emit a known bad62 # variable location. Should generate a DBG_VALUE $noreg.63 - { srcinst: 13, srcop: 0, dstinst: 14,dstop: 0, subreg: 5 } # sub_16bit_hi64 - { srcinst: 14, srcop: 0, dstinst: 15,dstop: 0, subreg: 6 } # sub_32bit65 - { srcinst: 15, srcop: 0, dstinst: 4, dstop: 5, subreg: 1 } # sub_8bit66stack:67 - { id: 0, name: '', type: spill-slot, offset: -16, size: 8, alignment: 8,68 stack-id: default, callee-saved-register: '', callee-saved-restored: true,69 debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }70body: |71 bb.0:72 liveins: $rdi, $rax73 CALL64pcrel32 @ext, csr_64, implicit $rsp, implicit $ssp, implicit $edi, implicit-def $rax, debug-instr-number 4, debug-location !1274 ; CHECK: CALL64pcrel3275 DBG_INSTR_REF !11, !DIExpression(DW_OP_LLVM_arg, 0), dbg-instr-ref(1, 0), debug-location !1276 ; CHECK-NEXT: DBG_INSTR_REF {{.+}}, dbg-instr-ref(1, 0)77 ; CHECK-NEXT: DBG_VALUE_LIST {{.+}}, $al78 DBG_INSTR_REF !11, !DIExpression(DW_OP_LLVM_arg, 0), dbg-instr-ref(5, 0), debug-location !1279 ; CHECK-NEXT: DBG_INSTR_REF {{.+}}, dbg-instr-ref(5, 0)80 ; CHECK-NEXT: DBG_VALUE_LIST {{.+}}, $ah81 DBG_INSTR_REF !11, !DIExpression(DW_OP_LLVM_arg, 0), dbg-instr-ref(8, 0), debug-location !1282 ; CHECK-NEXT: DBG_INSTR_REF {{.+}}, dbg-instr-ref(8, 0)83 ; CHECK-NEXT: DBG_VALUE_LIST {{.+}}, $ah84 DBG_INSTR_REF !11, !DIExpression(DW_OP_LLVM_arg, 0), dbg-instr-ref(13, 0), debug-location !1285 ; CHECK-NEXT: DBG_INSTR_REF {{.+}}, dbg-instr-ref(13, 0)86 ; CHECK-NEXT: DBG_VALUE_LIST {{.+}}, $noreg87 MOV64mr $rsp, 1, $noreg, 16, $noreg, $rax :: (store 8 into %stack.0)88 $rax = MOV64ri 0, debug-location !1289 ; CHECK: $rax = MOV64ri 090 ; The value is now located in a spill slot, as a subregister within the91 ; slot, which InstrRefBasedLDV should be able to find.92 DBG_INSTR_REF !11, !DIExpression(DW_OP_LLVM_arg, 0), dbg-instr-ref(1, 0), debug-location !1293 ; CHECK-NEXT: DBG_INSTR_REF {{.+}}, dbg-instr-ref(1, 0)94 ; CHECK-NEXT: DBG_VALUE_LIST !{{[0-9]*}}, !DIExpression(DW_OP_LLVM_arg, 0, DW_OP_constu, 8, DW_OP_minus, DW_OP_deref), $rsp95 DBG_INSTR_REF !11, !DIExpression(DW_OP_LLVM_arg, 0), dbg-instr-ref(5, 0), debug-location !1296 ; This and the next DBG_INSTR_REF refer to a value that is on the stack, but97 ; is located at a non-zero offset from the start of the slot -- $ah within98 ; $rax is 8 bits in. Today, InstrRefBasedLDV can't express this. It also99 ; doesn't seem likely to be profitable.100 ; CHECK-NEXT: DBG_INSTR_REF {{.+}}, dbg-instr-ref(5, 0)101 ; CHECK-NEXT: DBG_VALUE_LIST {{.+}}, $noreg102 DBG_INSTR_REF !11, !DIExpression(DW_OP_LLVM_arg, 0), dbg-instr-ref(8, 0), debug-location !12103 ; CHECK-NEXT: DBG_INSTR_REF {{.+}}, dbg-instr-ref(8, 0)104 ; CHECK-NEXT: DBG_VALUE_LIST {{.+}}, $noreg105 DBG_INSTR_REF !11, !DIExpression(DW_OP_LLVM_arg, 0), dbg-instr-ref(13, 0), debug-location !12106 ; CHECK-NEXT: DBG_INSTR_REF {{.+}}, dbg-instr-ref(13, 0)107 ; CHECK-NEXT: DBG_VALUE_LIST {{.+}}, $noreg108 $rax = MOV64rm $rsp, 1, $noreg, 8, $noreg :: (load 8 from %stack.0)109 RET64 $rax, debug-location !12110...111