blob: da3839893324baed4da0511e1b56e84e00ff8f55 [file] [log] [blame]
Kyle Butt6262ca32016-08-24 21:34:24 +00001; RUN: llc < %s -mtriple=thumbv7-apple-ios -arm-atomic-cfg-tidy=0 -stats 2>&1 | FileCheck %s
Lang Hames24864fe2013-07-19 23:52:47 +00002
3; If ARMBaseInstrInfo::AnalyzeBlocks returns the wrong value, which was possible
4; for blocks with indirect branches, the IfConverter could end up deleting
5; blocks that were the destinations of indirect branches, leaving branches to
6; nowhere.
7; <rdar://problem/14464830>
8
9define i32 @preserve_blocks(i32 %x) {
10; preserve_blocks:
11; CHECK: Block address taken
Lang Hames24864fe2013-07-19 23:52:47 +000012; CHECK: movs r0, #1
Kyle Butt6262ca32016-08-24 21:34:24 +000013; CHECK: Block address taken
14; CHECK: movs r0, #2
Lang Hames24864fe2013-07-19 23:52:47 +000015; CHECK-NOT: Address of block that was removed by CodeGen
Kyle Butt6262ca32016-08-24 21:34:24 +000016
17; Separate bug. There are no valid diamonds to if-convert in this file.
18; There was a bug in the if-conversion code that would if-convert a false
19; diamond where one side had a return and the other had an indirect branch.
20; Make sure no diamond conversions occurred while compiling this file.
21; CHECK: Statistics Collected
22; CHECK-NOT: 1 ifcvt - Number of diamond if-conversions performed
Lang Hames24864fe2013-07-19 23:52:47 +000023entry:
24 %c2 = icmp slt i32 %x, 3
25 %blockaddr = select i1 %c2, i8* blockaddress(@preserve_blocks, %ibt1), i8* blockaddress(@preserve_blocks, %ibt2)
26 %c1 = icmp eq i32 %x, 0
27 br i1 %c1, label %pre_ib, label %nextblock
28
29nextblock:
30 ret i32 3
31
32ibt1:
33 ret i32 2
34
35ibt2:
36 ret i32 1
37
38pre_ib:
39 indirectbr i8* %blockaddr, [ label %ibt1, label %ibt2 ]
40}