Minor speedup, don't query ValueMap each time through the loop
authorChris Lattner <sabre@nondot.org>
Wed, 4 Feb 2004 21:44:26 +0000 (21:44 +0000)
committerChris Lattner <sabre@nondot.org>
Wed, 4 Feb 2004 21:44:26 +0000 (21:44 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11123 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Utils/CloneFunction.cpp

index 4aa1aaa0d28377a59f51a090079ece105c4f8dae..f5ea66047a1f31da6be1531d6f0e30a9dd087bec 100644 (file)
@@ -92,14 +92,11 @@ void llvm::CloneFunctionInto(Function *NewFunc, const Function *OldFunc,
   // 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 BB = OldFunc->begin(), BE = OldFunc->end();
-       BB != BE; ++BB) {
-    BasicBlock *NBB = cast<BasicBlock>(ValueMap[BB]);
-    
+  for (Function::iterator BB = cast<BasicBlock>(ValueMap[OldFunc->begin()]),
+         BE = NewFunc->end(); BB != BE; ++BB)
     // Loop over all instructions, fixing each one as we find it...
-    for (BasicBlock::iterator II = NBB->begin(); II != NBB->end(); ++II)
+    for (BasicBlock::iterator II = BB->begin(); II != BB->end(); ++II)
       RemapInstruction(II, ValueMap);
-  }
 }
 
 /// CloneFunction - Return a copy of the specified function, but without