mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-08-09 11:25:55 +00:00
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
This commit is contained in:
@@ -110,9 +110,12 @@ namespace {
|
|||||||
UseMap Uses;
|
UseMap Uses;
|
||||||
|
|
||||||
typedef std::set<RetOrArg> LiveSet;
|
typedef std::set<RetOrArg> LiveSet;
|
||||||
|
typedef std::set<const Function*> LiveFuncSet;
|
||||||
|
|
||||||
/// This set contains all values that have been determined to be live.
|
/// This set contains all values that have been determined to be live.
|
||||||
LiveSet LiveValues;
|
LiveSet LiveValues;
|
||||||
|
/// This set contains all values that are cannot be changed in any way.
|
||||||
|
LiveFuncSet LiveFunctions;
|
||||||
|
|
||||||
typedef SmallVector<RetOrArg, 5> UseVector;
|
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
|
/// live, it adds Use to the MaybeLiveUses argument. Returns the determined
|
||||||
/// liveness of Use.
|
/// liveness of Use.
|
||||||
DAE::Liveness DAE::MarkIfNotLive(RetOrArg Use, UseVector &MaybeLiveUses) {
|
DAE::Liveness DAE::MarkIfNotLive(RetOrArg Use, UseVector &MaybeLiveUses) {
|
||||||
// We're live if our use is already marked as live.
|
// We're live if our use or its Function is already marked as live.
|
||||||
if (LiveValues.count(Use))
|
if (LiveFunctions.count(Use.F) || LiveValues.count(Use))
|
||||||
return Live;
|
return Live;
|
||||||
|
|
||||||
// We're maybe live otherwise, but remember that we must become live if
|
// 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.
|
/// values (according to Uses) live as well.
|
||||||
void DAE::MarkLive(const Function &F) {
|
void DAE::MarkLive(const Function &F) {
|
||||||
DOUT << "DAE - Intrinsically live fn: " << F.getName() << "\n";
|
DOUT << "DAE - Intrinsically live fn: " << F.getName() << "\n";
|
||||||
|
// Mark the function as live.
|
||||||
|
LiveFunctions.insert(&F);
|
||||||
// Mark all arguments as live.
|
// Mark all arguments as live.
|
||||||
for (unsigned i = 0, e = F.arg_size(); i != e; ++i)
|
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.
|
// Mark all return values as live.
|
||||||
for (unsigned i = 0, e = NumRetVals(&F); i != e; ++i)
|
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,
|
/// 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
|
/// mark any values that are used by this value (according to Uses) live as
|
||||||
/// well.
|
/// well.
|
||||||
void DAE::MarkLive(const RetOrArg &RA) {
|
void DAE::MarkLive(const RetOrArg &RA) {
|
||||||
|
if (LiveFunctions.count(RA.F))
|
||||||
|
return; // Function was already marked Live.
|
||||||
|
|
||||||
if (!LiveValues.insert(RA).second)
|
if (!LiveValues.insert(RA).second)
|
||||||
return; // We were already marked Live.
|
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.
|
// the function to not have these arguments and return values.
|
||||||
//
|
//
|
||||||
bool DAE::RemoveDeadStuffFromFunction(Function *F) {
|
bool DAE::RemoveDeadStuffFromFunction(Function *F) {
|
||||||
// Quick exit path for external functions
|
// Don't modify fully live functions
|
||||||
if (!F->hasInternalLinkage() && (!ShouldHackArguments() || F->isIntrinsic()))
|
if (LiveFunctions.count(F))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Start by computing a new prototype for the function, which is the same as
|
// Start by computing a new prototype for the function, which is the same as
|
||||||
|
Reference in New Issue
Block a user