v6-jumptable-clobber.mir
10.2 KB
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
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
# RUN: llc -run-pass=arm-cp-islands -o - %s | FileCheck %s
# Test created by tweaking the register allocation after stopping the IR below
# just before constant islands. We were forwarding the table index to the end of
# the block, even though the LEA clobbered it.
# CHECK-LABEL: name: foo
# CHECK: tBR_JT
# This order is important. If the jump-table comes first then the
# transformation is valid because the LEA can be removed, see second test.
# CHECK: CONSTPOOL_ENTRY
# CHECK: JUMPTABLE_ADDRS
# CHECK-LABEL: name: bar
# CHECK: tTBB_JT $pc, killed $r1
--- |
; ModuleID = 'simple.ll'
source_filename = "simple.ll"
target datalayout = "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64"
target triple = "thumbv6m-none--eabi"
define void @foo(i8 %in, i32* %addr) {
store i32 12345678, i32* %addr
%1 = call i32 @llvm.arm.space(i32 980, i32 undef)
%2 = zext i8 %in to i32
switch i32 %2, label %default [
i32 0, label %d1
i32 1, label %d2
i32 3, label %d3
i32 4, label %d4
i32 5, label %d5
i32 6, label %d6
i32 7, label %d7
i32 2, label %d8
i32 8, label %d9
i32 9, label %d10
i32 19, label %d11
i32 20, label %d12
i32 21, label %d13
i32 22, label %d14
i32 24, label %d15
i32 25, label %d16
i32 26, label %d17
]
default: ; preds = %0
unreachable
d1: ; preds = %0
unreachable
d2: ; preds = %0
unreachable
d3: ; preds = %0
unreachable
d4: ; preds = %0
unreachable
d5: ; preds = %0
unreachable
d6: ; preds = %0
unreachable
d7: ; preds = %0
unreachable
d8: ; preds = %0
unreachable
d9: ; preds = %0
unreachable
d10: ; preds = %0
unreachable
d11: ; preds = %0
unreachable
d12: ; preds = %0
unreachable
d13: ; preds = %0
unreachable
d14: ; preds = %0
unreachable
d15: ; preds = %0
unreachable
d16: ; preds = %0
unreachable
d17: ; preds = %0
unreachable
}
define void @bar(i8 %in, i32* %addr) {
store i32 12345678, i32* %addr
%1 = zext i8 %in to i32
switch i32 %1, label %default [
i32 0, label %d1
i32 1, label %d2
i32 3, label %d3
i32 4, label %d4
i32 5, label %d5
i32 6, label %d6
i32 7, label %d7
i32 2, label %d8
i32 8, label %d9
i32 9, label %d10
i32 19, label %d11
i32 20, label %d12
i32 21, label %d13
i32 22, label %d14
i32 24, label %d15
i32 25, label %d16
i32 26, label %d17
]
default: ; preds = %0
unreachable
d1: ; preds = %0
unreachable
d2: ; preds = %0
unreachable
d3: ; preds = %0
unreachable
d4: ; preds = %0
unreachable
d5: ; preds = %0
unreachable
d6: ; preds = %0
unreachable
d7: ; preds = %0
unreachable
d8: ; preds = %0
unreachable
d9: ; preds = %0
unreachable
d10: ; preds = %0
unreachable
d11: ; preds = %0
unreachable
d12: ; preds = %0
unreachable
d13: ; preds = %0
unreachable
d14: ; preds = %0
unreachable
d15: ; preds = %0
unreachable
d16: ; preds = %0
unreachable
d17: ; preds = %0
unreachable
}
; Function Attrs: nounwind
declare i32 @llvm.arm.space(i32, i32) #0
; Function Attrs: nounwind
declare void @llvm.stackprotector(i8*, i8**) #0
attributes #0 = { nounwind }
...
---
name: foo
alignment: 2
exposesReturnsTwice: false
legalized: false
regBankSelected: false
selected: false
tracksRegLiveness: true
liveins:
- { reg: '$r0' }
- { reg: '$r1' }
frameInfo:
isFrameAddressTaken: false
isReturnAddressTaken: false
hasStackMap: false
hasPatchPoint: false
stackSize: 0
offsetAdjustment: 0
maxAlignment: 0
adjustsStack: false
hasCalls: false
maxCallFrameSize: 0
hasOpaqueSPAdjustment: false
hasVAStart: false
hasMustTailInVarArgFunc: false
constants:
- id: 0
value: i32 12345678
alignment: 4
jumpTable:
kind: inline
entries:
- id: 0
blocks: [ '%bb.3.d2', '%bb.9.d8', '%bb.4.d3', '%bb.5.d4',
'%bb.6.d5', '%bb.7.d6', '%bb.8.d7', '%bb.10.d9',
'%bb.11.d10', '%bb.2.d1', '%bb.2.d1', '%bb.2.d1',
'%bb.2.d1', '%bb.2.d1', '%bb.2.d1', '%bb.2.d1',
'%bb.2.d1', '%bb.2.d1', '%bb.12.d11', '%bb.13.d12',
'%bb.14.d13', '%bb.15.d14', '%bb.2.d1', '%bb.16.d15',
'%bb.17.d16', '%bb.18.d17' ]
body: |
bb.0 (%ir-block.0):
successors: %bb.2.d1(0x03c3c3c4), %bb.1(0x7c3c3c3c)
liveins: $r0, $r1
$r2 = tLDRpci %const.0, 14, $noreg
tSTRi killed $r2, killed $r1, 0, 14, $noreg :: (store 4 into %ir.addr)
dead $r1 = SPACE 980, undef $r0
$r0 = tUXTB killed $r0, 14, $noreg
$r1, dead $cpsr = tSUBi3 killed $r0, 1, 14, $noreg
tCMPi8 $r1, 25, 14, $noreg, implicit-def $cpsr
tBcc %bb.2.d1, 8, killed $cpsr
bb.1 (%ir-block.0):
successors: %bb.3.d2(0x07c549d2), %bb.9.d8(0x07c549d2), %bb.4.d3(0x07c549d2), %bb.5.d4(0x07c549d2), %bb.6.d5(0x07c549d2), %bb.7.d6(0x07c549d2), %bb.8.d7(0x07c549d2), %bb.10.d9(0x07c549d2), %bb.11.d10(0x07c549d2), %bb.2.d1(0x03ab62db), %bb.12.d11(0x07c549d2), %bb.13.d12(0x07c549d2), %bb.14.d13(0x07c549d2), %bb.15.d14(0x07c549d2), %bb.16.d15(0x07c549d2), %bb.17.d16(0x07c549d2), %bb.18.d17(0x07c549d2)
liveins: $r1
$r0, dead $cpsr = tLSLri killed $r1, 2, 14, $noreg
$r1 = tLEApcrelJT %jump-table.0, 14, $noreg
$r0 = tLDRr killed $r1, killed $r0, 14, $noreg :: (load 4 from jump-table)
tBR_JTr killed $r0, %jump-table.0
bb.3.d2:
bb.9.d8:
bb.4.d3:
bb.5.d4:
bb.6.d5:
bb.7.d6:
bb.8.d7:
bb.10.d9:
bb.11.d10:
bb.2.d1:
bb.12.d11:
bb.13.d12:
bb.14.d13:
bb.15.d14:
bb.16.d15:
bb.17.d16:
bb.18.d17:
...
---
name: bar
alignment: 2
exposesReturnsTwice: false
legalized: false
regBankSelected: false
selected: false
tracksRegLiveness: true
liveins:
- { reg: '$r0' }
- { reg: '$r1' }
frameInfo:
isFrameAddressTaken: false
isReturnAddressTaken: false
hasStackMap: false
hasPatchPoint: false
stackSize: 0
offsetAdjustment: 0
maxAlignment: 0
adjustsStack: false
hasCalls: false
maxCallFrameSize: 0
hasOpaqueSPAdjustment: false
hasVAStart: false
hasMustTailInVarArgFunc: false
constants:
- id: 0
value: i32 12345678
alignment: 4
jumpTable:
kind: inline
entries:
- id: 0
blocks: [ '%bb.3.d2', '%bb.9.d8', '%bb.4.d3', '%bb.5.d4',
'%bb.6.d5', '%bb.7.d6', '%bb.8.d7', '%bb.10.d9',
'%bb.11.d10', '%bb.2.d1', '%bb.2.d1', '%bb.2.d1',
'%bb.2.d1', '%bb.2.d1', '%bb.2.d1', '%bb.2.d1',
'%bb.2.d1', '%bb.2.d1', '%bb.12.d11', '%bb.13.d12',
'%bb.14.d13', '%bb.15.d14', '%bb.2.d1', '%bb.16.d15',
'%bb.17.d16', '%bb.18.d17' ]
body: |
bb.0 (%ir-block.0):
successors: %bb.2.d1(0x03c3c3c4), %bb.1(0x7c3c3c3c)
liveins: $r0, $r1
$r2 = tLDRpci %const.0, 14, $noreg
tSTRi killed $r2, killed $r1, 0, 14, $noreg :: (store 4 into %ir.addr)
$r0 = tUXTB killed $r0, 14, $noreg
$r1, dead $cpsr = tSUBi3 killed $r0, 1, 14, $noreg
tCMPi8 $r1, 25, 14, $noreg, implicit-def $cpsr
tBcc %bb.2.d1, 8, killed $cpsr
bb.1 (%ir-block.0):
successors: %bb.3.d2(0x07c549d2), %bb.9.d8(0x07c549d2), %bb.4.d3(0x07c549d2), %bb.5.d4(0x07c549d2), %bb.6.d5(0x07c549d2), %bb.7.d6(0x07c549d2), %bb.8.d7(0x07c549d2), %bb.10.d9(0x07c549d2), %bb.11.d10(0x07c549d2), %bb.2.d1(0x03ab62db), %bb.12.d11(0x07c549d2), %bb.13.d12(0x07c549d2), %bb.14.d13(0x07c549d2), %bb.15.d14(0x07c549d2), %bb.16.d15(0x07c549d2), %bb.17.d16(0x07c549d2), %bb.18.d17(0x07c549d2)
liveins: $r1
$r0, dead $cpsr = tLSLri killed $r1, 2, 14, $noreg
$r1 = tLEApcrelJT %jump-table.0, 14, $noreg
$r0 = tLDRr killed $r1, killed $r0, 14, $noreg :: (load 4 from jump-table)
tBR_JTr killed $r0, %jump-table.0
bb.3.d2:
bb.9.d8:
bb.4.d3:
bb.5.d4:
bb.6.d5:
bb.7.d6:
bb.8.d7:
bb.10.d9:
bb.11.d10:
bb.2.d1:
bb.12.d11:
bb.13.d12:
bb.14.d13:
bb.15.d14:
bb.16.d15:
bb.17.d16:
bb.18.d17:
...