[llvm-commits] CVS: llvm/lib/Transforms/Scalar/LoopPreheaders.cpp

Chris Lattner lattner at cs.uiuc.edu
Thu Feb 27 16:32:01 PST 2003


Changes in directory llvm/lib/Transforms/Scalar:

LoopPreheaders.cpp updated: 1.6 -> 1.7

---
Log message:

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.


---
Diffs of the changes:

Index: llvm/lib/Transforms/Scalar/LoopPreheaders.cpp
diff -u llvm/lib/Transforms/Scalar/LoopPreheaders.cpp:1.6 llvm/lib/Transforms/Scalar/LoopPreheaders.cpp:1.7
--- llvm/lib/Transforms/Scalar/LoopPreheaders.cpp:1.6	Thu Feb 27 15:50:19 2003
+++ llvm/lib/Transforms/Scalar/LoopPreheaders.cpp	Thu Feb 27 16:31:07 2003
@@ -95,6 +95,8 @@
   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 @@
   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.





More information about the llvm-commits mailing list