diff options
author | Bill Wendling <isanbard@gmail.com> | 2011-09-19 23:00:52 +0000 |
---|---|---|
committer | Bill Wendling <isanbard@gmail.com> | 2011-09-19 23:00:52 +0000 |
commit | d3c9d971e6db1059f873f4d2a56dba835f3024b8 (patch) | |
tree | 8c90548e414700080848996f06e61a41acc74ca3 /llvm/lib/Transforms/Utils/CodeExtractor.cpp | |
parent | f5028fd1416980817d03024dcb5e1fd5df69906f (diff) | |
download | bcm5719-llvm-d3c9d971e6db1059f873f4d2a56dba835f3024b8.tar.gz bcm5719-llvm-d3c9d971e6db1059f873f4d2a56dba835f3024b8.zip |
If we are extracting a basic block that ends in an invoke call, we must also
extract the landing pad block. Otherwise, there will be a situation where the
invoke's unwind edge lands on a non-landing pad.
We also forbid the user from extracting the landing pad block by itself. Again,
this is not a valid transformation.
llvm-svn: 140083
Diffstat (limited to 'llvm/lib/Transforms/Utils/CodeExtractor.cpp')
-rw-r--r-- | llvm/lib/Transforms/Utils/CodeExtractor.cpp | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/Utils/CodeExtractor.cpp b/llvm/lib/Transforms/Utils/CodeExtractor.cpp index 126056b844c..8b9768520e0 100644 --- a/llvm/lib/Transforms/Utils/CodeExtractor.cpp +++ b/llvm/lib/Transforms/Utils/CodeExtractor.cpp @@ -664,7 +664,13 @@ ExtractCodeRegion(const std::vector<BasicBlock*> &code) { // * Pass in uses as args // 3) Move code region, add call instr to func // - BlocksToExtract.insert(code.begin(), code.end()); + for (std::vector<BasicBlock*>::const_iterator + I = code.begin(), E = code.end(); I != E; ++I) { + BasicBlock *BB = *I; + BlocksToExtract.insert(BB); + if (InvokeInst *II = dyn_cast<InvokeInst>(BB->getTerminator())) + BlocksToExtract.insert(II->getUnwindDest()); + } Values inputs, outputs; @@ -788,6 +794,7 @@ Function* llvm::ExtractLoop(DominatorTree &DT, Loop *L, bool AggregateArgs) { /// ExtractBasicBlock - slurp a basic block into a brand new function /// Function* llvm::ExtractBasicBlock(BasicBlock *BB, bool AggregateArgs) { + if (BB->isLandingPad()) return 0; std::vector<BasicBlock*> Blocks; Blocks.push_back(BB); return CodeExtractor(0, AggregateArgs).ExtractCodeRegion(Blocks); |