mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-29 10:25:12 +00:00
Clean up this file a little, no functionality change. This is a subset of my
patch back in r94322. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@100097 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -50,7 +50,7 @@ namespace {
|
|||||||
/// argument. Used so that arguments and return values can be used
|
/// argument. Used so that arguments and return values can be used
|
||||||
/// interchangably.
|
/// interchangably.
|
||||||
struct RetOrArg {
|
struct RetOrArg {
|
||||||
RetOrArg(const Function* F, unsigned Idx, bool IsArg) : F(F), Idx(Idx),
|
RetOrArg(const Function *F, unsigned Idx, bool IsArg) : F(F), Idx(Idx),
|
||||||
IsArg(IsArg) {}
|
IsArg(IsArg) {}
|
||||||
const Function *F;
|
const Function *F;
|
||||||
unsigned Idx;
|
unsigned Idx;
|
||||||
@@ -280,7 +280,7 @@ bool DAE::DeleteDeadVarargs(Function &Fn) {
|
|||||||
/// for void functions and 1 for functions not returning a struct. It returns
|
/// for void functions and 1 for functions not returning a struct. It returns
|
||||||
/// the number of struct elements for functions returning a struct.
|
/// the number of struct elements for functions returning a struct.
|
||||||
static unsigned NumRetVals(const Function *F) {
|
static unsigned NumRetVals(const Function *F) {
|
||||||
if (F->getReturnType() == Type::getVoidTy(F->getContext()))
|
if (F->getReturnType()->isVoidTy())
|
||||||
return 0;
|
return 0;
|
||||||
else if (const StructType *STy = dyn_cast<StructType>(F->getReturnType()))
|
else if (const StructType *STy = dyn_cast<StructType>(F->getReturnType()))
|
||||||
return STy->getNumElements();
|
return STy->getNumElements();
|
||||||
@@ -305,7 +305,7 @@ DAE::Liveness DAE::MarkIfNotLive(RetOrArg Use, UseVector &MaybeLiveUses) {
|
|||||||
|
|
||||||
/// SurveyUse - This looks at a single use of an argument or return value
|
/// SurveyUse - This looks at a single use of an argument or return value
|
||||||
/// and determines if it should be alive or not. Adds this use to MaybeLiveUses
|
/// and determines if it should be alive or not. Adds this use to MaybeLiveUses
|
||||||
/// if it causes the used value to become MaybeAlive.
|
/// if it causes the used value to become MaybeLive.
|
||||||
///
|
///
|
||||||
/// RetValNum is the return value number to use when this use is used in a
|
/// RetValNum is the return value number to use when this use is used in a
|
||||||
/// return instruction. This is used in the recursion, you should always leave
|
/// return instruction. This is used in the recursion, you should always leave
|
||||||
@@ -603,8 +603,8 @@ bool DAE::RemoveDeadStuffFromFunction(Function *F) {
|
|||||||
// -1 means unused, other numbers are the new index
|
// -1 means unused, other numbers are the new index
|
||||||
SmallVector<int, 5> NewRetIdxs(RetCount, -1);
|
SmallVector<int, 5> NewRetIdxs(RetCount, -1);
|
||||||
std::vector<const Type*> RetTypes;
|
std::vector<const Type*> RetTypes;
|
||||||
if (RetTy == Type::getVoidTy(F->getContext())) {
|
if (RetTy->isVoidTy()) {
|
||||||
NRetTy = Type::getVoidTy(F->getContext());
|
NRetTy = RetTy;
|
||||||
} else {
|
} else {
|
||||||
const StructType *STy = dyn_cast<StructType>(RetTy);
|
const StructType *STy = dyn_cast<StructType>(RetTy);
|
||||||
if (STy)
|
if (STy)
|
||||||
@@ -653,7 +653,7 @@ bool DAE::RemoveDeadStuffFromFunction(Function *F) {
|
|||||||
// values. Otherwise, ensure that we don't have any conflicting attributes
|
// values. Otherwise, ensure that we don't have any conflicting attributes
|
||||||
// here. Currently, this should not be possible, but special handling might be
|
// here. Currently, this should not be possible, but special handling might be
|
||||||
// required when new return value attributes are added.
|
// required when new return value attributes are added.
|
||||||
if (NRetTy == Type::getVoidTy(F->getContext()))
|
if (NRetTy->isVoidTy())
|
||||||
RAttrs &= ~Attribute::typeIncompatible(NRetTy);
|
RAttrs &= ~Attribute::typeIncompatible(NRetTy);
|
||||||
else
|
else
|
||||||
assert((RAttrs & Attribute::typeIncompatible(NRetTy)) == 0
|
assert((RAttrs & Attribute::typeIncompatible(NRetTy)) == 0
|
||||||
@@ -705,8 +705,7 @@ bool DAE::RemoveDeadStuffFromFunction(Function *F) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Create the new function type based on the recomputed parameters.
|
// Create the new function type based on the recomputed parameters.
|
||||||
FunctionType *NFTy = FunctionType::get(NRetTy, Params,
|
FunctionType *NFTy = FunctionType::get(NRetTy, Params, FTy->isVarArg());
|
||||||
FTy->isVarArg());
|
|
||||||
|
|
||||||
// No change?
|
// No change?
|
||||||
if (NFTy == FTy)
|
if (NFTy == FTy)
|
||||||
@@ -791,7 +790,7 @@ bool DAE::RemoveDeadStuffFromFunction(Function *F) {
|
|||||||
// Return type not changed? Just replace users then.
|
// Return type not changed? Just replace users then.
|
||||||
Call->replaceAllUsesWith(New);
|
Call->replaceAllUsesWith(New);
|
||||||
New->takeName(Call);
|
New->takeName(Call);
|
||||||
} else if (New->getType() == Type::getVoidTy(F->getContext())) {
|
} else if (New->getType()->isVoidTy()) {
|
||||||
// Our return value has uses, but they will get removed later on.
|
// Our return value has uses, but they will get removed later on.
|
||||||
// Replace by null for now.
|
// Replace by null for now.
|
||||||
Call->replaceAllUsesWith(Constant::getNullValue(Call->getType()));
|
Call->replaceAllUsesWith(Constant::getNullValue(Call->getType()));
|
||||||
@@ -931,9 +930,9 @@ bool DAE::runOnModule(Module &M) {
|
|||||||
SurveyFunction(*I);
|
SurveyFunction(*I);
|
||||||
|
|
||||||
// Now, remove all dead arguments and return values from each function in
|
// Now, remove all dead arguments and return values from each function in
|
||||||
// turn
|
// turn.
|
||||||
for (Module::iterator I = M.begin(), E = M.end(); I != E; ) {
|
for (Module::iterator I = M.begin(), E = M.end(); I != E; ) {
|
||||||
// Increment now, because the function will probably get removed (ie
|
// Increment now, because the function will probably get removed (ie.
|
||||||
// replaced by a new one).
|
// replaced by a new one).
|
||||||
Function *F = I++;
|
Function *F = I++;
|
||||||
Changed |= RemoveDeadStuffFromFunction(F);
|
Changed |= RemoveDeadStuffFromFunction(F);
|
||||||
|
Reference in New Issue
Block a user