aboutsummaryrefslogtreecommitdiff
path: root/lib/Transforms/Utils/LoopSimplify.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2003-02-27 22:31:07 +0000
committerChris Lattner <sabre@nondot.org>2003-02-27 22:31:07 +0000
commit7e7ad49c23867a5de8e15adfd946fdfa4ba68902 (patch)
treecc809f5d5c9199fcd023acda611dd7487be50470 /lib/Transforms/Utils/LoopSimplify.cpp
parent8601a9bf54049389e0e0b6a907dc51069dcadc60 (diff)
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@5659 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Utils/LoopSimplify.cpp')
-rw-r--r--lib/Transforms/Utils/LoopSimplify.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/lib/Transforms/Utils/LoopSimplify.cpp b/lib/Transforms/Utils/LoopSimplify.cpp
index dc9df6aa39..e40f1457ae 100644
--- a/lib/Transforms/Utils/LoopSimplify.cpp
+++ b/lib/Transforms/Utils/LoopSimplify.cpp
@@ -95,6 +95,8 @@ bool Preheaders::ProcessLoop(Loop *L) {
for (unsigned i = 0, e = L->getExitBlocks().size(); i != e; ++i)
if (!DS.dominates(Header, L->getExitBlocks()[i])) {
RewriteLoopExitBlock(L, L->getExitBlocks()[i]);
+ assert(DS.dominates(Header, L->getExitBlocks()[i]) &&
+ "RewriteLoopExitBlock failed?");
NumInserted++;
Changed = true;
}
@@ -270,19 +272,22 @@ void Preheaders::RewriteLoopExitBlock(Loop *L, BasicBlock *Exit) {
DominatorSet &DS = getAnalysis<DominatorSet>();
assert(!DS.dominates(L->getHeader(), Exit) &&
"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;
for (pred_iterator I = pred_begin(Exit), E = pred_end(Exit); I != E; ++I)
if (L->contains(*I))
LoopBlocks.push_back(*I);
- BasicBlock *NewBB =
- SplitBlockPredecessors(Exit, ".loopexit", LoopBlocks);
-
+ assert(!LoopBlocks.empty() && "No edges coming in from outside the loop?");
+ BasicBlock *NewBB = SplitBlockPredecessors(Exit, ".loopexit", LoopBlocks);
+
// Update Loop Information - we know that the new block will be in the parent
// loop of L.
if (Loop *Parent = L->getParentLoop())
Parent->addBasicBlockToLoop(NewBB, getAnalysis<LoopInfo>());
+ L->changeExitBlock(Exit, NewBB); // Update exit block information
// Update dominator information... The blocks that dominate NewBB are the
// intersection of the dominators of predecessors, plus the block itself.