summaryrefslogtreecommitdiff
path: root/lib/Transforms/IPO
diff options
context:
space:
mode:
authorMatthijs Kooijman <matthijs@stdin.nl>2008-07-15 09:11:16 +0000
committerMatthijs Kooijman <matthijs@stdin.nl>2008-07-15 09:11:16 +0000
commit2bf5372d8ad714be63bdd34dbfda2ad4bd8eeaba (patch)
tree992796b45078a5ebfa95ca138dbc4413cd4622bb /lib/Transforms/IPO
parent30156524734c5a4ac49a1e8c607c375346770fa5 (diff)
downloadllvm-2bf5372d8ad714be63bdd34dbfda2ad4bd8eeaba.tar.gz
llvm-2bf5372d8ad714be63bdd34dbfda2ad4bd8eeaba.tar.bz2
llvm-2bf5372d8ad714be63bdd34dbfda2ad4bd8eeaba.tar.xz
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53601 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/IPO')
-rw-r--r--lib/Transforms/IPO/DeadArgumentElimination.cpp20
1 files changed, 14 insertions, 6 deletions
diff --git a/lib/Transforms/IPO/DeadArgumentElimination.cpp b/lib/Transforms/IPO/DeadArgumentElimination.cpp
index 11c083b393..19be0eeb3c 100644
--- a/lib/Transforms/IPO/DeadArgumentElimination.cpp
+++ b/lib/Transforms/IPO/DeadArgumentElimination.cpp
@@ -110,9 +110,12 @@ namespace {
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 @@ static unsigned NumRetVals(const Function *F) {
/// 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 @@ void DAE::MarkValue(const RetOrArg &RA, Liveness L,
/// 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 @@ void DAE::PropagateLiveness(const RetOrArg &RA) {
// 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