diff options
author | Chris Lattner <sabre@nondot.org> | 2004-11-13 00:06:45 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2004-11-13 00:06:45 +0000 |
commit | 9ecc0461841ad2fb44996a965f30ab3931efbf70 (patch) | |
tree | 8c2e974163ed39bea9dc815d39e35f9364f00157 /lib/Transforms/Utils/CodeExtractor.cpp | |
parent | 8de2da41057550ba4f5de1f932bc7755d5288365 (diff) |
Fix: CodeExtractor/2004-11-12-InvokeExtract.ll
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@17699 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Utils/CodeExtractor.cpp')
-rw-r--r-- | lib/Transforms/Utils/CodeExtractor.cpp | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/lib/Transforms/Utils/CodeExtractor.cpp b/lib/Transforms/Utils/CodeExtractor.cpp index ebdc054202..b8b098029d 100644 --- a/lib/Transforms/Utils/CodeExtractor.cpp +++ b/lib/Transforms/Utils/CodeExtractor.cpp @@ -488,6 +488,9 @@ 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(); + + bool DominatesDef = true; + if (InvokeInst *Invoke = dyn_cast<InvokeInst>(outputs[out])) { DefBlock = Invoke->getNormalDest(); @@ -500,9 +503,18 @@ emitCallAndSwitchStatement(Function *newFunction, BasicBlock *codeReplacer, DefBlock = I->first; break; } + + // In the extract block case, if the block we are extracting ends + // with an invoke instruction, make sure that we don't emit a + // store of the invoke value for the unwind block. + if (!DS && DefBlock != OldTarget) + DominatesDef = false; } - if (!DS || DS->dominates(DefBlock, TI->getParent())) + if (DS) + DominatesDef = DS->dominates(DefBlock, OldTarget); + + if (DominatesDef) { if (AggregateArgs) { std::vector<Value*> Indices; Indices.push_back(Constant::getNullValue(Type::UIntTy)); @@ -512,8 +524,10 @@ emitCallAndSwitchStatement(Function *newFunction, BasicBlock *codeReplacer, "gep_" + outputs[out]->getName(), NTRet); new StoreInst(outputs[out], GEP, NTRet); - } else + } else { new StoreInst(outputs[out], OAI, NTRet); + } + } // Advance output iterator even if we don't emit a store if (!AggregateArgs) ++OAI; } |