From dd353b8ad747a8731a191848ff5db978a70bd0fb Mon Sep 17 00:00:00 2001 From: Evan Cheng Date: Fri, 26 Jan 2007 02:02:39 +0000 Subject: [PATCH] SplitBlockBeforeInstr() insert a unconditional branch to the next BB. This is unnecessary when we are fixing up a conditional branch since we will be adding a unconditional branch to the destination of the original branch. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33517 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/ARM/ARMConstantIslandPass.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/Target/ARM/ARMConstantIslandPass.cpp b/lib/Target/ARM/ARMConstantIslandPass.cpp index 62e47172e26..db50bde3849 100644 --- a/lib/Target/ARM/ARMConstantIslandPass.cpp +++ b/lib/Target/ARM/ARMConstantIslandPass.cpp @@ -602,13 +602,17 @@ ARMConstantIslands::FixUpImmediateBranch(MachineFunction &Fn, ImmBranch &Br) { // direct the updated conditional branch to the fall-through block. Otherwise, // split the MBB before the next instruction. MachineBasicBlock *MBB = MI->getParent(); - if (&MBB->back() != MI || !BBHasFallthrough(MBB)) + if (&MBB->back() != MI || !BBHasFallthrough(MBB)) { SplitBlockBeforeInstr(MI); + // No need for the branch to the next block. We're adding a unconditional + // branch to the destination. + MBB->back().eraseFromParent(); + } MachineBasicBlock *NextBB = next(MachineFunction::iterator(MBB)); // Insert a unconditional branch and replace the conditional branch. // Also update the ImmBranch as well as adding a new entry for the new branch. - BuildMI(MBB, TII->get(MI->getOpcode())).addMBB(NextBB).addImm((unsigned)CC); + BuildMI(MBB, TII->get(MI->getOpcode())).addMBB(NextBB).addImm(CC); Br.MI = &MBB->back(); BuildMI(MBB, TII->get(Br.UncondBr)).addMBB(DestBB); unsigned MaxDisp = (Br.UncondBr == ARM::tB) ? (1<<10)*2 : (1<<23)*4; -- 2.34.1