1 # RUN: llc -run-pass wasm-reg-coloring %s -o - | FileCheck %s
3 # Tests for invalid DBG_VALUE set to undef after in RegColoring
6 target triple = "wasm32-unknown-unknown"
10 define void @coalesce_test_0() {
11 call void @llvm.dbg.value(metadata i32 0, metadata !5, metadata !DIExpression()), !dbg !10
14 define void @coalesce_test_1() {
17 define void @coalesce_test_2() {
20 define void @coalesce_test_3() {
23 declare void @llvm.dbg.value(metadata, metadata, metadata)
26 !llvm.module.flags = !{!2, !3, !4}
28 !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, emissionKind: FullDebug)
29 !1 = !DIFile(filename: "test.c", directory: "")
30 !2 = !{i32 7, !"Dwarf Version", i32 5}
31 !3 = !{i32 2, !"Debug Info Version", i32 3}
32 !4 = !{i32 1, !"wchar_size", i32 4}
33 !5 = !DILocalVariable(name: "var_a", scope: !6, file: !1, line: 2, type: !9)
34 !6 = distinct !DISubprogram(name: "coalesce_test_0", scope: !1, file: !1, line: 1, type: !7, scopeLine: 1, unit: !0)
35 !7 = !DISubroutineType(types: !8)
37 !9 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
38 !10 = !DILocation(line: 0, scope: !6)
39 !11 = !DILocalVariable(name: "var_b", scope: !6, file: !1, line: 2, type: !9)
40 !12 = !DILocalVariable(name: "var_c", scope: !6, file: !1, line: 2, type: !9)
44 # %0 and %1 are coalesced in this test
45 # CHECK-LABEL: name: coalesce_test_0
48 - { reg: '$arguments' }
49 tracksRegLiveness: true
53 %0:i32 = CONST_I32 0, implicit-def $arguments
54 ; This should remain the same
55 DBG_VALUE %0, $noreg, !5, !DIExpression(), debug-location !10
56 ; This should be set to undef, because this is within %0's live range
57 DBG_VALUE %1, $noreg, !10, !DIExpression(), debug-location !10
58 CALL @use, %0, implicit-def $arguments
59 NOP implicit-def $arguments
60 %1:i32 = CONST_I32 1, implicit-def $arguments
61 ; This should be set to undef, because this is within %1's live range
62 DBG_VALUE %0, $noreg, !5, !DIExpression(), debug-location !10
63 ; This should remain the same
64 DBG_VALUE %1, $noreg, !10, !DIExpression(), debug-location !10
65 CALL @use, %1, implicit-def $arguments
66 RETURN implicit-def $arguments
68 ; CHECK: %0:i32 = CONST_I32 0
69 ; CHECK-NEXT: DBG_VALUE %0, $noreg
70 ; CHECK-NEXT: DBG_VALUE $noreg, $noreg
71 ; CHECK-NEXT: CALL @use, %0
73 ; CHECK-NEXT: %0:i32 = CONST_I32 1
74 ; CHECK-NEXT: DBG_VALUE $noreg, $noreg
75 ; CHECK-NEXT: DBG_VALUE %0, $noreg
76 ; CHECK-NEXT: CALL @use, %0
77 ; CHECK-NEXT: RETURN implicit-def $arguments
81 # A similar test with above, only with more consecutive DBG_VALUEs. These
82 # consecutive DBG_VALUEs will be handled with a quick last result check.
83 # CHECK-LABEL: name: coalesce_test_1
86 - { reg: '$arguments' }
87 tracksRegLiveness: true
91 %0:i32 = CONST_I32 0, implicit-def $arguments
92 ; All DBG_VALUE %1s in %0's live range will be set to undef
93 DBG_VALUE %1, $noreg, !10, !DIExpression(), debug-location !10
94 DBG_VALUE %1, $noreg, !10, !DIExpression(), debug-location !10
95 DBG_VALUE %0, $noreg, !5, !DIExpression(), debug-location !10
96 DBG_VALUE %1, $noreg, !10, !DIExpression(), debug-location !10
97 CALL @use, %0, implicit-def $arguments
98 NOP implicit-def $arguments
99 %1:i32 = CONST_I32 1, implicit-def $arguments
100 ; All DBG_VALUE %0s in %1's live range will be set to undef
101 DBG_VALUE %0, $noreg, !5, !DIExpression(), debug-location !10
102 DBG_VALUE %0, $noreg, !5, !DIExpression(), debug-location !10
103 DBG_VALUE %1, $noreg, !10, !DIExpression(), debug-location !10
104 DBG_VALUE %0, $noreg, !5, !DIExpression(), debug-location !10
105 CALL @use, %1, implicit-def $arguments
106 RETURN implicit-def $arguments
108 ; CHECK: %0:i32 = CONST_I32 0
109 ; CHECK-NEXT: DBG_VALUE $noreg, $noreg
110 ; CHECK-NEXT: DBG_VALUE $noreg, $noreg
111 ; CHECK-NEXT: DBG_VALUE %0, $noreg
112 ; CHECK-NEXT: DBG_VALUE $noreg, $noreg
113 ; CHECK-NEXT: CALL @use, %0
115 ; CHECK-NEXT: %0:i32 = CONST_I32 1
116 ; CHECK-NEXT: DBG_VALUE $noreg, $noreg
117 ; CHECK-NEXT: DBG_VALUE $noreg, $noreg
118 ; CHECK-NEXT: DBG_VALUE %0, $noreg
119 ; CHECK-NEXT: DBG_VALUE $noreg, $noreg
120 ; CHECK-NEXT: CALL @use, %0
121 ; CHECK-NEXT: RETURN implicit-def $arguments
125 # The same with coalesce_test_0, but the two registers' live ranges are in
127 # CHECK-LABEL: name: coalesce_test_2
128 name: coalesce_test_2
130 - { reg: '$arguments' }
131 tracksRegLiveness: true
135 %0:i32 = CONST_I32 0, implicit-def $arguments
136 DBG_VALUE %0, $noreg, !5, !DIExpression(), debug-location !10
137 DBG_VALUE %1, $noreg, !10, !DIExpression(), debug-location !10
138 CALL @use, %0, implicit-def $arguments
139 BR %bb.1, implicit-def $arguments
142 ; CHECK: %0:i32 = CONST_I32 0
143 ; CHECK-NEXT: DBG_VALUE %0, $noreg
144 ; CHECK-NEXT: DBG_VALUE $noreg, $noreg
145 ; CHECK-NEXT: CALL @use, %0
146 ; CHECK-NEXT: BR %bb.1
149 %1:i32 = CONST_I32 1, implicit-def $arguments
150 DBG_VALUE %0, $noreg, !5, !DIExpression(), debug-location !10
151 DBG_VALUE %1, $noreg, !10, !DIExpression(), debug-location !10
152 CALL @use, %1, implicit-def $arguments
153 RETURN implicit-def $arguments
156 ; CHECK-NEXT: %0:i32 = CONST_I32 1
157 ; CHECK-NEXT: DBG_VALUE $noreg, $noreg
158 ; CHECK-NEXT: DBG_VALUE %0, $noreg
159 ; CHECK-NEXT: CALL @use, %0
160 ; CHECK-NEXT: RETURN implicit-def $arguments
164 # Same test with three registers.
165 # CHECK-LABEL: name: coalesce_test_3
166 name: coalesce_test_3
168 - { reg: '$arguments' }
169 tracksRegLiveness: true
173 %0:i32 = CONST_I32 0, implicit-def $arguments
174 DBG_VALUE %0, $noreg, !5, !DIExpression(), debug-location !10
175 DBG_VALUE %1, $noreg, !10, !DIExpression(), debug-location !10
176 DBG_VALUE %2, $noreg, !11, !DIExpression(), debug-location !10
177 CALL @use, %0, implicit-def $arguments
178 NOP implicit-def $arguments
179 %1:i32 = CONST_I32 1, implicit-def $arguments
180 DBG_VALUE %0, $noreg, !5, !DIExpression(), debug-location !10
181 DBG_VALUE %1, $noreg, !10, !DIExpression(), debug-location !10
182 DBG_VALUE %2, $noreg, !11, !DIExpression(), debug-location !10
183 CALL @use, %1, implicit-def $arguments
184 NOP implicit-def $arguments
185 %2:i32 = CONST_I32 2, implicit-def $arguments
186 DBG_VALUE %0, $noreg, !5, !DIExpression(), debug-location !10
187 DBG_VALUE %1, $noreg, !10, !DIExpression(), debug-location !10
188 DBG_VALUE %2, $noreg, !11, !DIExpression(), debug-location !10
189 CALL @use, %2, implicit-def $arguments
190 RETURN implicit-def $arguments
192 ; CHECK: %0:i32 = CONST_I32 0
193 ; CHECK-NEXT: DBG_VALUE %0, $noreg
194 ; CHECK-NEXT: DBG_VALUE $noreg, $noreg
195 ; CHECK-NEXT: DBG_VALUE $noreg, $noreg
196 ; CHECK-NEXT: CALL @use, %0
198 ; CHECK-NEXT: %0:i32 = CONST_I32 1
199 ; CHECK-NEXT: DBG_VALUE $noreg, $noreg
200 ; CHECK-NEXT: DBG_VALUE %0, $noreg
201 ; CHECK-NEXT: DBG_VALUE $noreg, $noreg
202 ; CHECK-NEXT: CALL @use, %0
204 ; CHECK-NEXT: %0:i32 = CONST_I32 2
205 ; CHECK-NEXT: DBG_VALUE $noreg, $noreg
206 ; CHECK-NEXT: DBG_VALUE $noreg, $noreg
207 ; CHECK-NEXT: DBG_VALUE %0, $noreg
208 ; CHECK-NEXT: CALL @use, %0
209 ; CHECK-NEXT: RETURN implicit-def $arguments