2 # RUN: llc -run-pass arm-cp-islands %s -o - | FileCheck %s
4 # This is a reduced test made to expose a bug in
5 # ARMConstantIslandPass in Thumb1 mode, see PR36658.
7 # Verify optimized JT code uses TBB instructions.
8 # CHECK-LABEL: bb.7.entry:
9 # CHECK: tTBB_JT $pc, killed $r2, %jump-table.1, 0
11 # CHECK: JUMPTABLE_TBB 0, %jump-table.1, 44
13 # CHECK-LABEL: bb.11.entry:
14 # CHECK: $r1 = tMOVSr $r0, implicit-def dead $cpsr
15 # CHECK: tTBB_JT $pc, killed $r2, %jump-table.0, 1
17 # CHECK: JUMPTABLE_TBB 1, %jump-table.0, 44
20 ; ModuleID = 'PR36658.ll'
21 source_filename = "PR36658.ll"
22 target datalayout = "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64"
23 target triple = "thumbv5e-none-linux-gnueabi"
25 declare i32 @foo1(...)
27 declare i32 @foo2(i32)
29 declare i32 @foo3(i32*)
31 ; Function Attrs: nounwind optsize
32 define internal fastcc i32 @foo4(i32* nocapture %ignore_ptr) #0 {
34 %call = tail call i32 @foo3(i32* undef)
35 switch i32 %call, label %sw.epilog [
37 i32 48, label %sw.bb73
38 i32 49, label %sw.bb73
39 i32 50, label %sw.bb73
40 i32 51, label %sw.bb73
41 i32 52, label %sw.bb73
42 i32 53, label %sw.bb73
43 i32 54, label %sw.bb73
44 i32 55, label %sw.bb73
45 i32 92, label %cleanup
46 i32 39, label %cleanup
47 i32 34, label %cleanup
48 i32 10, label %sw.bb91
49 i32 110, label %sw.bb93
50 i32 116, label %sw.bb94
51 i32 114, label %sw.bb95
52 i32 102, label %sw.bb96
53 i32 98, label %sw.bb97
54 i32 97, label %sw.bb98
55 i32 118, label %sw.bb106
56 i32 101, label %sw.bb107
57 i32 69, label %sw.bb107
58 i32 63, label %cleanup
61 sw.bb: ; preds = %entry
64 while.cond: ; preds = %while.cond, %sw.bb
65 %call5 = tail call i32 @foo3(i32* null)
68 sw.bb73: ; preds = %entry, %entry, %entry, %entry, %entry, %entry, %entry, %entry
69 %0 = and i32 %call, -8
70 %1 = icmp eq i32 %0, 48
71 br i1 %1, label %while.body83.preheader, label %while.end88
73 while.body83.preheader: ; preds = %sw.bb73
74 br label %while.body83
76 while.body83: ; preds = %while.body83.preheader, %while.body83
77 %call87 = tail call i32 @foo3(i32* null)
78 br label %while.body83
80 while.end88: ; preds = %sw.bb73
81 %call89 = tail call i32 @foo2(i32 %call)
84 sw.bb91: ; preds = %entry
85 store i32 1, i32* %ignore_ptr, align 4
88 sw.bb93: ; preds = %entry
91 sw.bb94: ; preds = %entry
94 sw.bb95: ; preds = %entry
97 sw.bb96: ; preds = %entry
100 sw.bb97: ; preds = %entry
103 sw.bb98: ; preds = %entry
106 sw.bb106: ; preds = %entry
109 sw.bb107: ; preds = %entry, %entry
110 br i1 undef, label %cleanup, label %if.then109
112 if.then109: ; preds = %sw.bb107
113 %call110 = tail call i32 bitcast (i32 (...)* @foo1 to i32 (i8*, i32)*)(i8* undef, i32 %call)
116 sw.epilog: ; preds = %entry
117 %call.off = add i32 %call, -32
120 cleanup: ; preds = %sw.bb107, %sw.bb106, %sw.bb98, %sw.bb97, %sw.bb96, %sw.bb95, %sw.bb94, %sw.bb93, %sw.bb91, %entry, %entry, %entry, %entry
121 %retval.0 = phi i32 [ 11, %sw.bb106 ], [ 7, %sw.bb98 ], [ 8, %sw.bb97 ], [ 12, %sw.bb96 ], [ 13, %sw.bb95 ], [ 9, %sw.bb94 ], [ 10, %sw.bb93 ], [ 0, %sw.bb91 ], [ %call, %entry ], [ %call, %entry ], [ %call, %entry ], [ 27, %sw.bb107 ], [ %call, %entry ]
125 ; Function Attrs: nounwind
126 declare void @llvm.stackprotector(i8*, i8**) #1
128 attributes #0 = { nounwind optsize }
129 attributes #1 = { nounwind }
135 tracksRegLiveness: true
145 - { id: 0, type: spill-slot, offset: -4, size: 4, alignment: 4, stack-id: default,
146 callee-saved-register: '$lr', callee-saved-restored: false }
147 - { id: 1, type: spill-slot, offset: -8, size: 4, alignment: 4, stack-id: default,
148 callee-saved-register: '$r4' }
153 blocks: [ '%bb.28', '%bb.26', '%bb.26', '%bb.26', '%bb.26',
154 '%bb.24', '%bb.23', '%bb.26', '%bb.26', '%bb.12',
157 blocks: [ '%bb.19', '%bb.26', '%bb.26', '%bb.26', '%bb.21',
158 '%bb.26', '%bb.20', '%bb.26', '%bb.25', '%bb.26',
162 successors: %bb.1(0x42c8590b), %bb.9(0x3d37a6f5)
163 liveins: $r0, $r4, $lr
165 frame-setup tPUSH 14, $noreg, killed $r4, killed $lr, implicit-def $sp, implicit $sp
166 frame-setup CFI_INSTRUCTION def_cfa_offset 8
167 frame-setup CFI_INSTRUCTION offset $lr, -4
168 frame-setup CFI_INSTRUCTION offset $r4, -8
169 $r4 = tMOVSr $r0, implicit-def dead $cpsr
170 tBL 14, $noreg, @foo3, csr_aapcs, implicit-def dead $lr, implicit $sp, implicit undef $r0, implicit-def $sp, implicit-def $r0
171 $r1 = tMOVSr $r0, implicit-def dead $cpsr
172 tCMPi8 $r0, 68, 14, $noreg, implicit-def $cpsr
173 tBcc %bb.9, 12, killed $cpsr
176 successors: %bb.2(0x20000000), %bb.7(0x60000000)
177 liveins: $r0, $r1, $r4
179 tCMPi8 renamable $r1, 47, 14, $noreg, implicit-def $cpsr
180 tBcc %bb.2, 13, killed $cpsr
183 successors: %bb.16(0x71c71c72), %bb.8(0x0e38e38e)
186 $r2 = tMOVSr $r1, implicit-def dead $cpsr
187 renamable $r2, dead $cpsr = tSUBi8 killed renamable $r2, 48, 14, $noreg
188 tCMPi8 killed renamable $r2, 8, 14, $noreg, implicit-def $cpsr
189 tBcc %bb.8, 2, killed $cpsr
192 successors: %bb.17(0x7fffffff), %bb.18(0x00000001)
195 renamable $r2, dead $cpsr = tMOVi8 7, 14, $noreg
196 renamable $r1, dead $cpsr = tBIC killed renamable $r1, killed renamable $r2, 14, $noreg
197 tCMPi8 killed renamable $r1, 48, 14, $noreg, implicit-def $cpsr
198 tBcc %bb.18, 1, killed $cpsr
201 renamable $r0, dead $cpsr = tMOVi8 0, 14, $noreg
202 tBL 14, $noreg, @foo3, csr_aapcs, implicit-def dead $lr, implicit $sp, implicit $r0, implicit-def $sp, implicit-def dead $r0
203 tB %bb.17, 14, $noreg
206 successors: %bb.10(0x45d1745d), %bb.29(0x3a2e8ba3)
209 $r2 = tMOVSr $r1, implicit-def dead $cpsr
210 renamable $r2, dead $cpsr = tSUBi8 killed renamable $r2, 92, 14, $noreg
211 tCMPi8 renamable $r2, 10, 14, $noreg, implicit-def $cpsr
212 tBcc %bb.29, 9, killed $cpsr
215 successors: %bb.11(0x15555555), %bb.14(0x6aaaaaab)
218 $r2 = tMOVSr $r1, implicit-def dead $cpsr
219 renamable $r2, dead $cpsr = tSUBi8 killed renamable $r2, 110, 14, $noreg
220 tCMPi8 renamable $r2, 10, 14, $noreg, implicit-def $cpsr
221 tBcc %bb.11, 8, killed $cpsr
224 successors: %bb.19(0x1999999a), %bb.26(0x00000000), %bb.21(0x1999999a), %bb.20(0x1999999a), %bb.25(0x1999999a), %bb.15(0x1999999a)
227 renamable $r0, dead $cpsr = tLSLri killed renamable $r2, 2, 14, $noreg
228 renamable $r1 = tLEApcrelJT %jump-table.1, 14, $noreg
229 renamable $r0 = tLDRr killed renamable $r1, killed renamable $r0, 14, $noreg :: (load 4 from jump-table)
230 tBR_JTr killed renamable $r0, %jump-table.1
233 renamable $r1, dead $cpsr = tMOVi8 10, 14, $noreg
234 tB %bb.28, 14, $noreg
237 renamable $r0, dead $cpsr = tMOVi8 0, 14, $noreg
238 tBL 14, $noreg, @foo3, csr_aapcs, implicit-def dead $lr, implicit $sp, implicit $r0, implicit-def $sp, implicit-def dead $r0
239 tB %bb.15, 14, $noreg
242 successors: %bb.28(0x1999999a), %bb.26(0x00000000), %bb.24(0x1999999a), %bb.23(0x1999999a), %bb.12(0x1999999a), %bb.22(0x1999999a)
245 renamable $r1, dead $cpsr = tLSLri killed renamable $r2, 2, 14, $noreg
246 renamable $r2 = tLEApcrelJT %jump-table.0, 14, $noreg
247 renamable $r2 = tLDRr killed renamable $r2, killed renamable $r1, 14, $noreg :: (load 4 from jump-table)
248 $r1 = tMOVSr $r0, implicit-def dead $cpsr
249 tBR_JTr killed renamable $r2, %jump-table.0
252 renamable $r1, dead $cpsr = tMOVi8 7, 14, $noreg
253 tB %bb.28, 14, $noreg
256 successors: %bb.27(0x2aaaaaab), %bb.3(0x55555555)
257 liveins: $r0, $r1, $r4
259 tCMPi8 renamable $r1, 10, 14, $noreg, implicit-def $cpsr
260 tBcc %bb.27, 0, killed $cpsr
263 successors: %bb.4, %bb.5
266 tCMPi8 renamable $r1, 34, 14, $noreg, implicit-def $cpsr
267 tBcc %bb.5, 1, killed $cpsr
272 $r1 = tMOVSr killed $r0, implicit-def dead $cpsr
273 tB %bb.28, 14, $noreg
276 renamable $r1, dead $cpsr = tMOVi8 11, 14, $noreg
277 tB %bb.28, 14, $noreg
280 renamable $r1, dead $cpsr = tMOVi8 8, 14, $noreg
281 tB %bb.28, 14, $noreg
286 renamable $r0, dead $cpsr = tMOVi8 1, 14, $noreg
287 tSTRi killed renamable $r0, killed renamable $r4, 0, 14, $noreg :: (store 4 into %ir.ignore_ptr)
288 renamable $r1, dead $cpsr = tMOVi8 0, 14, $noreg
289 tB %bb.28, 14, $noreg
292 renamable $r1, dead $cpsr = tMOVi8 13, 14, $noreg
293 tB %bb.28, 14, $noreg
296 renamable $r1, dead $cpsr = tMOVi8 9, 14, $noreg
297 tB %bb.28, 14, $noreg
302 tCMPi8 killed renamable $r1, 39, 14, $noreg, implicit-def $cpsr
306 successors: %bb.12(0x80000000), %bb.26(0x00000000)
309 tCMPi8 killed renamable $r1, 69, 14, $noreg, implicit-def $cpsr
310 tBcc %bb.26, 1, killed $cpsr
313 successors: %bb.28(0x7fffffff), %bb.13(0x00000001)
316 renamable $r1, dead $cpsr = tMOVi8 27, 14, $noreg
317 renamable $r2, dead $cpsr = tMOVi8 0, 14, $noreg
318 tCMPi8 killed renamable $r2, 0, 14, $noreg, implicit-def $cpsr
319 tBcc %bb.28, 1, killed $cpsr
325 $r1 = tMOVSr killed $r0, implicit-def dead $cpsr
326 tBL 14, $noreg, @foo1, csr_aapcs, implicit-def dead $lr, implicit $sp, implicit undef $r0, implicit $r1, implicit-def $sp, implicit-def dead $r0
331 tCMPi8 killed renamable $r1, 63, 14, $noreg, implicit-def $cpsr
334 successors: %bb.28(0x80000000), %bb.26(0x00000000)
337 tPUSH 14, $noreg, killed $r0, implicit-def $sp, implicit $sp
338 tPOP 14, $noreg, def $r1, implicit-def $sp, implicit $sp
339 tBcc %bb.28, 0, killed $cpsr
346 renamable $r1, dead $cpsr = tMOVi8 12, 14, $noreg
351 $r0 = tMOVSr killed $r1, implicit-def dead $cpsr
352 tPOP_RET 14, $noreg, def $r4, def $pc, implicit-def $sp, implicit $sp, implicit $r0
357 tBL 14, $noreg, @foo2, csr_aapcs, implicit-def dead $lr, implicit $sp, implicit $r0, implicit-def $sp, implicit-def dead $r0