blob: e015bf098ff87c9cbfcbc9a4108f64a66892294c [file] [log] [blame]
Chad Rosier0162ff42012-01-26 18:24:25 +00001; 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.
5; CHECK: fn:
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
12define i32 @fn(i32* nocapture %opcodes) nounwind readonly ssp {
13entry:
14 %0 = load i32* %opcodes, align 4, !tbaa !0
15 %arrayidx = getelementptr inbounds [3 x i8*]* @fn.codetable, i32 0, i32 %0
16 br label %indirectgoto
17
18INCREMENT: ; preds = %indirectgoto
19 %inc = add nsw i32 %result.0, 1
20 %1 = load i32* %opcodes.addr.0, align 4, !tbaa !0
21 %arrayidx2 = getelementptr inbounds [3 x i8*]* @fn.codetable, i32 0, i32 %1
22 br label %indirectgoto
23
24DECREMENT: ; preds = %indirectgoto
25 %dec = add nsw i32 %result.0, -1
26 %2 = load i32* %opcodes.addr.0, align 4, !tbaa !0
27 %arrayidx4 = getelementptr inbounds [3 x i8*]* @fn.codetable, i32 0, i32 %2
28 br label %indirectgoto
29
30indirectgoto: ; 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
38RETURN: ; preds = %indirectgoto
39 ret i32 %result.0
40}
41
42!0 = metadata !{metadata !"int", metadata !1}
43!1 = metadata !{metadata !"omnipotent char", metadata !2}
44!2 = metadata !{metadata !"Simple C/C++ TBAA", null}