summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Transforms/Utils/CodeExtractor.cpp10
1 files changed, 9 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/Utils/CodeExtractor.cpp b/llvm/lib/Transforms/Utils/CodeExtractor.cpp
index cb349e34606..eeb5d2bf5eb 100644
--- a/llvm/lib/Transforms/Utils/CodeExtractor.cpp
+++ b/llvm/lib/Transforms/Utils/CodeExtractor.cpp
@@ -925,8 +925,16 @@ emitCallAndSwitchStatement(Function *newFunction, BasicBlock *codeReplacer,
auto *OutI = dyn_cast<Instruction>(outputs[i]);
if (!OutI)
continue;
+
// Find proper insertion point.
- Instruction *InsertPt = OutI->getNextNode();
+ Instruction *InsertPt;
+ // In case OutI is an invoke, we insert the store at the beginning in the
+ // 'normal destination' BB. Otherwise we insert the store right after OutI.
+ if (auto *InvokeI = dyn_cast<InvokeInst>(OutI))
+ InsertPt = InvokeI->getNormalDest()->getFirstNonPHI();
+ else
+ InsertPt = OutI->getNextNode();
+
// Let's assume that there is no other guy interleave non-PHI in PHIs.
if (isa<PHINode>(InsertPt))
InsertPt = InsertPt->getParent()->getFirstNonPHI();
OpenPOWER on IntegriCloud