1# REQUIRES: asserts 2# RUN: llc -run-pass arm-cp-islands %s -o - | FileCheck %s 3# 4# This is a reduced test made to expose a bug in 5# ARMConstantIslandPass in Thumb1 mode, see PR36658. 6 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 10# CHECK-LABEL: bb.8: 11# CHECK: JUMPTABLE_TBB 0, %jump-table.1, 44 12 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 16# CHECK-LABEL: bb.12: 17# CHECK: JUMPTABLE_TBB 1, %jump-table.0, 44 18 19--- | 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" 24 25 declare i32 @foo1(...) 26 27 declare i32 @foo2(i32) 28 29 declare i32 @foo3(i32*) 30 31 ; Function Attrs: nounwind optsize 32 define internal fastcc i32 @foo4(i32* nocapture %ignore_ptr) #0 { 33 entry: 34 %call = tail call i32 @foo3(i32* undef) 35 switch i32 %call, label %sw.epilog [ 36 i32 120, label %sw.bb 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 59 ] 60 61 sw.bb: ; preds = %entry 62 br label %while.cond 63 64 while.cond: ; preds = %while.cond, %sw.bb 65 %call5 = tail call i32 @foo3(i32* null) 66 br label %while.cond 67 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 72 73 while.body83.preheader: ; preds = %sw.bb73 74 br label %while.body83 75 76 while.body83: ; preds = %while.body83.preheader, %while.body83 77 %call87 = tail call i32 @foo3(i32* null) 78 br label %while.body83 79 80 while.end88: ; preds = %sw.bb73 81 %call89 = tail call i32 @foo2(i32 %call) 82 unreachable 83 84 sw.bb91: ; preds = %entry 85 store i32 1, i32* %ignore_ptr, align 4 86 br label %cleanup 87 88 sw.bb93: ; preds = %entry 89 br label %cleanup 90 91 sw.bb94: ; preds = %entry 92 br label %cleanup 93 94 sw.bb95: ; preds = %entry 95 br label %cleanup 96 97 sw.bb96: ; preds = %entry 98 br label %cleanup 99 100 sw.bb97: ; preds = %entry 101 br label %cleanup 102 103 sw.bb98: ; preds = %entry 104 br label %cleanup 105 106 sw.bb106: ; preds = %entry 107 br label %cleanup 108 109 sw.bb107: ; preds = %entry, %entry 110 br i1 undef, label %cleanup, label %if.then109 111 112 if.then109: ; preds = %sw.bb107 113 %call110 = tail call i32 bitcast (i32 (...)* @foo1 to i32 (i8*, i32)*)(i8* undef, i32 %call) 114 unreachable 115 116 sw.epilog: ; preds = %entry 117 %call.off = add i32 %call, -32 118 unreachable 119 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 ] 122 ret i32 %retval.0 123 } 124 125 ; Function Attrs: nounwind 126 declare void @llvm.stackprotector(i8*, i8**) #1 127 128 attributes #0 = { nounwind optsize } 129 attributes #1 = { nounwind } 130 131... 132--- 133name: foo4 134alignment: 1 135tracksRegLiveness: true 136liveins: 137 - { reg: '$r0' } 138frameInfo: 139 stackSize: 8 140 maxAlignment: 4 141 adjustsStack: true 142 hasCalls: true 143 maxCallFrameSize: 0 144stack: 145 - { id: 0, type: spill-slot, offset: -4, size: 4, alignment: 4, stack-id: 0, 146 callee-saved-register: '$lr', callee-saved-restored: false } 147 - { id: 1, type: spill-slot, offset: -8, size: 4, alignment: 4, stack-id: 0, 148 callee-saved-register: '$r4' } 149jumpTable: 150 kind: inline 151 entries: 152 - id: 0 153 blocks: [ '%bb.28', '%bb.26', '%bb.26', '%bb.26', '%bb.26', 154 '%bb.24', '%bb.23', '%bb.26', '%bb.26', '%bb.12', 155 '%bb.22' ] 156 - id: 1 157 blocks: [ '%bb.19', '%bb.26', '%bb.26', '%bb.26', '%bb.21', 158 '%bb.26', '%bb.20', '%bb.26', '%bb.25', '%bb.26', 159 '%bb.15' ] 160body: | 161 bb.0.entry: 162 successors: %bb.1(0x42c8590b), %bb.9(0x3d37a6f5) 163 liveins: $r0, $r4, $lr 164 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 174 175 bb.1.entry: 176 successors: %bb.2(0x20000000), %bb.7(0x60000000) 177 liveins: $r0, $r1, $r4 178 179 tCMPi8 renamable $r1, 47, 14, $noreg, implicit-def $cpsr 180 tBcc %bb.2, 13, killed $cpsr 181 182 bb.7.entry: 183 successors: %bb.16(0x71c71c72), %bb.8(0x0e38e38e) 184 liveins: $r0, $r1 185 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 190 191 bb.16.sw.bb73: 192 successors: %bb.17(0x7fffffff), %bb.18(0x00000001) 193 liveins: $r0, $r1 194 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 199 200 bb.17.while.body83: 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 204 205 bb.9.entry: 206 successors: %bb.10(0x45d1745d), %bb.29(0x3a2e8ba3) 207 liveins: $r0, $r1 208 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 213 214 bb.10.entry: 215 successors: %bb.11(0x15555555), %bb.14(0x6aaaaaab) 216 liveins: $r0, $r1 217 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 222 223 bb.14.entry: 224 successors: %bb.19(0x1999999a), %bb.26(0x00000000), %bb.21(0x1999999a), %bb.20(0x1999999a), %bb.25(0x1999999a), %bb.15(0x1999999a) 225 liveins: $r2 226 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 231 232 bb.19.sw.bb93: 233 renamable $r1, dead $cpsr = tMOVi8 10, 14, $noreg 234 tB %bb.28, 14, $noreg 235 236 bb.15.while.cond: 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 240 241 bb.29.entry: 242 successors: %bb.28(0x1999999a), %bb.26(0x00000000), %bb.24(0x1999999a), %bb.23(0x1999999a), %bb.12(0x1999999a), %bb.22(0x1999999a) 243 liveins: $r0, $r2 244 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 250 251 bb.24.sw.bb98: 252 renamable $r1, dead $cpsr = tMOVi8 7, 14, $noreg 253 tB %bb.28, 14, $noreg 254 255 bb.2.entry: 256 successors: %bb.27(0x2aaaaaab), %bb.3(0x55555555) 257 liveins: $r0, $r1, $r4 258 259 tCMPi8 renamable $r1, 10, 14, $noreg, implicit-def $cpsr 260 tBcc %bb.27, 0, killed $cpsr 261 262 bb.3.entry: 263 successors: %bb.4, %bb.5 264 liveins: $r0, $r1 265 266 tCMPi8 renamable $r1, 34, 14, $noreg, implicit-def $cpsr 267 tBcc %bb.5, 1, killed $cpsr 268 269 bb.4: 270 liveins: $r0 271 272 $r1 = tMOVSr killed $r0, implicit-def dead $cpsr 273 tB %bb.28, 14, $noreg 274 275 bb.25.sw.bb106: 276 renamable $r1, dead $cpsr = tMOVi8 11, 14, $noreg 277 tB %bb.28, 14, $noreg 278 279 bb.23.sw.bb97: 280 renamable $r1, dead $cpsr = tMOVi8 8, 14, $noreg 281 tB %bb.28, 14, $noreg 282 283 bb.27.sw.bb91: 284 liveins: $r4 285 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 290 291 bb.21.sw.bb95: 292 renamable $r1, dead $cpsr = tMOVi8 13, 14, $noreg 293 tB %bb.28, 14, $noreg 294 295 bb.20.sw.bb94: 296 renamable $r1, dead $cpsr = tMOVi8 9, 14, $noreg 297 tB %bb.28, 14, $noreg 298 299 bb.5.entry: 300 liveins: $r0, $r1 301 302 tCMPi8 killed renamable $r1, 39, 14, $noreg, implicit-def $cpsr 303 tB %bb.6, 14, $noreg 304 305 bb.11.entry: 306 successors: %bb.12(0x80000000), %bb.26(0x00000000) 307 liveins: $r0, $r1 308 309 tCMPi8 killed renamable $r1, 69, 14, $noreg, implicit-def $cpsr 310 tBcc %bb.26, 1, killed $cpsr 311 312 bb.12.sw.bb107: 313 successors: %bb.28(0x7fffffff), %bb.13(0x00000001) 314 liveins: $r0 315 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 320 321 bb.13.if.then109: 322 successors: 323 liveins: $r0 324 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 327 328 bb.8.entry: 329 liveins: $r0, $r1 330 331 tCMPi8 killed renamable $r1, 63, 14, $noreg, implicit-def $cpsr 332 333 bb.6.entry: 334 successors: %bb.28(0x80000000), %bb.26(0x00000000) 335 liveins: $cpsr, $r0 336 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 340 341 bb.26.sw.epilog: 342 successors: 343 344 345 bb.22.sw.bb96: 346 renamable $r1, dead $cpsr = tMOVi8 12, 14, $noreg 347 348 bb.28.cleanup: 349 liveins: $r1 350 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 353 354 bb.18.while.end88: 355 liveins: $r0 356 357 tBL 14, $noreg, @foo2, csr_aapcs, implicit-def dead $lr, implicit $sp, implicit $r0, implicit-def $sp, implicit-def dead $r0 358 359... 360