diff options
author | Chris Lattner <sabre@nondot.org> | 2006-02-18 00:55:32 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2006-02-18 00:55:32 +0000 |
commit | 25cae0fd1ca1be2dc4b10864e0f7c8fc86ecd51d (patch) | |
tree | 6d76ae2fe6dc2a28ce099ad9495313248943769b | |
parent | 299520de7c5358a30dd7786cf9fe9f9a6ce37d94 (diff) | |
download | external_llvm-25cae0fd1ca1be2dc4b10864e0f7c8fc86ecd51d.zip external_llvm-25cae0fd1ca1be2dc4b10864e0f7c8fc86ecd51d.tar.gz external_llvm-25cae0fd1ca1be2dc4b10864e0f7c8fc86ecd51d.tar.bz2 |
When unswitching a loop, make sure to update loop info with exit blocks in
the right loop.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26277 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Transforms/Scalar/LoopUnswitch.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/Transforms/Scalar/LoopUnswitch.cpp b/lib/Transforms/Scalar/LoopUnswitch.cpp index 6d29090..6add98d 100644 --- a/lib/Transforms/Scalar/LoopUnswitch.cpp +++ b/lib/Transforms/Scalar/LoopUnswitch.cpp @@ -590,6 +590,7 @@ void LoopUnswitch::VersionLoop(Value *LIC, Constant *Val, Loop *L, // Split all of the edges from inside the loop to their exit blocks. This // unswitching trivial: no phi nodes to update. unsigned NumBlocks = L->getBlocks().size(); + for (unsigned i = 0, e = ExitBlocks.size(); i != e; ++i) { BasicBlock *ExitBlock = ExitBlocks[i]; std::vector<BasicBlock*> Preds(pred_begin(ExitBlock), pred_end(ExitBlock)); @@ -639,8 +640,9 @@ void LoopUnswitch::VersionLoop(Value *LIC, Constant *Val, Loop *L, for (unsigned i = 0, e = ExitBlocks.size(); i != e; ++i) { BasicBlock *NewExit = cast<BasicBlock>(ValueMap[ExitBlocks[i]]); - if (ParentLoop) - ParentLoop->addBasicBlockToLoop(cast<BasicBlock>(NewExit), *LI); + // The new exit block should be in the same loop as the old one. + if (Loop *ExitBBLoop = LI->getLoopFor(ExitBlocks[i])) + ExitBBLoop->addBasicBlockToLoop(NewExit, *LI); assert(NewExit->getTerminator()->getNumSuccessors() == 1 && "Exit block should have been split to have one successor!"); |