1# RUN: llc -run-pass wasm-reg-coloring %s -o - | FileCheck %s 2 3# Tests for invalid DBG_VALUE set to undef after in RegColoring 4 5--- | 6 target triple = "wasm32-unknown-unknown" 7 8 declare void @use(i32) 9 10 define void @coalesce_test_0() { 11 call void @llvm.dbg.value(metadata i32 0, metadata !5, metadata !DIExpression()), !dbg !10 12 ret void 13 } 14 define void @coalesce_test_1() { 15 unreachable 16 } 17 define void @coalesce_test_2() { 18 unreachable 19 } 20 define void @coalesce_test_3() { 21 unreachable 22 } 23 declare void @llvm.dbg.value(metadata, metadata, metadata) 24 25 !llvm.dbg.cu = !{!0} 26 !llvm.module.flags = !{!2, !3, !4} 27 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) 36 !8 = !{null} 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) 41... 42 43--- 44# %0 and %1 are coalesced in this test 45# CHECK-LABEL: name: coalesce_test_0 46name: coalesce_test_0 47liveins: 48 - { reg: '$arguments' } 49tracksRegLiveness: true 50body: | 51 bb.0: 52 liveins: $arguments 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 67 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 72 ; CHECK-NEXT: NOP 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 78... 79 80--- 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 84name: coalesce_test_1 85liveins: 86 - { reg: '$arguments' } 87tracksRegLiveness: true 88body: | 89 bb.0: 90 liveins: $arguments 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 107 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 114 ; CHECK-NEXT: NOP 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 122... 123 124--- 125# The same with coalesce_test_0, but the two registers' live ranges are in 126# different BBs. 127# CHECK-LABEL: name: coalesce_test_2 128name: coalesce_test_2 129liveins: 130 - { reg: '$arguments' } 131tracksRegLiveness: true 132body: | 133 bb.0: 134 liveins: $arguments 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 140 141 ; CHECK: bb.0: 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 147 148 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 154 155 ; CHECK: bb.1: 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 161... 162 163--- 164# Same test with three registers. 165# CHECK-LABEL: name: coalesce_test_3 166name: coalesce_test_3 167liveins: 168 - { reg: '$arguments' } 169tracksRegLiveness: true 170body: | 171 bb.0: 172 liveins: $arguments 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 191 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 197 ; CHECK-NEXT: NOP 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 203 ; CHECK-NEXT: NOP 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 210--- 211