Chad Rosier | 1a1531d | 2012-01-26 18:24:25 +0000 | [diff] [blame] | 1 | ; RUN: llc < %s -mtriple=thumb-apple-darwin -relocation-model=dynamic-no-pic -mcpu=cortex-a8 -asm-verbose=false | FileCheck %s |
| 2 | |
| 3 | ; We should be able to tail-duplicate the basic block containing the indirectbr |
| 4 | ; into all of its predecessors. |
Stephen Lin | d24ab20 | 2013-07-14 06:24:09 +0000 | [diff] [blame^] | 5 | ; CHECK-LABEL: fn: |
Chad Rosier | 1a1531d | 2012-01-26 18:24:25 +0000 | [diff] [blame] | 6 | ; CHECK: mov pc |
| 7 | ; CHECK: mov pc |
| 8 | ; CHECK: mov pc |
| 9 | |
| 10 | @fn.codetable = internal unnamed_addr constant [3 x i8*] [i8* blockaddress(@fn, %RETURN), i8* blockaddress(@fn, %INCREMENT), i8* blockaddress(@fn, %DECREMENT)], align 4 |
| 11 | |
| 12 | define i32 @fn(i32* nocapture %opcodes) nounwind readonly ssp { |
| 13 | entry: |
Manman Ren | 1a5ff28 | 2013-04-30 17:52:57 +0000 | [diff] [blame] | 14 | %0 = load i32* %opcodes, align 4 |
Chad Rosier | 1a1531d | 2012-01-26 18:24:25 +0000 | [diff] [blame] | 15 | %arrayidx = getelementptr inbounds [3 x i8*]* @fn.codetable, i32 0, i32 %0 |
| 16 | br label %indirectgoto |
| 17 | |
| 18 | INCREMENT: ; preds = %indirectgoto |
| 19 | %inc = add nsw i32 %result.0, 1 |
Manman Ren | 1a5ff28 | 2013-04-30 17:52:57 +0000 | [diff] [blame] | 20 | %1 = load i32* %opcodes.addr.0, align 4 |
Chad Rosier | 1a1531d | 2012-01-26 18:24:25 +0000 | [diff] [blame] | 21 | %arrayidx2 = getelementptr inbounds [3 x i8*]* @fn.codetable, i32 0, i32 %1 |
| 22 | br label %indirectgoto |
| 23 | |
| 24 | DECREMENT: ; preds = %indirectgoto |
| 25 | %dec = add nsw i32 %result.0, -1 |
Manman Ren | 1a5ff28 | 2013-04-30 17:52:57 +0000 | [diff] [blame] | 26 | %2 = load i32* %opcodes.addr.0, align 4 |
Chad Rosier | 1a1531d | 2012-01-26 18:24:25 +0000 | [diff] [blame] | 27 | %arrayidx4 = getelementptr inbounds [3 x i8*]* @fn.codetable, i32 0, i32 %2 |
| 28 | br label %indirectgoto |
| 29 | |
| 30 | indirectgoto: ; preds = %DECREMENT, %INCREMENT, %entry |
| 31 | %result.0 = phi i32 [ 0, %entry ], [ %dec, %DECREMENT ], [ %inc, %INCREMENT ] |
| 32 | %opcodes.pn = phi i32* [ %opcodes, %entry ], [ %opcodes.addr.0, %DECREMENT ], [ %opcodes.addr.0, %INCREMENT ] |
| 33 | %indirect.goto.dest.in = phi i8** [ %arrayidx, %entry ], [ %arrayidx4, %DECREMENT ], [ %arrayidx2, %INCREMENT ] |
| 34 | %opcodes.addr.0 = getelementptr inbounds i32* %opcodes.pn, i32 1 |
| 35 | %indirect.goto.dest = load i8** %indirect.goto.dest.in, align 4 |
| 36 | indirectbr i8* %indirect.goto.dest, [label %RETURN, label %INCREMENT, label %DECREMENT] |
| 37 | |
| 38 | RETURN: ; preds = %indirectgoto |
| 39 | ret i32 %result.0 |
| 40 | } |