diff options
author | Chris Lattner <sabre@nondot.org> | 2002-06-25 16:12:52 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2002-06-25 16:12:52 +0000 |
commit | 18961504fc2b299578dba817900a0696cf3ccc4d (patch) | |
tree | c34853ffc064b841932d0897e25305c81c3a7338 /lib/Transforms/Utils/CloneFunction.cpp | |
parent | a2204e1ff25265a1da00ecbb3ebb22c05acf7194 (diff) |
*** empty log message ***
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@2777 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Utils/CloneFunction.cpp')
-rw-r--r-- | lib/Transforms/Utils/CloneFunction.cpp | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/lib/Transforms/Utils/CloneFunction.cpp b/lib/Transforms/Utils/CloneFunction.cpp index 6b1b24ac57..6bf7553e75 100644 --- a/lib/Transforms/Utils/CloneFunction.cpp +++ b/lib/Transforms/Utils/CloneFunction.cpp @@ -36,10 +36,9 @@ static inline void RemapInstruction(Instruction *I, // void CloneFunctionInto(Function *NewFunc, const Function *OldFunc, const std::vector<Value*> &ArgMap) { - assert(OldFunc->getArgumentList().empty() || - !NewFunc->getArgumentList().empty() && + assert(OldFunc->aempty() || !NewFunc->aempty() && "Synthesization of arguments is not implemented yet!"); - assert(OldFunc->getArgumentList().size() == ArgMap.size() && + assert(OldFunc->asize() == ArgMap.size() && "Improper number of argument values to map specified!"); // Keep a mapping between the original function's values and the new @@ -49,8 +48,10 @@ void CloneFunctionInto(Function *NewFunc, const Function *OldFunc, std::map<const Value *, Value*> ValueMap; // Add all of the function arguments to the mapping... - for (unsigned i = 0, e = ArgMap.size(); i != e; ++i) - ValueMap[(Value*)OldFunc->getArgumentList()[i]] = ArgMap[i]; + unsigned i = 0; + for (Function::const_aiterator I = OldFunc->abegin(), E = OldFunc->aend(); + I != E; ++I, ++i) + ValueMap[I] = ArgMap[i]; // Loop over all of the basic blocks in the function, cloning them as @@ -58,33 +59,32 @@ void CloneFunctionInto(Function *NewFunc, const Function *OldFunc, // for (Function::const_iterator BI = OldFunc->begin(), BE = OldFunc->end(); BI != BE; ++BI) { - const BasicBlock *BB = *BI; - assert(BB->getTerminator() && "BasicBlock doesn't have terminator!?!?"); + const BasicBlock &BB = *BI; + assert(BB.getTerminator() && "BasicBlock doesn't have terminator!?!?"); // Create a new basic block to copy instructions into! - BasicBlock *CBB = new BasicBlock(BB->getName(), NewFunc); - ValueMap[BB] = CBB; // Add basic block mapping. + BasicBlock *CBB = new BasicBlock(BB.getName(), NewFunc); + ValueMap[&BB] = CBB; // Add basic block mapping. // Loop over all instructions copying them over... - for (BasicBlock::const_iterator II = BB->begin(), IE = BB->end(); + for (BasicBlock::const_iterator II = BB.begin(), IE = BB.end(); II != IE; ++II) { - Instruction *NewInst = (*II)->clone(); - NewInst->setName((*II)->getName()); // Name is not cloned... + Instruction *NewInst = II->clone(); + NewInst->setName(II->getName()); // Name is not cloned... CBB->getInstList().push_back(NewInst); - ValueMap[*II] = NewInst; // Add instruction map to value. + ValueMap[II] = NewInst; // Add instruction map to value. } } // Loop over all of the instructions in the function, fixing up operand // references as we go. This uses ValueMap to do all the hard work. // - for (Function::const_iterator BI = OldFunc->begin(), BE = OldFunc->end(); - BI != BE; ++BI) { - const BasicBlock *BB = *BI; + for (Function::const_iterator BB = OldFunc->begin(), BE = OldFunc->end(); + BB != BE; ++BB) { BasicBlock *NBB = cast<BasicBlock>(ValueMap[BB]); // Loop over all instructions, fixing each one as we find it... - for (BasicBlock::iterator II = NBB->begin(); II != NBB->end(); II++) - RemapInstruction(*II, ValueMap); + for (BasicBlock::iterator II = NBB->begin(); II != NBB->end(); ++II) + RemapInstruction(II, ValueMap); } } |