mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-14 11:32:34 +00:00
Clean up some of this code a tiny bit, no functionality change.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@186622 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
771e0ab32a
commit
b05ad799e7
@ -126,12 +126,10 @@ CallGraphNode *ArgPromotion::PromoteArguments(CallGraphNode *CGN) {
|
|||||||
if (!F || !F->hasLocalLinkage()) return 0;
|
if (!F || !F->hasLocalLinkage()) return 0;
|
||||||
|
|
||||||
// First check: see if there are any pointer arguments! If not, quick exit.
|
// First check: see if there are any pointer arguments! If not, quick exit.
|
||||||
SmallVector<std::pair<Argument*, unsigned>, 16> PointerArgs;
|
SmallVector<Argument*, 16> PointerArgs;
|
||||||
unsigned ArgNo = 0;
|
for (Function::arg_iterator I = F->arg_begin(), E = F->arg_end(); I != E; ++I)
|
||||||
for (Function::arg_iterator I = F->arg_begin(), E = F->arg_end();
|
|
||||||
I != E; ++I, ++ArgNo)
|
|
||||||
if (I->getType()->isPointerTy())
|
if (I->getType()->isPointerTy())
|
||||||
PointerArgs.push_back(std::pair<Argument*, unsigned>(I, ArgNo));
|
PointerArgs.push_back(I);
|
||||||
if (PointerArgs.empty()) return 0;
|
if (PointerArgs.empty()) return 0;
|
||||||
|
|
||||||
// Second check: make sure that all callers are direct callers. We can't
|
// Second check: make sure that all callers are direct callers. We can't
|
||||||
@ -152,15 +150,13 @@ CallGraphNode *ArgPromotion::PromoteArguments(CallGraphNode *CGN) {
|
|||||||
// add it to ArgsToPromote.
|
// add it to ArgsToPromote.
|
||||||
SmallPtrSet<Argument*, 8> ArgsToPromote;
|
SmallPtrSet<Argument*, 8> ArgsToPromote;
|
||||||
SmallPtrSet<Argument*, 8> ByValArgsToTransform;
|
SmallPtrSet<Argument*, 8> ByValArgsToTransform;
|
||||||
for (unsigned i = 0; i != PointerArgs.size(); ++i) {
|
for (unsigned i = 0, e = PointerArgs.size(); i != e; ++i) {
|
||||||
bool isByVal=F->getAttributes().
|
Argument *PtrArg = PointerArgs[i];
|
||||||
hasAttribute(PointerArgs[i].second+1, Attribute::ByVal);
|
|
||||||
Argument *PtrArg = PointerArgs[i].first;
|
|
||||||
Type *AgTy = cast<PointerType>(PtrArg->getType())->getElementType();
|
Type *AgTy = cast<PointerType>(PtrArg->getType())->getElementType();
|
||||||
|
|
||||||
// If this is a byval argument, and if the aggregate type is small, just
|
// If this is a byval argument, and if the aggregate type is small, just
|
||||||
// pass the elements, which is always safe.
|
// pass the elements, which is always safe.
|
||||||
if (isByVal) {
|
if (PtrArg->hasByValAttr()) {
|
||||||
if (StructType *STy = dyn_cast<StructType>(AgTy)) {
|
if (StructType *STy = dyn_cast<StructType>(AgTy)) {
|
||||||
if (maxElements > 0 && STy->getNumElements() > maxElements) {
|
if (maxElements > 0 && STy->getNumElements() > maxElements) {
|
||||||
DEBUG(dbgs() << "argpromotion disable promoting argument '"
|
DEBUG(dbgs() << "argpromotion disable promoting argument '"
|
||||||
@ -205,7 +201,7 @@ CallGraphNode *ArgPromotion::PromoteArguments(CallGraphNode *CGN) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Otherwise, see if we can promote the pointer to its value.
|
// Otherwise, see if we can promote the pointer to its value.
|
||||||
if (isSafeToPromoteArgument(PtrArg, isByVal))
|
if (isSafeToPromoteArgument(PtrArg, PtrArg->hasByValAttr()))
|
||||||
ArgsToPromote.insert(PtrArg);
|
ArgsToPromote.insert(PtrArg);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -221,8 +217,7 @@ CallGraphNode *ArgPromotion::PromoteArguments(CallGraphNode *CGN) {
|
|||||||
static bool AllCallersPassInValidPointerForArgument(Argument *Arg) {
|
static bool AllCallersPassInValidPointerForArgument(Argument *Arg) {
|
||||||
Function *Callee = Arg->getParent();
|
Function *Callee = Arg->getParent();
|
||||||
|
|
||||||
unsigned ArgNo = std::distance(Callee->arg_begin(),
|
unsigned ArgNo = Arg->getArgNo();
|
||||||
Function::arg_iterator(Arg));
|
|
||||||
|
|
||||||
// Look at all call sites of the function. At this pointer we know we only
|
// Look at all call sites of the function. At this pointer we know we only
|
||||||
// have direct callees.
|
// have direct callees.
|
||||||
|
Loading…
Reference in New Issue
Block a user