summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
diff options
context:
space:
mode:
authorDavid Majnemer <david.majnemer@gmail.com>2015-09-23 15:41:09 +0000
committerDavid Majnemer <david.majnemer@gmail.com>2015-09-23 15:41:09 +0000
commitfa36bde2f66825e27aac7d753efc11e7549a9f84 (patch)
treea169cf6809cfb949978ba93e37166a0626f8c58d /llvm/lib/Transforms
parent2a6c13274c5cc36654073f3865f7bdf5bf10250d (diff)
downloadbcm5719-llvm-fa36bde2f66825e27aac7d753efc11e7549a9f84.tar.gz
bcm5719-llvm-fa36bde2f66825e27aac7d753efc11e7549a9f84.zip
[DeadArgElim] Split the invoke successor edge
Invoking a function which returns an aggregate can sometimes be transformed to return a scalar value. However, this means that we need to create an insertvalue instruction(s) to recreate the correct aggregate type. We achieved this by inserting an insertvalue instruction at the invoke's normal successor. However, this is not feasible if the normal successor uses the invoke's return value inside a PHI node. Instead, split the edge between the invoke and the unwind successor and create the insertvalue instruction in the new basic block. The new basic block's successor will be the old invoke successor which leaves us with IR which is well behaved. This fixes PR24906. llvm-svn: 248387
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r--llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp b/llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp
index 64c5ab9cb1b..024fb2c1015 100644
--- a/llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp
+++ b/llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp
@@ -35,6 +35,7 @@
#include "llvm/Pass.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/raw_ostream.h"
+#include "llvm/Transforms/Utils/BasicBlockUtils.h"
#include <map>
#include <set>
#include <tuple>
@@ -967,7 +968,7 @@ bool DAE::RemoveDeadStuffFromFunction(Function *F) {
Instruction *New;
if (InvokeInst *II = dyn_cast<InvokeInst>(Call)) {
New = InvokeInst::Create(NF, II->getNormalDest(), II->getUnwindDest(),
- Args, "", Call);
+ Args, "", Call->getParent());
cast<InvokeInst>(New)->setCallingConv(CS.getCallingConv());
cast<InvokeInst>(New)->setAttributes(NewCallPAL);
} else {
@@ -997,9 +998,8 @@ bool DAE::RemoveDeadStuffFromFunction(Function *F) {
" must have been a struct or an array!");
Instruction *InsertPt = Call;
if (InvokeInst *II = dyn_cast<InvokeInst>(Call)) {
- BasicBlock::iterator IP = II->getNormalDest()->begin();
- while (isa<PHINode>(IP)) ++IP;
- InsertPt = IP;
+ BasicBlock *NewEdge = SplitEdge(New->getParent(), II->getNormalDest());
+ InsertPt = NewEdge->getFirstInsertionPt();
}
// We used to return a struct or array. Instead of doing smart stuff
OpenPOWER on IntegriCloud