Intelligently split the landing pad block.

We have to be careful when splitting the landing pad block, because the
landingpad instruction is required to remain as the first non-PHI of an invoke's
unwind edge. To retain this, we split the block into two blocks, moving the
predecessors within the loop to one block and the remaining predecessors to the
other. The landingpad instruction is cloned into the new blocks.

llvm-svn: 138015
This commit is contained in:
Bill Wendling 2011-08-19 00:09:22 +00:00
parent ca7d309623
commit c61f7659ba
1 changed files with 16 additions and 5 deletions

View File

@ -410,13 +410,24 @@ BasicBlock *LoopSimplify::RewriteLoopExitBlock(Loop *L, BasicBlock *Exit) {
}
assert(!LoopBlocks.empty() && "No edges coming in from outside the loop?");
BasicBlock *NewBB = SplitBlockPredecessors(Exit, &LoopBlocks[0],
LoopBlocks.size(), ".loopexit",
this);
BasicBlock *NewExitBB = 0;
if (Exit->isLandingPad()) {
SmallVector<BasicBlock*, 2> NewBBs;
SplitLandingPadPredecessors(Exit, ArrayRef<BasicBlock*>(&LoopBlocks[0],
LoopBlocks.size()),
".loopexit", ".nonloopexit",
this, NewBBs);
NewExitBB = NewBBs[0];
} else {
NewExitBB = SplitBlockPredecessors(Exit, &LoopBlocks[0],
LoopBlocks.size(), ".loopexit",
this);
}
DEBUG(dbgs() << "LoopSimplify: Creating dedicated exit block "
<< NewBB->getName() << "\n");
return NewBB;
<< NewExitBB->getName() << "\n");
return NewExitBB;
}
/// AddBlockAndPredsToSet - Add the specified block, and all of its