summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2004-05-12 16:07:41 +0000
committerChris Lattner <sabre@nondot.org>2004-05-12 16:07:41 +0000
commitd99e1d3afbe664694ee04a5db5e4a7a8104858a1 (patch)
tree6ccb12c35fdcb3c9affc69a4f57c557274542ed3 /lib
parente746ad512efc447f352f9580a82c808c2d32ab26 (diff)
downloadexternal_llvm-d99e1d3afbe664694ee04a5db5e4a7a8104858a1.zip
external_llvm-d99e1d3afbe664694ee04a5db5e4a7a8104858a1.tar.gz
external_llvm-d99e1d3afbe664694ee04a5db5e4a7a8104858a1.tar.bz2
Implement support for code extracting basic blocks that have a return
instruction in them. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13490 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/Transforms/Utils/CodeExtractor.cpp14
1 files changed, 12 insertions, 2 deletions
diff --git a/lib/Transforms/Utils/CodeExtractor.cpp b/lib/Transforms/Utils/CodeExtractor.cpp
index d4c9faf..e325921 100644
--- a/lib/Transforms/Utils/CodeExtractor.cpp
+++ b/lib/Transforms/Utils/CodeExtractor.cpp
@@ -77,6 +77,7 @@ namespace {
}
void severSplitPHINodes(BasicBlock *&Header);
+ void splitReturnBlocks();
void findInputsOutputs(Values &inputs, Values &outputs);
Function *constructFunction(const Values &inputs,
@@ -184,8 +185,13 @@ void CodeExtractor::severSplitPHINodes(BasicBlock *&Header) {
}
}
}
+}
- verifyFunction(*NewBB->getParent());
+void CodeExtractor::splitReturnBlocks() {
+ for (std::set<BasicBlock*>::iterator I = BlocksToExtract.begin(),
+ E = BlocksToExtract.end(); I != E; ++I)
+ if (ReturnInst *RI = dyn_cast<ReturnInst>((*I)->getTerminator()))
+ (*I)->splitBasicBlock(RI, (*I)->getName()+".ret");
}
// findInputsOutputs - Find inputs to, outputs from the code region.
@@ -596,9 +602,13 @@ Function *CodeExtractor::ExtractCodeRegion(const std::vector<BasicBlock*> &code)
"No blocks in this region may have entries from outside the region"
" except for the first block!");
- // If we have to split PHI nodes, do so now.
+ // If we have to split PHI nodes or the entry block, do so now.
severSplitPHINodes(header);
+ // If we have any return instructions in the region, split those blocks so
+ // that the return is not in the region.
+ splitReturnBlocks();
+
Function *oldFunction = header->getParent();
// This takes place of the original loop