diff --git a/lib/Target/ARM/ARMFastISel.cpp b/lib/Target/ARM/ARMFastISel.cpp index 92248f53178..89b85d09b72 100644 --- a/lib/Target/ARM/ARMFastISel.cpp +++ b/lib/Target/ARM/ARMFastISel.cpp @@ -1388,6 +1388,11 @@ bool ARMFastISel::SelectIndirectBr(const Instruction *I) { unsigned Opc = isThumb2 ? ARM::tBRIND : ARM::BX; AddOptionalDefs(BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL, TII.get(Opc)) .addReg(AddrReg)); + + const IndirectBrInst *IB = cast(I); + for (unsigned i = 0, e = IB->getNumSuccessors(); i != e; ++i) + FuncInfo.MBB->addSuccessor(FuncInfo.MBBMap[IB->getSuccessor(i)]); + return true; } diff --git a/test/CodeGen/ARM/indirectbr-2.ll b/test/CodeGen/ARM/indirectbr-2.ll new file mode 100644 index 00000000000..084f520a8ee --- /dev/null +++ b/test/CodeGen/ARM/indirectbr-2.ll @@ -0,0 +1,46 @@ +; RUN: llc < %s -O0 -relocation-model=pic -mtriple=thumbv7-apple-ios | FileCheck %s +; + +@foo = global i32 34879, align 4 +@DWJumpTable2808 = global [2 x i32] [i32 sub (i32 ptrtoint (i8* blockaddress(@func, %14) to i32), i32 ptrtoint (i8* blockaddress(@func, %4) to i32)), i32 sub (i32 ptrtoint (i8* blockaddress(@func, %13) to i32), i32 ptrtoint (i8* blockaddress(@func, %4) to i32))] +@0 = internal constant [45 x i8] c"func XXXXXXXXXXX :: bb xxxxxxxxxxxxxxxxxxxx\0A\00" + +; The indirect branch has the two destinations as successors. The lone PHI +; statement shouldn't be implicitly defined. + +; CHECK: func: +; CHECK: Ltmp1: @ Block address taken +; CHECK-NOT: @ implicit-def: R0 +; CHECK: @ 4-byte Reload + +define i32 @func() nounwind ssp { + %1 = alloca i32, align 4 + %2 = load i32* @foo, align 4 + %3 = icmp eq i32 %2, 34879 + br label %4 + +;