summaryrefslogtreecommitdiff
path: root/lib/Transforms/IPO
diff options
context:
space:
mode:
authorMatthijs Kooijman <matthijs@stdin.nl>2008-06-20 15:25:43 +0000
committerMatthijs Kooijman <matthijs@stdin.nl>2008-06-20 15:25:43 +0000
commitdf0891d2ffb6d00c5bd5b929dae02c74535ea246 (patch)
tree63bcac3a528996cd8db77100a4fe2f05061ae9f5 /lib/Transforms/IPO
parent03d18569cb39b0e4bd50f5eff2d4fe61bb234678 (diff)
downloadllvm-df0891d2ffb6d00c5bd5b929dae02c74535ea246.tar.gz
llvm-df0891d2ffb6d00c5bd5b929dae02c74535ea246.tar.bz2
llvm-df0891d2ffb6d00c5bd5b929dae02c74535ea246.tar.xz
Don't let DeadArgumentElimination attempt to update callers when the return
type wasn't changed. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52538 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/IPO')
-rw-r--r--lib/Transforms/IPO/DeadArgumentElimination.cpp21
1 files changed, 12 insertions, 9 deletions
diff --git a/lib/Transforms/IPO/DeadArgumentElimination.cpp b/lib/Transforms/IPO/DeadArgumentElimination.cpp
index 3253c54a68..d7febc50c8 100644
--- a/lib/Transforms/IPO/DeadArgumentElimination.cpp
+++ b/lib/Transforms/IPO/DeadArgumentElimination.cpp
@@ -743,11 +743,18 @@ bool DAE::RemoveDeadStuffFromFunction(Function *F) {
Args.clear();
if (!Call->use_empty()) {
- if (New->getType() == Type::VoidTy)
- // Our return value was unused, replace by null for now, uses will get
- // removed later on
+ if (New->getType() == Call->getType()) {
+ // Return type not changed? Just replace users then
+ Call->replaceAllUsesWith(New);
+ New->takeName(Call);
+ } else if (New->getType() == Type::VoidTy) {
+ // Our return value has uses, but they will get removed later on.
+ // Replace by null for now.
Call->replaceAllUsesWith(Constant::getNullValue(Call->getType()));
- else if (isa<StructType>(RetTy)) {
+ } else {
+ assert(isa<StructType>(RetTy) && "Return type changed, but not into a"
+ "void. The old return type must have"
+ "been a struct!");
// The original return value was a struct, update all uses (which are
// all extractvalue instructions).
for (Value::use_iterator I = Call->use_begin(), E = Call->use_end();
@@ -781,11 +788,7 @@ bool DAE::RemoveDeadStuffFromFunction(Function *F) {
}
}
New->takeName(Call);
- } else {
- // The original function had a single return value
- Call->replaceAllUsesWith(New);
- New->takeName(Call);
- }
+ }
}
// Finally, remove the old call from the program, reducing the use-count of