summaryrefslogtreecommitdiff
path: root/lib/Transforms/IPO/DeadArgumentElimination.cpp
diff options
context:
space:
mode:
authorNick Lewycky <nicholas@mxc.ca>2010-04-14 04:51:58 +0000
committerNick Lewycky <nicholas@mxc.ca>2010-04-14 04:51:58 +0000
commit3715e45da564e1c92410bf7b2d799d998664ff44 (patch)
treed8da815b2b4cfb0014d0239868b72634ee041642 /lib/Transforms/IPO/DeadArgumentElimination.cpp
parentd4ef4df939a830ae3ea4bd9063f6ec5e8d9dd216 (diff)
downloadllvm-3715e45da564e1c92410bf7b2d799d998664ff44.tar.gz
llvm-3715e45da564e1c92410bf7b2d799d998664ff44.tar.bz2
llvm-3715e45da564e1c92410bf7b2d799d998664ff44.tar.xz
Revert r101213.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@101231 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/IPO/DeadArgumentElimination.cpp')
-rw-r--r--lib/Transforms/IPO/DeadArgumentElimination.cpp43
1 files changed, 14 insertions, 29 deletions
diff --git a/lib/Transforms/IPO/DeadArgumentElimination.cpp b/lib/Transforms/IPO/DeadArgumentElimination.cpp
index 5bf45174f5..1ffb1a3821 100644
--- a/lib/Transforms/IPO/DeadArgumentElimination.cpp
+++ b/lib/Transforms/IPO/DeadArgumentElimination.cpp
@@ -30,7 +30,6 @@
#include "llvm/Support/CallSite.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/raw_ostream.h"
-#include "llvm/Transforms/Utils/Local.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/ADT/StringExtras.h"
@@ -38,9 +37,8 @@
#include <set>
using namespace llvm;
-STATISTIC(NumArgumentsEliminated , "Number of unread args removed");
-STATISTIC(NumRetValsEliminated , "Number of unused return values removed");
-STATISTIC(NumParametersEliminated, "Number of parameters replaced with undef");
+STATISTIC(NumArgumentsEliminated, "Number of unread args removed");
+STATISTIC(NumRetValsEliminated , "Number of unused return values removed");
namespace {
/// DAE - The dead argument elimination pass.
@@ -142,7 +140,6 @@ namespace {
void MarkLive(const Function &F);
void PropagateLiveness(const RetOrArg &RA);
bool RemoveDeadStuffFromFunction(Function *F);
- bool RemoveDeadParamsFromCallersOf(Function *F);
bool DeleteDeadVarargs(Function &Fn);
};
}
@@ -400,9 +397,7 @@ DAE::Liveness DAE::SurveyUses(const Value *V, UseVector &MaybeLiveUses) {
// map.
//
// We consider arguments of non-internal functions to be intrinsically alive as
-// well as arguments to functions which have their "address taken". Externally
-// visible functions are assumed to only have their return values intrinsically
-// alive, permitting removal of parameters to unused arguments in callers.
+// well as arguments to functions which have their "address taken".
//
void DAE::SurveyFunction(const Function &F) {
unsigned RetCount = NumRetVals(&F);
@@ -425,14 +420,7 @@ void DAE::SurveyFunction(const Function &F) {
return;
}
- if (F.hasExternalLinkage() && !F.isDeclaration()) {
- DEBUG(dbgs() << "DAE - Intrinsically live return from " << F.getName()
- << "\n");
- // Mark the return values alive.
- for (unsigned i = 0, e = NumRetVals(&F); i != e; ++i)
- MarkLive(CreateRet(&F, i));
- } else if (!F.hasLocalLinkage() &&
- (!ShouldHackArguments() || F.isIntrinsic())) {
+ if (!F.hasLocalLinkage() && (!ShouldHackArguments() || F.isIntrinsic())) {
MarkLive(F);
return;
}
@@ -544,14 +532,14 @@ void DAE::MarkValue(const RetOrArg &RA, Liveness L,
/// values (according to Uses) live as well.
void DAE::MarkLive(const Function &F) {
DEBUG(dbgs() << "DAE - Intrinsically live fn: " << F.getName() << "\n");
- // Mark the function as live.
- LiveFunctions.insert(&F);
- // Mark all arguments as live.
- for (unsigned i = 0, e = F.arg_size(); i != e; ++i)
- PropagateLiveness(CreateArg(&F, i));
- // Mark all return values as live.
- for (unsigned i = 0, e = NumRetVals(&F); i != e; ++i)
- PropagateLiveness(CreateRet(&F, i));
+ // Mark the function as live.
+ LiveFunctions.insert(&F);
+ // Mark all arguments as live.
+ for (unsigned i = 0, e = F.arg_size(); i != e; ++i)
+ PropagateLiveness(CreateArg(&F, i));
+ // Mark all return values as live.
+ for (unsigned i = 0, e = NumRetVals(&F); i != e; ++i)
+ PropagateLiveness(CreateRet(&F, i));
}
/// MarkLive - Mark the given return value or argument as live. Additionally,
@@ -865,7 +853,7 @@ bool DAE::RemoveDeadStuffFromFunction(Function *F) {
if (ReturnInst *RI = dyn_cast<ReturnInst>(BB->getTerminator())) {
Value *RetVal;
- if (NFTy->getReturnType()->isVoidTy()) {
+ if (NFTy->getReturnType() == Type::getVoidTy(F->getContext())) {
RetVal = 0;
} else {
assert (RetTy->isStructTy());
@@ -971,10 +959,7 @@ bool DAE::runOnModule(Module &M) {
// Increment now, because the function will probably get removed (ie.
// replaced by a new one).
Function *F = I++;
- if (F->hasExternalLinkage() && !F->isDeclaration())
- Changed |= RemoveDeadParamsFromCallersOf(F);
- else
- Changed |= RemoveDeadStuffFromFunction(F);
+ Changed |= RemoveDeadStuffFromFunction(F);
}
return Changed;
}