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
This commit is contained in:
Nick Lewycky
2008-03-09 05:24:34 +00:00
parent 6af31aab63
commit 529de8a457
7 changed files with 45 additions and 16 deletions

View File

@ -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