Cleanup flow, and only update the jump table we're analyzing when replacing a destination MBB.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@88805 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Jim Grosbach 2009-11-14 20:10:18 +00:00
parent 68bb60f6a4
commit 00a6a1f022

View File

@ -1749,7 +1749,7 @@ bool ARMConstantIslands::ReorderThumb2JumpTables(MachineFunction &MF) {
MachineBasicBlock *NewBB = MachineBasicBlock *NewBB =
AdjustJTTargetBlockForward(MBB, MI->getParent()); AdjustJTTargetBlockForward(MBB, MI->getParent());
if (NewBB) if (NewBB)
MJTI->ReplaceMBBInJumpTables(JTBBs[j], NewBB); MJTI->ReplaceMBBInJumpTable(JTI, JTBBs[j], NewBB);
MadeChange = true; MadeChange = true;
} }
} }
@ -1772,16 +1772,16 @@ AdjustJTTargetBlockForward(MachineBasicBlock *BB, MachineBasicBlock *JTBB)
int Size = BBSizes[BBI]; int Size = BBSizes[BBI];
MachineBasicBlock *TBB = 0, *FBB = 0; MachineBasicBlock *TBB = 0, *FBB = 0;
SmallVector<MachineOperand, 4> Cond; SmallVector<MachineOperand, 4> Cond;
// If the block terminator isn't analyzable, don't try to move the block
if (TII->AnalyzeBranch(*BB, TBB, FBB, Cond))
return NULL;
// If the block is small and ends in an unconditional branch, move it. // If the block is small and ends in an unconditional branch, move it.
if (Size < 50 && Cond.empty()) { if (Size < 50 && Cond.empty()) {
// If the block terminator isn't analyzable, don't try to move the block
if (TII->AnalyzeBranch(*BB, TBB, FBB, Cond))
return NULL;
MachineFunction::iterator OldPrior = prior(BB); MachineFunction::iterator OldPrior = prior(BB);
BB->moveAfter(JTBB); BB->moveAfter(JTBB);
OldPrior->updateTerminator(); OldPrior->updateTerminator();
//BB->updateTerminator(); BB->updateTerminator();
++NumJTMoved; ++NumJTMoved;
return NULL; return NULL;
} }
@ -1792,20 +1792,22 @@ AdjustJTTargetBlockForward(MachineBasicBlock *BB, MachineBasicBlock *JTBB)
MachineFunction::iterator MBBI = JTBB; ++MBBI; MachineFunction::iterator MBBI = JTBB; ++MBBI;
MF.insert(MBBI, NewBB); MF.insert(MBBI, NewBB);
//MF.splice(MBBI, NewBB, NewBB);
// Add an unconditional branch from NewBB to BB. // Add an unconditional branch from NewBB to BB.
// There doesn't seem to be meaningful DebugInfo available; this doesn't // There doesn't seem to be meaningful DebugInfo available; this doesn't
// correspond directly to anything in the source. // correspond directly to anything in the source.
assert (isThumb2 && "Adjusting for TB[BH] but not in Thumb2?"); assert (isThumb2 && "Adjusting for TB[BH] but not in Thumb2?");
BuildMI(NewBB, DebugLoc::getUnknownLoc(), TII->get(ARM::t2B)).addMBB(BB); BuildMI(NewBB, DebugLoc::getUnknownLoc(), TII->get(ARM::t2B)).addMBB(BB);
// Update internal data structures to account for the newly inserted MBB.
MF.RenumberBlocks(NewBB);
// Update the CFG. // Update the CFG.
NewBB->addSuccessor(BB); NewBB->addSuccessor(BB);
JTBB->removeSuccessor(BB); JTBB->removeSuccessor(BB);
JTBB->addSuccessor(NewBB); JTBB->addSuccessor(NewBB);
// Update internal data structures to account for the newly inserted MBB.
MF.RenumberBlocks();
// Insert a size into BBSizes to align it properly with the (newly // Insert a size into BBSizes to align it properly with the (newly
// renumbered) block numbers. // renumbered) block numbers.
BBSizes.insert(BBSizes.begin()+NewBB->getNumber(), 0); BBSizes.insert(BBSizes.begin()+NewBB->getNumber(), 0);