mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-24 11:42:57 +01:00
Explicitely track if any arguments or return values were removed in
DeadArgumentElimination and assert that the function type does not change if nothing was changed. This should catch subtle changes in function type that are not intended. llvm-svn: 52536
This commit is contained in:
parent
35ac78c162
commit
1d019c28b3
@ -568,6 +568,8 @@ bool DAE::RemoveDeadStuffFromFunction(Function *F) {
|
|||||||
const Type *RetTy = FTy->getReturnType();
|
const Type *RetTy = FTy->getReturnType();
|
||||||
const Type *NRetTy;
|
const Type *NRetTy;
|
||||||
unsigned RetCount = NumRetVals(F);
|
unsigned RetCount = NumRetVals(F);
|
||||||
|
// Explicitely track if anything changed, for debugging
|
||||||
|
bool Changed = false;
|
||||||
// -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;
|
||||||
@ -582,7 +584,8 @@ bool DAE::RemoveDeadStuffFromFunction(Function *F) {
|
|||||||
NewRetIdxs[i] = RetTypes.size() - 1;
|
NewRetIdxs[i] = RetTypes.size() - 1;
|
||||||
} else {
|
} else {
|
||||||
++NumRetValsEliminated;
|
++NumRetValsEliminated;
|
||||||
DOUT << "DAE - Removing return value " << i << " from " << F->getNameStart() << "\n";
|
DOUT << "DAE - Removing return value " << i << " from " << F->getNameStart() << "\n";
|
||||||
|
Changed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -593,6 +596,7 @@ bool DAE::RemoveDeadStuffFromFunction(Function *F) {
|
|||||||
} else {
|
} else {
|
||||||
DOUT << "DAE - Removing return value from " << F->getNameStart() << "\n";
|
DOUT << "DAE - Removing return value from " << F->getNameStart() << "\n";
|
||||||
++NumRetValsEliminated;
|
++NumRetValsEliminated;
|
||||||
|
Changed = true;
|
||||||
}
|
}
|
||||||
if (RetTypes.size() == 0)
|
if (RetTypes.size() == 0)
|
||||||
// No return types? Make it void
|
// No return types? Make it void
|
||||||
@ -632,6 +636,7 @@ bool DAE::RemoveDeadStuffFromFunction(Function *F) {
|
|||||||
} else {
|
} else {
|
||||||
++NumArgumentsEliminated;
|
++NumArgumentsEliminated;
|
||||||
DOUT << "DAE - Removing argument " << i << " (" << I->getNameStart() << ") from " << F->getNameStart() << "\n";
|
DOUT << "DAE - Removing argument " << i << " (" << I->getNameStart() << ") from " << F->getNameStart() << "\n";
|
||||||
|
Changed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -657,6 +662,10 @@ bool DAE::RemoveDeadStuffFromFunction(Function *F) {
|
|||||||
if (NFTy == FTy)
|
if (NFTy == FTy)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
// The function type is only allowed to be different if we actually left out
|
||||||
|
// an argument or return value
|
||||||
|
assert(Changed && "Function type changed while no arguments or retrurn values were removed!");
|
||||||
|
|
||||||
// Create the new function body and insert it into the module...
|
// Create the new function body and insert it into the module...
|
||||||
Function *NF = Function::Create(NFTy, F->getLinkage());
|
Function *NF = Function::Create(NFTy, F->getLinkage());
|
||||||
NF->copyAttributesFrom(F);
|
NF->copyAttributesFrom(F);
|
||||||
|
Loading…
Reference in New Issue
Block a user