summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp8
-rw-r--r--llvm/test/Transforms/DeadArgElim/aggregates.ll26
2 files changed, 29 insertions, 5 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
diff --git a/llvm/test/Transforms/DeadArgElim/aggregates.ll b/llvm/test/Transforms/DeadArgElim/aggregates.ll
index 68d25342558..2eca76a4a4e 100644
--- a/llvm/test/Transforms/DeadArgElim/aggregates.ll
+++ b/llvm/test/Transforms/DeadArgElim/aggregates.ll
@@ -159,4 +159,28 @@ define internal i8 @outer() {
%val = load i8, i8* %resptr
ret i8 %val
-} \ No newline at end of file
+}
+
+define internal { i32 } @agg_ret() {
+entry:
+ unreachable
+}
+
+; CHECK-LABEL: define void @PR24906
+; CHECK: %[[invoke:.*]] = invoke i32 @agg_ret()
+; CHECK: %[[oldret:.*]] = insertvalue { i32 } undef, i32 %[[invoke]], 0
+; CHECK: phi { i32 } [ %[[oldret]],
+define void @PR24906() personality i32 (i32)* undef {
+entry:
+ %tmp2 = invoke { i32 } @agg_ret()
+ to label %bb3 unwind label %bb4
+
+bb3:
+ %tmp3 = phi { i32 } [ %tmp2, %entry ]
+ unreachable
+
+bb4:
+ %tmp4 = landingpad { i8*, i32 }
+ cleanup
+ unreachable
+}
OpenPOWER on IntegriCloud