1 # RUN: llc -run-pass=arm-cp-islands -o - %s | FileCheck %s
3 # Test created by tweaking the register allocation after stopping the IR below
4 # just before constant islands. We were forwarding the table index to the end of
5 # the block, even though the LEA clobbered it.
7 # CHECK-LABEL: name: foo
9 # This order is important. If the jump-table comes first then the
10 # transformation is valid because the LEA can be removed, see second test.
11 # CHECK: CONSTPOOL_ENTRY
12 # CHECK: JUMPTABLE_ADDRS
14 # CHECK-LABEL: name: bar
15 # CHECK: tTBB_JT $pc, killed $r1
18 ; ModuleID = 'simple.ll'
19 source_filename = "simple.ll"
20 target datalayout = "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64"
21 target triple = "thumbv6m-none--eabi"
23 define void @foo(i8 %in, i32* %addr) {
24 store i32 12345678, i32* %addr
25 %1 = call i32 @llvm.arm.space(i32 980, i32 undef)
26 %2 = zext i8 %in to i32
27 switch i32 %2, label %default [
102 define void @bar(i8 %in, i32* %addr) {
103 store i32 12345678, i32* %addr
104 %1 = zext i8 %in to i32
105 switch i32 %1, label %default [
125 default: ; preds = %0
180 ; Function Attrs: nounwind
181 declare i32 @llvm.arm.space(i32, i32) #0
183 ; Function Attrs: nounwind
184 declare void @llvm.stackprotector(i8*, i8**) #0
186 attributes #0 = { nounwind }
192 exposesReturnsTwice: false
194 regBankSelected: false
196 tracksRegLiveness: true
201 isFrameAddressTaken: false
202 isReturnAddressTaken: false
211 hasOpaqueSPAdjustment: false
213 hasMustTailInVarArgFunc: false
222 blocks: [ '%bb.3.d2', '%bb.9.d8', '%bb.4.d3', '%bb.5.d4',
223 '%bb.6.d5', '%bb.7.d6', '%bb.8.d7', '%bb.10.d9',
224 '%bb.11.d10', '%bb.2.d1', '%bb.2.d1', '%bb.2.d1',
225 '%bb.2.d1', '%bb.2.d1', '%bb.2.d1', '%bb.2.d1',
226 '%bb.2.d1', '%bb.2.d1', '%bb.12.d11', '%bb.13.d12',
227 '%bb.14.d13', '%bb.15.d14', '%bb.2.d1', '%bb.16.d15',
228 '%bb.17.d16', '%bb.18.d17' ]
231 successors: %bb.2.d1(0x03c3c3c4), %bb.1(0x7c3c3c3c)
234 $r2 = tLDRpci %const.0, 14, $noreg
235 tSTRi killed $r2, killed $r1, 0, 14, $noreg :: (store 4 into %ir.addr)
236 dead $r1 = SPACE 980, undef $r0
237 $r0 = tUXTB killed $r0, 14, $noreg
238 $r1, dead $cpsr = tSUBi3 killed $r0, 1, 14, $noreg
239 tCMPi8 $r1, 25, 14, $noreg, implicit-def $cpsr
240 tBcc %bb.2.d1, 8, killed $cpsr
243 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)
246 $r0, dead $cpsr = tLSLri killed $r1, 2, 14, $noreg
247 $r1 = tLEApcrelJT %jump-table.0, 14, $noreg
248 $r0 = tLDRr killed $r1, killed $r0, 14, $noreg :: (load 4 from jump-table)
249 tBR_JTr killed $r0, %jump-table.0
290 exposesReturnsTwice: false
292 regBankSelected: false
294 tracksRegLiveness: true
299 isFrameAddressTaken: false
300 isReturnAddressTaken: false
309 hasOpaqueSPAdjustment: false
311 hasMustTailInVarArgFunc: false
320 blocks: [ '%bb.3.d2', '%bb.9.d8', '%bb.4.d3', '%bb.5.d4',
321 '%bb.6.d5', '%bb.7.d6', '%bb.8.d7', '%bb.10.d9',
322 '%bb.11.d10', '%bb.2.d1', '%bb.2.d1', '%bb.2.d1',
323 '%bb.2.d1', '%bb.2.d1', '%bb.2.d1', '%bb.2.d1',
324 '%bb.2.d1', '%bb.2.d1', '%bb.12.d11', '%bb.13.d12',
325 '%bb.14.d13', '%bb.15.d14', '%bb.2.d1', '%bb.16.d15',
326 '%bb.17.d16', '%bb.18.d17' ]
329 successors: %bb.2.d1(0x03c3c3c4), %bb.1(0x7c3c3c3c)
332 $r2 = tLDRpci %const.0, 14, $noreg
333 tSTRi killed $r2, killed $r1, 0, 14, $noreg :: (store 4 into %ir.addr)
334 $r0 = tUXTB killed $r0, 14, $noreg
335 $r1, dead $cpsr = tSUBi3 killed $r0, 1, 14, $noreg
336 tCMPi8 $r1, 25, 14, $noreg, implicit-def $cpsr
337 tBcc %bb.2.d1, 8, killed $cpsr
340 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)
343 $r0, dead $cpsr = tLSLri killed $r1, 2, 14, $noreg
344 $r1 = tLEApcrelJT %jump-table.0, 14, $noreg
345 $r0 = tLDRr killed $r1, killed $r0, 14, $noreg :: (load 4 from jump-table)
346 tBR_JTr killed $r0, %jump-table.0