Minor random cleanups
authorChris Lattner <sabre@nondot.org>
Sun, 14 Mar 2004 04:01:47 +0000 (04:01 +0000)
committerChris Lattner <sabre@nondot.org>
Sun, 14 Mar 2004 04:01:47 +0000 (04:01 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12382 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Utils/CodeExtractor.cpp

index cbe9858aa448e61e1f0ac7dca73d56236808469a..1ad610d80af16d8e7e3c14915905894045f68dbd 100644 (file)
@@ -353,17 +353,18 @@ Function *CodeExtractor::constructFunction(const Values &inputs,
 void CodeExtractor::moveCodeToFunction(const std::vector<BasicBlock*> &code,
                                        Function *newFunction)
 {
+  Function *oldFunc = code[0]->getParent();
+  Function::BasicBlockListType &oldBlocks = oldFunc->getBasicBlockList();
+    Function::BasicBlockListType &newBlocks = newFunction->getBasicBlockList();
+
   for (std::vector<BasicBlock*>::const_iterator i = code.begin(), e =code.end();
        i != e; ++i) {
     BasicBlock *BB = *i;
-    Function *oldFunc = BB->getParent();
-    Function::BasicBlockListType &oldBlocks = oldFunc->getBasicBlockList();
 
     // Delete the basic block from the old function, and the list of blocks
     oldBlocks.remove(BB);
 
     // Insert this basic block into the new function
-    Function::BasicBlockListType &newBlocks = newFunction->getBasicBlockList();
     newBlocks.push_back(BB);
   }
 }
@@ -569,22 +570,19 @@ Function *CodeExtractor::ExtractCodeRegion(const std::vector<BasicBlock*> &code)
 /// function
 ///
 Function* llvm::ExtractCodeRegion(const std::vector<BasicBlock*> &code) {
-  CodeExtractor CE;
-  return CE.ExtractCodeRegion(code);
+  return CodeExtractor().ExtractCodeRegion(code);
 }
 
 /// ExtractBasicBlock - slurp a natural loop into a brand new function
 ///
 Function* llvm::ExtractLoop(Loop *L) {
-  CodeExtractor CE;
-  return CE.ExtractCodeRegion(L->getBlocks());
+  return CodeExtractor().ExtractCodeRegion(L->getBlocks());
 }
 
 /// ExtractBasicBlock - slurp a basic block into a brand new function
 ///
 Function* llvm::ExtractBasicBlock(BasicBlock *BB) {
-  CodeExtractor CE;
   std::vector<BasicBlock*> Blocks;
   Blocks.push_back(BB);
-  return CE.ExtractCodeRegion(Blocks);  
+  return CodeExtractor().ExtractCodeRegion(Blocks);  
 }