diff options
author | Nick Lewycky <nicholas@mxc.ca> | 2008-03-09 05:24:34 +0000 |
---|---|---|
committer | Nick Lewycky <nicholas@mxc.ca> | 2008-03-09 05:24:34 +0000 |
commit | 529de8a45702cd34968d79d13f95ed1e5d5fa250 (patch) | |
tree | 31fa91f8bc4b9823103028f53a42918b300e285f /lib/Transforms/Scalar | |
parent | 6af31aab63583e61b7c7b51bc285541750bd834f (diff) |
Update the block cloner which fixes bugpoint on code using unwind_to (phew!)
and also update the cloning interface's major user, the loop optimizations.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@48088 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Scalar')
-rw-r--r-- | lib/Transforms/Scalar/LoopUnroll.cpp | 10 | ||||
-rw-r--r-- | lib/Transforms/Scalar/LoopUnswitch.cpp | 10 |
2 files changed, 14 insertions, 6 deletions
diff --git a/lib/Transforms/Scalar/LoopUnroll.cpp b/lib/Transforms/Scalar/LoopUnroll.cpp index 2140b22f2f..ff8ece2aa8 100644 --- a/lib/Transforms/Scalar/LoopUnroll.cpp +++ b/lib/Transforms/Scalar/LoopUnroll.cpp @@ -396,10 +396,14 @@ bool LoopUnroll::unrollLoop(Loop *L, unsigned Count, unsigned Threshold) { } // Remap all instructions in the most recent iteration - for (unsigned i = 0; i < NewBlocks.size(); ++i) - for (BasicBlock::iterator I = NewBlocks[i]->begin(), - E = NewBlocks[i]->end(); I != E; ++I) + for (unsigned i = 0; i < NewBlocks.size(); ++i) { + BasicBlock *NB = NewBlocks[i]; + if (BasicBlock *UnwindDest = NB->getUnwindDest()) + NB->setUnwindDest(cast<BasicBlock>(LastValueMap[UnwindDest])); + + for (BasicBlock::iterator I = NB->begin(), E = NB->end(); I != E; ++I) RemapInstruction(I, LastValueMap); + } } // The latch block exits the loop. If there are any PHI nodes in the diff --git a/lib/Transforms/Scalar/LoopUnswitch.cpp b/lib/Transforms/Scalar/LoopUnswitch.cpp index 8d39a4dece..966038ddff 100644 --- a/lib/Transforms/Scalar/LoopUnswitch.cpp +++ b/lib/Transforms/Scalar/LoopUnswitch.cpp @@ -819,10 +819,14 @@ void LoopUnswitch::UnswitchNontrivialCondition(Value *LIC, Constant *Val, } // Rewrite the code to refer to itself. - for (unsigned i = 0, e = NewBlocks.size(); i != e; ++i) - for (BasicBlock::iterator I = NewBlocks[i]->begin(), - E = NewBlocks[i]->end(); I != E; ++I) + for (unsigned i = 0, e = NewBlocks.size(); i != e; ++i) { + BasicBlock *NB = NewBlocks[i]; + if (BasicBlock *UnwindDest = NB->getUnwindDest()) + NB->setUnwindDest(cast<BasicBlock>(ValueMap[UnwindDest])); + + for (BasicBlock::iterator I = NB->begin(), E = NB->end(); I != E; ++I) RemapInstruction(I, ValueMap); + } // Rewrite the original preheader to select between versions of the loop. BranchInst *OldBR = cast<BranchInst>(OrigPreheader->getTerminator()); |