xref: /aosp_15_r20/external/llvm/test/CodeGen/ARM/indirectbr-3.ll (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker; RUN: llc < %s -mtriple=thumbv7-apple-ios -arm-atomic-cfg-tidy=0 | FileCheck %s
2*9880d681SAndroid Build Coastguard Worker
3*9880d681SAndroid Build Coastguard Worker; If ARMBaseInstrInfo::AnalyzeBlocks returns the wrong value, which was possible
4*9880d681SAndroid Build Coastguard Worker; for blocks with indirect branches, the IfConverter could end up deleting
5*9880d681SAndroid Build Coastguard Worker; blocks that were the destinations of indirect branches, leaving branches to
6*9880d681SAndroid Build Coastguard Worker; nowhere.
7*9880d681SAndroid Build Coastguard Worker; <rdar://problem/14464830>
8*9880d681SAndroid Build Coastguard Worker
9*9880d681SAndroid Build Coastguard Workerdefine i32 @preserve_blocks(i32 %x) {
10*9880d681SAndroid Build Coastguard Worker; preserve_blocks:
11*9880d681SAndroid Build Coastguard Worker; CHECK: Block address taken
12*9880d681SAndroid Build Coastguard Worker; CHECK: movs r0, #2
13*9880d681SAndroid Build Coastguard Worker; CHECK: movs r0, #1
14*9880d681SAndroid Build Coastguard Worker; CHECK-NOT: Address of block that was removed by CodeGen
15*9880d681SAndroid Build Coastguard Workerentry:
16*9880d681SAndroid Build Coastguard Worker  %c2 = icmp slt i32 %x, 3
17*9880d681SAndroid Build Coastguard Worker  %blockaddr = select i1 %c2, i8* blockaddress(@preserve_blocks, %ibt1), i8* blockaddress(@preserve_blocks, %ibt2)
18*9880d681SAndroid Build Coastguard Worker  %c1 = icmp eq i32 %x, 0
19*9880d681SAndroid Build Coastguard Worker  br i1 %c1, label %pre_ib, label %nextblock
20*9880d681SAndroid Build Coastguard Worker
21*9880d681SAndroid Build Coastguard Workernextblock:
22*9880d681SAndroid Build Coastguard Worker  ret i32 3
23*9880d681SAndroid Build Coastguard Worker
24*9880d681SAndroid Build Coastguard Workeribt1:
25*9880d681SAndroid Build Coastguard Worker  ret i32 2
26*9880d681SAndroid Build Coastguard Worker
27*9880d681SAndroid Build Coastguard Workeribt2:
28*9880d681SAndroid Build Coastguard Worker  ret i32 1
29*9880d681SAndroid Build Coastguard Worker
30*9880d681SAndroid Build Coastguard Workerpre_ib:
31*9880d681SAndroid Build Coastguard Worker  indirectbr i8* %blockaddr, [ label %ibt1, label %ibt2 ]
32*9880d681SAndroid Build Coastguard Worker}
33