diff options
author | Chris Lattner <sabre@nondot.org> | 2004-04-18 17:38:42 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2004-04-18 17:38:42 +0000 |
commit | cc43909bb6bfe99494d82001ec7503407996e43a (patch) | |
tree | 8b900aaf508a77e78c795a4f3b0a86711695cbd3 /lib/Transforms/Scalar/LoopUnroll.cpp | |
parent | 998f44f859ee37a9dd6a124a24653af3c99fe291 (diff) |
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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13039 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Scalar/LoopUnroll.cpp')
-rw-r--r-- | lib/Transforms/Scalar/LoopUnroll.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/Transforms/Scalar/LoopUnroll.cpp b/lib/Transforms/Scalar/LoopUnroll.cpp index 266afbbe9b..90de9e946d 100644 --- a/lib/Transforms/Scalar/LoopUnroll.cpp +++ b/lib/Transforms/Scalar/LoopUnroll.cpp @@ -300,10 +300,15 @@ bool LoopUnroll::visitLoop(Loop *L) { 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; |