mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-08-14 15:28:20 +00:00
Move the deadargelim code for intrinsically alive functions into its own
method, to slightly simplify control flow. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53591 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -133,6 +133,7 @@ namespace {
|
|||||||
void MarkValue(const RetOrArg &RA, Liveness L,
|
void MarkValue(const RetOrArg &RA, Liveness L,
|
||||||
const UseVector &MaybeLiveUses);
|
const UseVector &MaybeLiveUses);
|
||||||
void MarkLive(RetOrArg RA);
|
void MarkLive(RetOrArg RA);
|
||||||
|
void MarkLive(const Function &F);
|
||||||
bool RemoveDeadStuffFromFunction(Function *F);
|
bool RemoveDeadStuffFromFunction(Function *F);
|
||||||
bool DeleteDeadVarargs(Function &Fn);
|
bool DeleteDeadVarargs(Function &Fn);
|
||||||
};
|
};
|
||||||
@@ -397,7 +398,6 @@ DAE::Liveness DAE::SurveyUses(Value *V, UseVector &MaybeLiveUses) {
|
|||||||
// well as arguments to functions which have their "address taken".
|
// well as arguments to functions which have their "address taken".
|
||||||
//
|
//
|
||||||
void DAE::SurveyFunction(Function &F) {
|
void DAE::SurveyFunction(Function &F) {
|
||||||
bool FunctionIntrinsicallyLive = false;
|
|
||||||
unsigned RetCount = NumRetVals(&F);
|
unsigned RetCount = NumRetVals(&F);
|
||||||
// Assume all return values are dead
|
// Assume all return values are dead
|
||||||
typedef SmallVector<Liveness, 5> RetVals;
|
typedef SmallVector<Liveness, 5> RetVals;
|
||||||
@@ -414,14 +414,15 @@ void DAE::SurveyFunction(Function &F) {
|
|||||||
if (RI->getNumOperands() != 0 && RI->getOperand(0)->getType()
|
if (RI->getNumOperands() != 0 && RI->getOperand(0)->getType()
|
||||||
!= F.getFunctionType()->getReturnType()) {
|
!= F.getFunctionType()->getReturnType()) {
|
||||||
// We don't support old style multiple return values.
|
// We don't support old style multiple return values.
|
||||||
FunctionIntrinsicallyLive = true;
|
MarkLive(F);
|
||||||
break;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!F.hasInternalLinkage() && (!ShouldHackArguments() || F.isIntrinsic()))
|
if (!F.hasInternalLinkage() && (!ShouldHackArguments() || F.isIntrinsic())) {
|
||||||
FunctionIntrinsicallyLive = true;
|
MarkLive(F);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!FunctionIntrinsicallyLive) {
|
|
||||||
DOUT << "DAE - Inspecting callers for fn: " << F.getName() << "\n";
|
DOUT << "DAE - Inspecting callers for fn: " << F.getName() << "\n";
|
||||||
// Keep track of the number of live retvals, so we can skip checks once all
|
// Keep track of the number of live retvals, so we can skip checks once all
|
||||||
// of them turn out to be live.
|
// of them turn out to be live.
|
||||||
@@ -432,16 +433,16 @@ void DAE::SurveyFunction(Function &F) {
|
|||||||
// If the function is PASSED IN as an argument, its address has been
|
// If the function is PASSED IN as an argument, its address has been
|
||||||
// taken.
|
// taken.
|
||||||
if (I.getOperandNo() != 0) {
|
if (I.getOperandNo() != 0) {
|
||||||
FunctionIntrinsicallyLive = true;
|
MarkLive(F);
|
||||||
break;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If this use is anything other than a call site, the function is alive.
|
// If this use is anything other than a call site, the function is alive.
|
||||||
CallSite CS = CallSite::get(*I);
|
CallSite CS = CallSite::get(*I);
|
||||||
Instruction *TheCall = CS.getInstruction();
|
Instruction *TheCall = CS.getInstruction();
|
||||||
if (!TheCall) { // Not a direct call site?
|
if (!TheCall) { // Not a direct call site?
|
||||||
FunctionIntrinsicallyLive = true;
|
MarkLive(F);
|
||||||
break;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we end up here, we are looking at a direct call to our function.
|
// If we end up here, we are looking at a direct call to our function.
|
||||||
@@ -480,19 +481,6 @@ void DAE::SurveyFunction(Function &F) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (FunctionIntrinsicallyLive) {
|
|
||||||
DOUT << "DAE - Intrinsically live fn: " << F.getName() << "\n";
|
|
||||||
// Mark all arguments as live.
|
|
||||||
unsigned i = 0;
|
|
||||||
for (unsigned i = 0, e = F.arg_size(); i != e; ++i)
|
|
||||||
MarkLive(CreateArg(&F, i));
|
|
||||||
// Mark all return values as live.
|
|
||||||
i = 0;
|
|
||||||
for (unsigned i = 0; i != RetCount; ++i)
|
|
||||||
MarkLive(CreateRet(&F, i));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Now we've inspected all callers, record the liveness of our return values.
|
// Now we've inspected all callers, record the liveness of our return values.
|
||||||
for (unsigned i = 0; i != RetCount; ++i)
|
for (unsigned i = 0; i != RetCount; ++i)
|
||||||
@@ -535,6 +523,20 @@ void DAE::MarkValue(const RetOrArg &RA, Liveness L,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// MarkLive - Mark the given Function as alive, meaning that it cannot be
|
||||||
|
/// changed in any way. Additionally,
|
||||||
|
/// mark any values that are used as this function's parameters or by its return
|
||||||
|
/// values (according to Uses) live as well.
|
||||||
|
void DAE::MarkLive(const Function &F) {
|
||||||
|
DOUT << "DAE - Intrinsically live fn: " << F.getName() << "\n";
|
||||||
|
// Mark all arguments as live.
|
||||||
|
for (unsigned i = 0, e = F.arg_size(); i != e; ++i)
|
||||||
|
MarkLive(CreateArg(&F, i));
|
||||||
|
// Mark all return values as live.
|
||||||
|
for (unsigned i = 0, e = NumRetVals(&F); i != e; ++i)
|
||||||
|
MarkLive(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.
|
||||||
|
Reference in New Issue
Block a user