summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorFlorian Hahn <florian.hahn@arm.com>2018-08-21 20:07:46 +0000
committerFlorian Hahn <florian.hahn@arm.com>2018-08-21 20:07:46 +0000
commit7cdf52e4257456a0f5010489bc5907ef8ac16ac5 (patch)
tree7ad08ef0e14e75c51c9dfbf1e60e2a22696d9fe2 /llvm/lib
parent9cd7f88a35cbcaa51ca2c6eb02be31cca2a6d8cc (diff)
downloadbcm5719-llvm-7cdf52e4257456a0f5010489bc5907ef8ac16ac5.tar.gz
bcm5719-llvm-7cdf52e4257456a0f5010489bc5907ef8ac16ac5.zip
[CodeExtractor] Use 'normal destination' BB as insert point to store invoke results.
Currently CodeExtractor tries to use the next node after an invoke to place the store for the result of the invoke, if it is an out parameter of the region. This fails, as the invoke terminates the current BB. In that case, we can place the store in the 'normal destination' BB, as the result will only be available in that case. Reviewers: davidxl, davide, efriedma Reviewed By: davidxl Differential Revision: https://reviews.llvm.org/D51037 llvm-svn: 340331
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