2 ; RUN: llc %s -march=x86-64 -run-pass=livedebugvalues -o - -experimental-debug-variable-locations | FileCheck %s -implicit-check-not=DBG_VALUE
4 define i32 @_Z8bb_to_bb() local_unnamed_addr !dbg !12 {
10 !llvm.module.flags = !{!7, !8, !9, !10}
12 !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 10.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, globals: !3, debugInfoForProfiling: true, nameTableKind: None)
13 !1 = !DIFile(filename: "main.cpp", directory: "F:\")
16 !4 = !DIGlobalVariableExpression(var: !5, expr: !DIExpression())
17 !5 = distinct !DIGlobalVariable(name: "start", scope: !0, file: !1, line: 4, type: !6, isLocal: false, isDefinition: true)
18 !6 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
19 !7 = !{i32 2, !"Dwarf Version", i32 4}
20 !8 = !{i32 2, !"Debug Info Version", i32 3}
21 !9 = !{i32 1, !"wchar_size", i32 2}
22 !10 = !{i32 7, !"PIC Level", i32 2}
23 !11 = !{!"clang version 10.0.0"}
24 !12 = distinct !DISubprogram(name: "bb_to_bb", linkageName: "bb_to_bb", scope: !1, file: !1, line: 6, type: !13, scopeLine: 6, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !15)
25 !13 = !DISubroutineType(types: !14)
28 !16 = !DILocalVariable(name: "myVar", scope: !12, file: !1, line: 7, type: !6)
29 !17 = !DILocation(line: 10, scope: !12)
35 debugValueSubstitutions:
36 - { srcinst: 4, srcop: 0, dstinst: 3, dstop: 0, subreg: 0 }
39 $rax = MOV64ri 1, debug-instr-number 1, debug-location !17
40 ; This debug instruction should identify the value as being in $rax.
41 DBG_INSTR_REF !16, !DIExpression(DW_OP_LLVM_arg, 0), dbg-instr-ref(1, 0), debug-location !17
\r
42 ; CHECK: DBG_VALUE_LIST {{.+}}, $rax
\r
44 $rbx = COPY killed $rax, debug-location !17
45 $rax = MOV64ri 1, debug-location !17
46 ; CHECK: DBG_VALUE_LIST {{.+}}, $rbx
\r
48 DBG_INSTR_REF !16, !DIExpression(DW_OP_LLVM_arg, 0), dbg-instr-ref(2, 0), debug-location !17
\r
49 ; No instruction is labelled with the number "2". This should produce an
50 ; empty variable location.
51 ; CHECK: DBG_VALUE_LIST {{.+}}, $noreg
\r
53 $rbx = MOV64ri 1, debug-instr-number 3, debug-location !17
60 DBG_INSTR_REF !16, !DIExpression(DW_OP_LLVM_arg, 0), dbg-instr-ref(3, 0), debug-location !17
\r
61 ; This refers to a value def'd in a parent block -- but it should be
62 ; tracked into this block.
63 ; CHECK: DBG_VALUE_LIST {{.+}}, $rbx
\r
68 ; Just like any other variable location, live-ins should be created for
69 ; any successor blocks.
70 ; CHECK: DBG_VALUE_LIST {{.+}}, $rbx
\r
72 DBG_INSTR_REF !16, !DIExpression(DW_OP_LLVM_arg, 0), dbg-instr-ref(5, 0), debug-location !17
\r
73 ; This is a debug use-before-def: the value appears a few instructions
74 ; later. Any earlier value should be terminated here, _and_ we should
75 ; emit a DBG_VALUE when the value becomes available.
76 ; CHECK: DBG_VALUE_LIST {{.+}}, $noreg
\r
78 $rax = MOV64ri 1, debug-location !17
79 $rax = MOV64ri 1, debug-location !17
80 $rcx = MOV64ri 1, debug-instr-number 5, debug-location !17
81 ; CHECK: DBG_VALUE_LIST {{.+}}, $rcx
\r
82 $rax = MOV64ri 1, debug-location !17
84 DBG_INSTR_REF !16, !DIExpression(DW_OP_LLVM_arg, 0), dbg-instr-ref(6, 0), debug-location !17
\r
85 ; Another debug use-before-def, but across block boundaries.
86 ; CHECK: DBG_VALUE_LIST {{.+}}, $noreg
\r
91 $rax = MOV64ri 1, debug-location !17
92 $rdx = MOV64ri 1, debug-instr-number 6, debug-location !17
93 ; CHECK: DBG_VALUE_LIST {{.+}}, $rdx
\r
95 ; Terminate variable location for next few blocks,
96 DBG_VALUE $noreg, $noreg, !16, !DIExpression(), debug-location !17
97 ; CHECK: DBG_VALUE $noreg, $noreg
101 ; The next three blocks form a debug use-before-def modelling a scenario
102 ; where an instruction is sunk (debug inst in bb5, value in bb6). However,
103 ; because a different path joins bb.6, we should _not_ add any DBG_VALUE.
104 ; A different variable value may enter the block via the other path.
105 $rdx = MOV64ri 1, implicit-def $eflags, debug-location !17
106 JCC_1 %bb.6, 4, implicit $eflags, debug-location !17
108 DBG_INSTR_REF !16, !DIExpression(DW_OP_LLVM_arg, 0), dbg-instr-ref(7, 0), debug-location !17
\r
109 ; CHECK: DBG_VALUE_LIST {{.+}}, $noreg
\r
110 JMP_1 %bb.6, debug-location !17
112 $rsi = MOV64ri 1, debug-instr-number 7, debug-location !17
113 JMP_1 %bb.7, debug-location !17
115 ; A use-before-def shouldn't pass another definition of the variable location
118 DBG_INSTR_REF !16, !DIExpression(DW_OP_LLVM_arg, 0), dbg-instr-ref(8, 0), debug-location !17
\r
119 ; CHECK: DBG_VALUE_LIST {{.+}}, $noreg
\r
120 DBG_VALUE $rax, $noreg, !16, !DIExpression(), debug-location !17
121 ; CHECK: DBG_VALUE $rax, $noreg,
122 $rdi = MOV64ri 1, debug-instr-number 8, debug-location !17
124 ; Loops: use-before-defs should be live-through loops, assuming that nothing
125 ; in that loop modifies the variable location.
127 DBG_INSTR_REF !16, !DIExpression(DW_OP_LLVM_arg, 0), dbg-instr-ref(9, 0), debug-location !17
\r
128 ; CHECK: DBG_VALUE_LIST {{.+}}, $noreg
\r
129 JCC_1 %bb.8, 4, implicit $eflags
131 $rax = MOV64ri 11, debug-instr-number 9, debug-location !17
132 ; CHECK: DBG_VALUE_LIST {{.+}}, $rax
\r
134 ; Likewise, use-before-defs where anything changes the variable location
135 ; or value in the loop, should be discarded.
138 ; CHECK: DBG_VALUE_LIST {{.+}}, $rax
\r
139 DBG_INSTR_REF !16, !DIExpression(DW_OP_LLVM_arg, 0), dbg-instr-ref(10, 0), debug-location !17
\r
140 ; CHECK: DBG_VALUE_LIST {{.+}}, $noreg
\r
143 $rbx = MOV64ri 1, debug-location !17
146 DBG_INSTR_REF !16, !DIExpression(DW_OP_LLVM_arg, 0), dbg-instr-ref(9, 0), debug-location !17
\r
147 ; This still has a value in $rax,
148 ; CHECK: DBG_VALUE_LIST {{.+}}, $rax
\r
149 JCC_1 %bb.11, 4, implicit $eflags
153 ; CHECK: DBG_VALUE_LIST {{.+}}, $rax
\r
154 $rbx = MOV64ri 11, debug-instr-number 10, debug-location !17
155 ; This is instruction 10 referred to in bb.10. However, as the variable
156 ; location/value has been modified in the meantime, no DBG_VALUE should be
158 RET64 $eax, debug-location !17