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

Chris Lattner lattner at cs.uiuc.edu
Sun Apr 18 12:39:01 PDT 2004


Changes in directory llvm/lib/Transforms/Scalar:

LoopUnroll.cpp updated: 1.4 -> 1.5

---
Log message:

If the preheader of the loop was the entry block of the function, make sure
that the exit block of the loop becomes the new entry block of the function.

This was causing a verifier assertion on 252.eon.


---
Diffs of the changes:  (+7 -2)

Index: llvm/lib/Transforms/Scalar/LoopUnroll.cpp
diff -u llvm/lib/Transforms/Scalar/LoopUnroll.cpp:1.4 llvm/lib/Transforms/Scalar/LoopUnroll.cpp:1.5
--- llvm/lib/Transforms/Scalar/LoopUnroll.cpp:1.4	Sun Apr 18 12:32:39 2004
+++ llvm/lib/Transforms/Scalar/LoopUnroll.cpp	Sun Apr 18 12:38:42 2004
@@ -300,10 +300,15 @@
     ChangeExitBlocksFromTo(LI->begin(), LI->end(),
                            Preheader, LoopExit);
 
+  // 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.
-  LoopExit->getParent()->getBasicBlockList().erase(Preheader);
-  LoopExit->getParent()->getBasicBlockList().erase(BB);
+  F->getBasicBlockList().erase(Preheader);
+  F->getBasicBlockList().erase(BB);
 
   ++NumUnrolled;
   return true;





More information about the llvm-commits mailing list