[llvm-commits] [llvm] r53601 - /llvm/trunk/lib/Transforms/IPO/DeadArgumentElimination.cpp
Matthijs Kooijman
matthijs at stdin.nl
Tue Jul 15 02:11:17 PDT 2008
Author: matthijs
Date: Tue Jul 15 04:11:16 2008
New Revision: 53601
URL: http://llvm.org/viewvc/llvm-project?rev=53601&view=rev
Log:
Let DAE keep a list of live functions, instead of simply marking all arguments
and return values live for those functions. This doesn't change anything yet,
but prepares for the coming commits.
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=53601&r1=53600&r2=53601&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/IPO/DeadArgumentElimination.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/DeadArgumentElimination.cpp Tue Jul 15 04:11:16 2008
@@ -110,9 +110,12 @@
UseMap Uses;
typedef std::set<RetOrArg> LiveSet;
+ typedef std::set<const Function*> LiveFuncSet;
/// This set contains all values that have been determined to be live.
LiveSet LiveValues;
+ /// This set contains all values that are cannot be changed in any way.
+ LiveFuncSet LiveFunctions;
typedef SmallVector<RetOrArg, 5> UseVector;
@@ -291,8 +294,8 @@
/// live, it adds Use to the MaybeLiveUses argument. Returns the determined
/// liveness of Use.
DAE::Liveness DAE::MarkIfNotLive(RetOrArg Use, UseVector &MaybeLiveUses) {
- // We're live if our use is already marked as live.
- if (LiveValues.count(Use))
+ // We're live if our use or its Function is already marked as live.
+ if (LiveFunctions.count(Use.F) || LiveValues.count(Use))
return Live;
// We're maybe live otherwise, but remember that we must become live if
@@ -530,18 +533,23 @@
/// values (according to Uses) live as well.
void DAE::MarkLive(const Function &F) {
DOUT << "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)
- MarkLive(CreateArg(&F, i));
+ PropagateLiveness(CreateArg(&F, i));
// Mark all return values as live.
for (unsigned i = 0, e = NumRetVals(&F); i != e; ++i)
- MarkLive(CreateRet(&F, i));
+ PropagateLiveness(CreateRet(&F, i));
}
/// MarkLive - Mark the given return value or argument as live. Additionally,
/// mark any values that are used by this value (according to Uses) live as
/// well.
void DAE::MarkLive(const RetOrArg &RA) {
+ if (LiveFunctions.count(RA.F))
+ return; // Function was already marked Live.
+
if (!LiveValues.insert(RA).second)
return; // We were already marked Live.
@@ -571,8 +579,8 @@
// the function to not have these arguments and return values.
//
bool DAE::RemoveDeadStuffFromFunction(Function *F) {
- // Quick exit path for external functions
- if (!F->hasInternalLinkage() && (!ShouldHackArguments() || F->isIntrinsic()))
+ // Don't modify fully live functions
+ if (LiveFunctions.count(F))
return false;
// Start by computing a new prototype for the function, which is the same as
More information about the llvm-commits
mailing list