| Kyle Butt | 6262ca3 | 2016-08-24 21:34:24 +0000 | [diff] [blame^] | 1 | ; RUN: llc < %s -mtriple=thumbv7-apple-ios -arm-atomic-cfg-tidy=0 -stats 2>&1 | FileCheck %s |
| Lang Hames | 24864fe | 2013-07-19 23:52:47 +0000 | [diff] [blame] | 2 | |
| 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 | |
| 9 | define i32 @preserve_blocks(i32 %x) { |
| 10 | ; preserve_blocks: |
| 11 | ; CHECK: Block address taken |
| Lang Hames | 24864fe | 2013-07-19 23:52:47 +0000 | [diff] [blame] | 12 | ; CHECK: movs r0, #1 |
| Kyle Butt | 6262ca3 | 2016-08-24 21:34:24 +0000 | [diff] [blame^] | 13 | ; CHECK: Block address taken |
| 14 | ; CHECK: movs r0, #2 |
| Lang Hames | 24864fe | 2013-07-19 23:52:47 +0000 | [diff] [blame] | 15 | ; CHECK-NOT: Address of block that was removed by CodeGen |
| Kyle Butt | 6262ca3 | 2016-08-24 21:34:24 +0000 | [diff] [blame^] | 16 | |
| 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 Hames | 24864fe | 2013-07-19 23:52:47 +0000 | [diff] [blame] | 23 | entry: |
| 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 | |
| 29 | nextblock: |
| 30 | ret i32 3 |
| 31 | |
| 32 | ibt1: |
| 33 | ret i32 2 |
| 34 | |
| 35 | ibt2: |
| 36 | ret i32 1 |
| 37 | |
| 38 | pre_ib: |
| 39 | indirectbr i8* %blockaddr, [ label %ibt1, label %ibt2 ] |
| 40 | } |