[llvm-commits] CVS: llvm/lib/Transforms/Scalar/LoopPreheaders.cpp
Chris Lattner
lattner at cs.uiuc.edu
Thu Feb 27 16:50:01 PST 2003
Changes in directory llvm/lib/Transforms/Scalar:
LoopPreheaders.cpp updated: 1.7 -> 1.8
---
Log message:
Fix bug: 2003-02-27-PreheaderExitNodeUpdate.ll by updating exit node info
---
Diffs of the changes:
Index: llvm/lib/Transforms/Scalar/LoopPreheaders.cpp
diff -u llvm/lib/Transforms/Scalar/LoopPreheaders.cpp:1.7 llvm/lib/Transforms/Scalar/LoopPreheaders.cpp:1.8
--- llvm/lib/Transforms/Scalar/LoopPreheaders.cpp:1.7 Thu Feb 27 16:31:07 2003
+++ llvm/lib/Transforms/Scalar/LoopPreheaders.cpp Thu Feb 27 16:48:57 2003
@@ -192,6 +192,22 @@
// We know that we have loop information to update... update it now.
if (Loop *Parent = L->getParentLoop())
Parent->addBasicBlockToLoop(NewBB, getAnalysis<LoopInfo>());
+
+ // If the header for the loop used to be an exit node for another loop, then
+ // we need to update this to know that the loop-preheader is now the exit
+ // node. Note that the only loop that could have our header as an exit node
+ // is a sibling loop, ie, one with the same parent loop.
+ const std::vector<Loop*> *ParentSubLoops;
+ if (Loop *Parent = L->getParentLoop())
+ ParentSubLoops = &Parent->getSubLoops();
+ else // Must check top-level loops...
+ ParentSubLoops = &getAnalysis<LoopInfo>().getTopLevelLoops();
+
+ // Loop over all sibling loops, performing the substitution...
+ for (unsigned i = 0, e = ParentSubLoops->size(); i != e; ++i)
+ if ((*ParentSubLoops)[i]->hasExitBlock(Header))
+ (*ParentSubLoops)[i]->changeExitBlock(Header, NewBB);
+
DominatorSet &DS = getAnalysis<DominatorSet>(); // Update dominator info
{
More information about the llvm-commits
mailing list