[llvm-commits] CVS: llvm/lib/Transforms/Scalar/LoopUnroll.cpp
Chris Lattner
lattner at cs.uiuc.edu
Sun Mar 6 12:57:45 PST 2005
Changes in directory llvm/lib/Transforms/Scalar:
LoopUnroll.cpp updated: 1.15 -> 1.16
---
Log message:
Fix a bug where we could corrupt a parent loop's header info if we unrolled
a nested loop. This fixes Transforms/LoopUnroll/2005-03-06-BadLoopInfoUpdate.ll
and PR532: http://llvm.cs.uiuc.edu/PR532
---
Diffs of the changes: (+17 -6)
LoopUnroll.cpp | 23 +++++++++++++++++------
1 files changed, 17 insertions(+), 6 deletions(-)
Index: llvm/lib/Transforms/Scalar/LoopUnroll.cpp
diff -u llvm/lib/Transforms/Scalar/LoopUnroll.cpp:1.15 llvm/lib/Transforms/Scalar/LoopUnroll.cpp:1.16
--- llvm/lib/Transforms/Scalar/LoopUnroll.cpp:1.15 Sat Jan 8 13:37:20 2005
+++ llvm/lib/Transforms/Scalar/LoopUnroll.cpp Sun Mar 6 14:57:32 2005
@@ -283,16 +283,27 @@
// Preheader.
Preheader->replaceAllUsesWith(LoopExit);
+ Function *F = LoopExit->getParent();
+ if (Parent) {
+ // Otherwise, if this is a sub-loop, and the preheader was the loop header
+ // of the parent loop, move the exit block to be the new parent loop header.
+ if (Parent->getHeader() == Preheader) {
+ assert(Parent->contains(LoopExit) &&
+ "Exit block isn't contained in parent?");
+ Parent->moveToHeader(LoopExit);
+ }
+ } else {
+ // If the preheader was the entry block of this function, move the exit
+ // block to be the new entry of the function.
+ if (Preheader == &F->front())
+ F->getBasicBlockList().splice(F->begin(),
+ F->getBasicBlockList(), LoopExit);
+ }
+
// Remove BB and LoopExit from our analyses.
LI->removeBlock(Preheader);
LI->removeBlock(BB);
- // If the preheader was the entry block of this function, move the exit block
- // to be the new entry of the loop.
- Function *F = LoopExit->getParent();
- if (Preheader == &F->front())
- F->getBasicBlockList().splice(F->begin(), F->getBasicBlockList(), LoopExit);
-
// Actually delete the blocks now.
F->getBasicBlockList().erase(Preheader);
F->getBasicBlockList().erase(BB);
More information about the llvm-commits
mailing list