forked from OSchip/llvm-project
Add a new assertion to check that stuff is happening right
Ironically the exit block modification code wasn't updating the exit block information itself. Fix this. llvm-svn: 5659
This commit is contained in:
parent
1ad80e2511
commit
10b2b055e8
|
@ -95,6 +95,8 @@ bool Preheaders::ProcessLoop(Loop *L) {
|
||||||
for (unsigned i = 0, e = L->getExitBlocks().size(); i != e; ++i)
|
for (unsigned i = 0, e = L->getExitBlocks().size(); i != e; ++i)
|
||||||
if (!DS.dominates(Header, L->getExitBlocks()[i])) {
|
if (!DS.dominates(Header, L->getExitBlocks()[i])) {
|
||||||
RewriteLoopExitBlock(L, L->getExitBlocks()[i]);
|
RewriteLoopExitBlock(L, L->getExitBlocks()[i]);
|
||||||
|
assert(DS.dominates(Header, L->getExitBlocks()[i]) &&
|
||||||
|
"RewriteLoopExitBlock failed?");
|
||||||
NumInserted++;
|
NumInserted++;
|
||||||
Changed = true;
|
Changed = true;
|
||||||
}
|
}
|
||||||
|
@ -270,19 +272,22 @@ void Preheaders::RewriteLoopExitBlock(Loop *L, BasicBlock *Exit) {
|
||||||
DominatorSet &DS = getAnalysis<DominatorSet>();
|
DominatorSet &DS = getAnalysis<DominatorSet>();
|
||||||
assert(!DS.dominates(L->getHeader(), Exit) &&
|
assert(!DS.dominates(L->getHeader(), Exit) &&
|
||||||
"Loop already dominates exit block??");
|
"Loop already dominates exit block??");
|
||||||
|
assert(std::find(L->getExitBlocks().begin(), L->getExitBlocks().end(), Exit)
|
||||||
|
!= L->getExitBlocks().end() && "Not a current exit block!");
|
||||||
|
|
||||||
std::vector<BasicBlock*> LoopBlocks;
|
std::vector<BasicBlock*> LoopBlocks;
|
||||||
for (pred_iterator I = pred_begin(Exit), E = pred_end(Exit); I != E; ++I)
|
for (pred_iterator I = pred_begin(Exit), E = pred_end(Exit); I != E; ++I)
|
||||||
if (L->contains(*I))
|
if (L->contains(*I))
|
||||||
LoopBlocks.push_back(*I);
|
LoopBlocks.push_back(*I);
|
||||||
|
|
||||||
BasicBlock *NewBB =
|
assert(!LoopBlocks.empty() && "No edges coming in from outside the loop?");
|
||||||
SplitBlockPredecessors(Exit, ".loopexit", LoopBlocks);
|
BasicBlock *NewBB = SplitBlockPredecessors(Exit, ".loopexit", LoopBlocks);
|
||||||
|
|
||||||
// Update Loop Information - we know that the new block will be in the parent
|
// Update Loop Information - we know that the new block will be in the parent
|
||||||
// loop of L.
|
// loop of L.
|
||||||
if (Loop *Parent = L->getParentLoop())
|
if (Loop *Parent = L->getParentLoop())
|
||||||
Parent->addBasicBlockToLoop(NewBB, getAnalysis<LoopInfo>());
|
Parent->addBasicBlockToLoop(NewBB, getAnalysis<LoopInfo>());
|
||||||
|
L->changeExitBlock(Exit, NewBB); // Update exit block information
|
||||||
|
|
||||||
// Update dominator information... The blocks that dominate NewBB are the
|
// Update dominator information... The blocks that dominate NewBB are the
|
||||||
// intersection of the dominators of predecessors, plus the block itself.
|
// intersection of the dominators of predecessors, plus the block itself.
|
||||||
|
|
Loading…
Reference in New Issue