[llvm-commits] [llvm] r52538 - /llvm/trunk/lib/Transforms/IPO/DeadArgumentElimination.cpp
Matthijs Kooijman
matthijs at stdin.nl
Fri Jun 20 08:25:43 PDT 2008
Author: matthijs
Date: Fri Jun 20 10:25:43 2008
New Revision: 52538
URL: http://llvm.org/viewvc/llvm-project?rev=52538&view=rev
Log:
Don't let DeadArgumentElimination attempt to update callers when the return
type wasn't changed.
Modified:
llvm/trunk/lib/Transforms/IPO/DeadArgumentElimination.cpp
Modified: llvm/trunk/lib/Transforms/IPO/DeadArgumentElimination.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/DeadArgumentElimination.cpp?rev=52538&r1=52537&r2=52538&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/IPO/DeadArgumentElimination.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/DeadArgumentElimination.cpp Fri Jun 20 10:25:43 2008
@@ -743,11 +743,18 @@
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 @@
}
}
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
More information about the llvm-commits
mailing list