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