summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Utils
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2004-03-14 04:01:47 +0000
committerChris Lattner <sabre@nondot.org>2004-03-14 04:01:47 +0000
commit4fca71eb44725be4428567be6b5a46659e6d8685 (patch)
treec5bd80f1d8177349838d172814afebb15acdef66 /llvm/lib/Transforms/Utils
parent6c3e8c78cfb3206f28efe19bd2c5488102f5497d (diff)
downloadbcm5719-llvm-4fca71eb44725be4428567be6b5a46659e6d8685.tar.gz
bcm5719-llvm-4fca71eb44725be4428567be6b5a46659e6d8685.zip
Minor random cleanups
llvm-svn: 12382
Diffstat (limited to 'llvm/lib/Transforms/Utils')
-rw-r--r--llvm/lib/Transforms/Utils/CodeExtractor.cpp16
1 files changed, 7 insertions, 9 deletions
diff --git a/llvm/lib/Transforms/Utils/CodeExtractor.cpp b/llvm/lib/Transforms/Utils/CodeExtractor.cpp
index cbe9858aa44..1ad610d80af 100644
--- a/llvm/lib/Transforms/Utils/CodeExtractor.cpp
+++ b/llvm/lib/Transforms/Utils/CodeExtractor.cpp
@@ -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);
}
OpenPOWER on IntegriCloud