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)
34 debugValueSubstitutions:
35 - { srcinst: 4, srcop: 0, dstinst: 3, dstop: 0, subreg: 0 }
38 $rax = MOV64ri 1, debug-instr-number 1, debug-location !17
39 ; This debug instruction should identify the value as being in $rax.
40 DBG_INSTR_REF 1, 0, !16, !DIExpression(), debug-location !17
41 ; CHECK: DBG_VALUE $rax, $noreg
43 $rbx = COPY killed $rax, debug-location !17
44 $rax = MOV64ri 1, debug-location !17
45 ; CHECK: DBG_VALUE $rbx, $noreg
47 DBG_INSTR_REF 2, 0, !16, !DIExpression(), debug-location !17
48 ; No instruction is labelled with the number "2". This should produce an
49 ; empty variable location.
50 ; CHECK: DBG_VALUE $noreg, $noreg
52 $rbx = MOV64ri 1, debug-instr-number 3, debug-location !17
59 DBG_INSTR_REF 3, 0, !16, !DIExpression(), debug-location !17
60 ; This refers to a value def'd in a parent block -- but it should be
61 ; tracked into this block.
62 ; CHECK: DBG_VALUE $rbx, $noreg
67 ; Just like any other variable location, live-ins should be created for
68 ; any successor blocks.
69 ; CHECK: DBG_VALUE $rbx, $noreg
71 DBG_INSTR_REF 5, 0, !16, !DIExpression(), debug-location !17
72 ; This is a debug use-before-def: the value appears a few instructions
73 ; later. Any earlier value should be terminated here, _and_ we should
74 ; emit a DBG_VALUE when the value becomes available.
75 ; CHECK: DBG_VALUE $noreg, $noreg
77 $rax = MOV64ri 1, debug-location !17
78 $rax = MOV64ri 1, debug-location !17
79 $rcx = MOV64ri 1, debug-instr-number 5, debug-location !17
80 ; CHECK: DBG_VALUE $rcx, $noreg
81 $rax = MOV64ri 1, debug-location !17
83 DBG_INSTR_REF 6, 0, !16, !DIExpression(), debug-location !17
84 ; Another debug use-before-def, but across block boundaries.
85 ; CHECK: DBG_VALUE $noreg, $noreg
90 $rax = MOV64ri 1, debug-location !17
91 $rdx = MOV64ri 1, debug-instr-number 6, debug-location !17
92 ; CHECK: DBG_VALUE $rdx, $noreg
94 ; Terminate variable location for next few blocks,
95 DBG_VALUE $noreg, $noreg, !16, !DIExpression(), debug-location !17
96 ; CHECK: DBG_VALUE $noreg, $noreg
100 ; The next three blocks form a debug use-before-def modelling a scenario
101 ; where an instruction is sunk (debug inst in bb5, value in bb6). However,
102 ; because a different path joins bb.6, we should _not_ add any DBG_VALUE.
103 ; A different variable value may enter the block via the other path.
104 $rdx = MOV64ri 1, implicit-def $eflags, debug-location !17
105 JCC_1 %bb.6, 4, implicit $eflags, debug-location !17
107 DBG_INSTR_REF 7, 0, !16, !DIExpression(), debug-location !17
108 ; CHECK: DBG_VALUE $noreg, $noreg
109 JMP_1 %bb.6, debug-location !17
111 $rsi = MOV64ri 1, debug-instr-number 7, debug-location !17
112 JMP_1 %bb.7, debug-location !17
114 ; A use-before-def shouldn't pass another definition of the variable location
117 DBG_INSTR_REF 8, 0, !16, !DIExpression(), debug-location !17
118 ; CHECK: DBG_VALUE $noreg, $noreg
119 DBG_VALUE $rax, $noreg, !16, !DIExpression(), debug-location !17
120 ; CHECK: DBG_VALUE $rax, $noreg,
121 $rdi = MOV64ri 1, debug-instr-number 8, debug-location !17
123 ; Loops: use-before-defs should be live-through loops, assuming that nothing
124 ; in that loop modifies the variable location.
126 DBG_INSTR_REF 9, 0, !16, !DIExpression(), debug-location !17
127 ; CHECK: DBG_VALUE $noreg, $noreg
128 JCC_1 %bb.8, 4, implicit $eflags
130 $rax = MOV64ri 11, debug-instr-number 9, debug-location !17
131 ; CHECK: DBG_VALUE $rax, $noreg,
133 ; Likewise, use-before-defs where anything changes the variable location
134 ; or value in the loop, should be discarded.
137 ; CHECK: DBG_VALUE $rax, $noreg,
138 DBG_INSTR_REF 10, 0, !16, !DIExpression(), debug-location !17
139 ; CHECK: DBG_VALUE $noreg, $noreg
142 $rbx = MOV64ri 1, debug-location !17
145 DBG_INSTR_REF 9, 0, !16, !DIExpression(), debug-location !17
146 ; This still has a value in $rax,
147 ; CHECK: DBG_VALUE $rax, $noreg
148 JCC_1 %bb.11, 4, implicit $eflags
152 ; CHECK: DBG_VALUE $rax, $noreg
153 $rbx = MOV64ri 11, debug-instr-number 10, debug-location !17
154 ; This is instruction 10 referred to in bb.10. However, as the variable
155 ; location/value has been modified in the meantime, no DBG_VALUE should be
157 RETQ $eax, debug-location !17