summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Utils/CloneFunction.cpp
diff options
context:
space:
mode:
authorNick Lewycky <nicholas@mxc.ca>2008-03-09 05:24:34 +0000
committerNick Lewycky <nicholas@mxc.ca>2008-03-09 05:24:34 +0000
commit11fc6f87651936281e22d58530a9425cc77341d4 (patch)
treeaab56c07a21cd9909d6f20f8fec4c5b0c4ded4de /llvm/lib/Transforms/Utils/CloneFunction.cpp
parentebe5c8520c1330896f8cb018830986a25f1bdf1a (diff)
downloadbcm5719-llvm-11fc6f87651936281e22d58530a9425cc77341d4.tar.gz
bcm5719-llvm-11fc6f87651936281e22d58530a9425cc77341d4.zip
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. llvm-svn: 48088
Diffstat (limited to 'llvm/lib/Transforms/Utils/CloneFunction.cpp')
-rw-r--r--llvm/lib/Transforms/Utils/CloneFunction.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/Utils/CloneFunction.cpp b/llvm/lib/Transforms/Utils/CloneFunction.cpp
index 513de4e893e..5d0d1d8c678 100644
--- a/llvm/lib/Transforms/Utils/CloneFunction.cpp
+++ b/llvm/lib/Transforms/Utils/CloneFunction.cpp
@@ -33,6 +33,7 @@ BasicBlock *llvm::CloneBasicBlock(const BasicBlock *BB,
ClonedCodeInfo *CodeInfo) {
BasicBlock *NewBB = new BasicBlock("", F);
if (BB->hasName()) NewBB->setName(BB->getName()+NameSuffix);
+ NewBB->setUnwindDest(const_cast<BasicBlock*>(BB->getUnwindDest()));
bool hasCalls = false, hasDynamicAllocas = false, hasStaticAllocas = false;
@@ -103,10 +104,15 @@ void llvm::CloneFunctionInto(Function *NewFunc, const Function *OldFunc,
// references as we go. This uses ValueMap to do all the hard work.
//
for (Function::iterator BB = cast<BasicBlock>(ValueMap[OldFunc->begin()]),
- BE = NewFunc->end(); BB != BE; ++BB)
+ BE = NewFunc->end(); BB != BE; ++BB) {
+ // Fix up the unwind_to label.
+ if (BasicBlock *UnwindDest = BB->getUnwindDest())
+ BB->setUnwindDest(cast<BasicBlock>(ValueMap[UnwindDest]));
+
// Loop over all instructions, fixing each one as we find it...
for (BasicBlock::iterator II = BB->begin(); II != BB->end(); ++II)
RemapInstruction(II, ValueMap);
+ }
}
/// CloneFunction - Return a copy of the specified function, but without
OpenPOWER on IntegriCloud