summaryrefslogtreecommitdiff
path: root/lib/Transforms/Utils/CodeExtractor.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2004-11-12 23:50:44 +0000
committerChris Lattner <sabre@nondot.org>2004-11-12 23:50:44 +0000
commit68c311aac64ca3bc50f48f4f1b4fd4c21fe0c4df (patch)
tree31d8dcf834c577bc3bf0b824f3ac1a52895d45e3 /lib/Transforms/Utils/CodeExtractor.cpp
parent44c94b96710a653e467dbf8d34ce9540ff66a1a0 (diff)
downloadllvm-68c311aac64ca3bc50f48f4f1b4fd4c21fe0c4df.tar.gz
llvm-68c311aac64ca3bc50f48f4f1b4fd4c21fe0c4df.tar.bz2
llvm-68c311aac64ca3bc50f48f4f1b4fd4c21fe0c4df.tar.xz
Fix a bug where the code extractor would get a bit confused handling invoke
instructions, setting DefBlock to a block it did not have dom info for. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@17697 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Utils/CodeExtractor.cpp')
-rw-r--r--lib/Transforms/Utils/CodeExtractor.cpp14
1 files changed, 13 insertions, 1 deletions
diff --git a/lib/Transforms/Utils/CodeExtractor.cpp b/lib/Transforms/Utils/CodeExtractor.cpp
index 2b7eb0093f..ebdc054202 100644
--- a/lib/Transforms/Utils/CodeExtractor.cpp
+++ b/lib/Transforms/Utils/CodeExtractor.cpp
@@ -488,8 +488,20 @@ emitCallAndSwitchStatement(Function *newFunction, BasicBlock *codeReplacer,
// For an invoke, the normal destination is the only one that is
// dominated by the result of the invocation
BasicBlock *DefBlock = cast<Instruction>(outputs[out])->getParent();
- if (InvokeInst *Invoke = dyn_cast<InvokeInst>(outputs[out]))
+ if (InvokeInst *Invoke = dyn_cast<InvokeInst>(outputs[out])) {
DefBlock = Invoke->getNormalDest();
+
+ // Make sure we are looking at the original successor block, not
+ // at a newly inserted exit block, which won't be in the dominator
+ // info.
+ for (std::map<BasicBlock*, BasicBlock*>::iterator I =
+ ExitBlockMap.begin(), E = ExitBlockMap.end(); I != E; ++I)
+ if (DefBlock == I->second) {
+ DefBlock = I->first;
+ break;
+ }
+ }
+
if (!DS || DS->dominates(DefBlock, TI->getParent()))
if (AggregateArgs) {
std::vector<Value*> Indices;