1 # RUN: llc %s -march=x86-64 -run-pass=livedebugvalues -experimental-debug-variable-locations -o - 2>&1 | FileCheck %s
3 # Test that when we have a subregister qualifiers in substitutions, that
4 # InstrRefBasedLDV correctly applies them to the variable location. Below, a
5 # call defines all of $rax, but the variable locations should only apply to
6 # the low order 8 bits.
8 define i8 @test(i32 %bar) local_unnamed_addr !dbg !7 {
13 declare dso_local void @ext(i64)
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)
28 !11 = !DILocalVariable(name: "baz", scope: !7, file: !1, line: 7, type: !2)
29 !12 = !DILocation(line: 10, scope: !7)
33 tracksRegLiveness: true
36 - { reg: '$rdi', virtual-reg: '' }
37 debugValueSubstitutions:
38 - { srcinst: 1, srcop: 0, dstinst: 2, dstop: 0, subreg: 1 } # sub_8bit
39 - { srcinst: 2, srcop: 0, dstinst: 3, dstop: 0, subreg: 4 } # sub_16bit
40 - { srcinst: 3, srcop: 0, dstinst: 4, dstop: 5, subreg: 6 } # sub_32bit
41 # Substitution involving sub_8bit_hi, should land in $ah
42 - { srcinst: 5, srcop: 0, dstinst: 6, dstop: 0, subreg: 2 } # sub_8bit_hi
43 - { srcinst: 6, srcop: 0, dstinst: 7, dstop: 0, subreg: 4 } # sub_16bit
44 - { srcinst: 7, srcop: 0, dstinst: 4, dstop: 5, subreg: 6 } # sub_32bit
45 # Several redundant substitutions, representing extractions from a small
46 # register, followed by larger spurious ones, for example:
48 # %1:gr32 = COPY %0.sub_32bit
49 # %2:gr16 = COPY %1.sub_16bit
50 # %3:gr64 = SUBREG_TO_REG %2, sub_8bit_hi
51 # %4:gr32 = COPY %3.sub_32bit
52 # %5:gr16 = COPY %2.sub_16bit
53 # Should still come out as ah.
54 - { srcinst: 8, srcop: 0, dstinst: 9, dstop: 0, subreg: 4 } # sub_16bit
55 - { srcinst: 9, srcop: 0, dstinst: 10,dstop: 0, subreg: 6 } # sub_32bit
56 - { srcinst: 10,srcop: 0, dstinst: 11,dstop: 0, subreg: 2 } # sub_8bit_hi
57 - { srcinst: 11,srcop: 0, dstinst: 12,dstop: 0, subreg: 4 } # sub_16bit
58 - { srcinst: 12,srcop: 0, dstinst: 4, dstop: 5, subreg: 6 } # sub_32bit
59 # If some kind of really mal-formed code appears that extracts the high bits
60 # out of a too-small location, we should drop it. It's not clear whether this
61 # scenario could ever happen; but if it did, best to not emit a known bad
62 # variable location. Should generate a DBG_VALUE $noreg.
63 - { srcinst: 13, srcop: 0, dstinst: 14,dstop: 0, subreg: 5 } # sub_16bit_hi
64 - { srcinst: 14, srcop: 0, dstinst: 15,dstop: 0, subreg: 6 } # sub_32bit
65 - { srcinst: 15, srcop: 0, dstinst: 4, dstop: 5, subreg: 1 } # sub_8bit
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: '' }
73 CALL64pcrel32 @ext, csr_64, implicit $rsp, implicit $ssp, implicit $edi, implicit-def $rax, debug-instr-number 4, debug-location !12
74 ; CHECK: CALL64pcrel32
75 DBG_INSTR_REF !11, !DIExpression(DW_OP_LLVM_arg, 0), dbg-instr-ref(1, 0), debug-location !12
\r
76 ; CHECK-NEXT: DBG_INSTR_REF {{.+}}, dbg-instr-ref(1, 0)
\r
77 ; CHECK-NEXT: DBG_VALUE_LIST {{.+}}, $al
\r
78 DBG_INSTR_REF !11, !DIExpression(DW_OP_LLVM_arg, 0), dbg-instr-ref(5, 0), debug-location !12
\r
79 ; CHECK-NEXT: DBG_INSTR_REF {{.+}}, dbg-instr-ref(5, 0)
\r
80 ; CHECK-NEXT: DBG_VALUE_LIST {{.+}}, $ah
\r
81 DBG_INSTR_REF !11, !DIExpression(DW_OP_LLVM_arg, 0), dbg-instr-ref(8, 0), debug-location !12
\r
82 ; CHECK-NEXT: DBG_INSTR_REF {{.+}}, dbg-instr-ref(8, 0)
\r
83 ; CHECK-NEXT: DBG_VALUE_LIST {{.+}}, $ah
\r
84 DBG_INSTR_REF !11, !DIExpression(DW_OP_LLVM_arg, 0), dbg-instr-ref(13, 0), debug-location !12
\r
85 ; CHECK-NEXT: DBG_INSTR_REF {{.+}}, dbg-instr-ref(13, 0)
\r
86 ; CHECK-NEXT: DBG_VALUE_LIST {{.+}}, $noreg
\r
87 MOV64mr $rsp, 1, $noreg, 16, $noreg, $rax :: (store 8 into %stack.0)
88 $rax = MOV64ri 0, debug-location !12
89 ; CHECK: $rax = MOV64ri 0
90 ; The value is now located in a spill slot, as a subregister within the
91 ; 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 !12
\r
93 ; CHECK-NEXT: DBG_INSTR_REF {{.+}}, dbg-instr-ref(1, 0)
\r
94 ; CHECK-NEXT: DBG_VALUE_LIST !{{[0-9]*}}, !DIExpression(DW_OP_LLVM_arg, 0, DW_OP_constu, 8, DW_OP_minus, DW_OP_deref), $rsp
\r
95 DBG_INSTR_REF !11, !DIExpression(DW_OP_LLVM_arg, 0), dbg-instr-ref(5, 0), debug-location !12
\r
96 ; This and the next DBG_INSTR_REF refer to a value that is on the stack, but
97 ; is located at a non-zero offset from the start of the slot -- $ah within
98 ; $rax is 8 bits in. Today, InstrRefBasedLDV can't express this. It also
99 ; doesn't seem likely to be profitable.
100 ; CHECK-NEXT: DBG_INSTR_REF {{.+}}, dbg-instr-ref(5, 0)
\r
101 ; CHECK-NEXT: DBG_VALUE_LIST {{.+}}, $noreg
\r
102 DBG_INSTR_REF !11, !DIExpression(DW_OP_LLVM_arg, 0), dbg-instr-ref(8, 0), debug-location !12
\r
103 ; CHECK-NEXT: DBG_INSTR_REF {{.+}}, dbg-instr-ref(8, 0)
\r
104 ; CHECK-NEXT: DBG_VALUE_LIST {{.+}}, $noreg
\r
105 DBG_INSTR_REF !11, !DIExpression(DW_OP_LLVM_arg, 0), dbg-instr-ref(13, 0), debug-location !12
\r
106 ; CHECK-NEXT: DBG_INSTR_REF {{.+}}, dbg-instr-ref(13, 0)
\r
107 ; CHECK-NEXT: DBG_VALUE_LIST {{.+}}, $noreg
\r
108 $rax = MOV64rm $rsp, 1, $noreg, 8, $noreg :: (load 8 from %stack.0)
109 RET64 $rax, debug-location !12