summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-03-18 00:31:45 +0000
committerChris Lattner <sabre@nondot.org>2009-03-18 00:31:45 +0000
commita15ce21135d0a78f5d0d9c49d2b6d6fbe38a43f4 (patch)
tree532c64a20731700382394c327eea2512b068cef0 /llvm/lib
parent4eaeb4ef222013f621d6e1c33d5fa1d12d5b1878 (diff)
downloadbcm5719-llvm-a15ce21135d0a78f5d0d9c49d2b6d6fbe38a43f4.tar.gz
bcm5719-llvm-a15ce21135d0a78f5d0d9c49d2b6d6fbe38a43f4.zip
Fix PR3807 by inserting 'insertelement' instructions in the normal dest of
an invoke instead of after the invoke (in its block), which is invalid. llvm-svn: 67139
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp15
1 files changed, 10 insertions, 5 deletions
diff --git a/llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp b/llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp
index dd5fce69fe1..9f2b2a733ee 100644
--- a/llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp
+++ b/llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp
@@ -798,9 +798,13 @@ bool DAE::RemoveDeadStuffFromFunction(Function *F) {
// Replace by null for now.
Call->replaceAllUsesWith(Constant::getNullValue(Call->getType()));
} else {
- assert(isa<StructType>(RetTy) && "Return type changed, but not into a"
- "void. The old return type must have"
- "been a struct!");
+ assert(isa<StructType>(RetTy) &&
+ "Return type changed, but not into a void. The old return type"
+ " must have been a struct!");
+ Instruction *InsertPt = Call;
+ if (InvokeInst *II = dyn_cast<InvokeInst>(Call))
+ InsertPt = II->getNormalDest()->begin();
+
// We used to return a struct. Instead of doing smart stuff with all the
// uses of this struct, we will just rebuild it using
// extract/insertvalue chaining and let instcombine clean that up.
@@ -813,12 +817,13 @@ bool DAE::RemoveDeadStuffFromFunction(Function *F) {
if (RetTypes.size() > 1)
// We are still returning a struct, so extract the value from our
// return value
- V = ExtractValueInst::Create(New, NewRetIdxs[i], "newret", Call);
+ V = ExtractValueInst::Create(New, NewRetIdxs[i], "newret",
+ InsertPt);
else
// We are now returning a single element, so just insert that
V = New;
// Insert the value at the old position
- RetVal = InsertValueInst::Create(RetVal, V, i, "oldret", Call);
+ RetVal = InsertValueInst::Create(RetVal, V, i, "oldret", InsertPt);
}
// Now, replace all uses of the old call instruction with the return
// struct we built
OpenPOWER on IntegriCloud