[llvm] r186622 - Clean up some of this code a tiny bit, no functionality change.
Nick Lewycky
nicholas at mxc.ca
Thu Jul 18 15:32:33 PDT 2013
Author: nicholas
Date: Thu Jul 18 17:32:32 2013
New Revision: 186622
URL: http://llvm.org/viewvc/llvm-project?rev=186622&view=rev
Log:
Clean up some of this code a tiny bit, no functionality change.
Modified:
llvm/trunk/lib/Transforms/IPO/ArgumentPromotion.cpp
Modified: llvm/trunk/lib/Transforms/IPO/ArgumentPromotion.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/ArgumentPromotion.cpp?rev=186622&r1=186621&r2=186622&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/IPO/ArgumentPromotion.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/ArgumentPromotion.cpp Thu Jul 18 17:32:32 2013
@@ -126,12 +126,10 @@ CallGraphNode *ArgPromotion::PromoteArgu
if (!F || !F->hasLocalLinkage()) return 0;
// First check: see if there are any pointer arguments! If not, quick exit.
- SmallVector<std::pair<Argument*, unsigned>, 16> PointerArgs;
- unsigned ArgNo = 0;
- for (Function::arg_iterator I = F->arg_begin(), E = F->arg_end();
- I != E; ++I, ++ArgNo)
+ SmallVector<Argument*, 16> PointerArgs;
+ for (Function::arg_iterator I = F->arg_begin(), E = F->arg_end(); I != E; ++I)
if (I->getType()->isPointerTy())
- PointerArgs.push_back(std::pair<Argument*, unsigned>(I, ArgNo));
+ PointerArgs.push_back(I);
if (PointerArgs.empty()) return 0;
// Second check: make sure that all callers are direct callers. We can't
@@ -152,15 +150,13 @@ CallGraphNode *ArgPromotion::PromoteArgu
// add it to ArgsToPromote.
SmallPtrSet<Argument*, 8> ArgsToPromote;
SmallPtrSet<Argument*, 8> ByValArgsToTransform;
- for (unsigned i = 0; i != PointerArgs.size(); ++i) {
- bool isByVal=F->getAttributes().
- hasAttribute(PointerArgs[i].second+1, Attribute::ByVal);
- Argument *PtrArg = PointerArgs[i].first;
+ for (unsigned i = 0, e = PointerArgs.size(); i != e; ++i) {
+ Argument *PtrArg = PointerArgs[i];
Type *AgTy = cast<PointerType>(PtrArg->getType())->getElementType();
// If this is a byval argument, and if the aggregate type is small, just
// pass the elements, which is always safe.
- if (isByVal) {
+ if (PtrArg->hasByValAttr()) {
if (StructType *STy = dyn_cast<StructType>(AgTy)) {
if (maxElements > 0 && STy->getNumElements() > maxElements) {
DEBUG(dbgs() << "argpromotion disable promoting argument '"
@@ -205,7 +201,7 @@ CallGraphNode *ArgPromotion::PromoteArgu
}
// Otherwise, see if we can promote the pointer to its value.
- if (isSafeToPromoteArgument(PtrArg, isByVal))
+ if (isSafeToPromoteArgument(PtrArg, PtrArg->hasByValAttr()))
ArgsToPromote.insert(PtrArg);
}
@@ -221,8 +217,7 @@ CallGraphNode *ArgPromotion::PromoteArgu
static bool AllCallersPassInValidPointerForArgument(Argument *Arg) {
Function *Callee = Arg->getParent();
- unsigned ArgNo = std::distance(Callee->arg_begin(),
- Function::arg_iterator(Arg));
+ unsigned ArgNo = Arg->getArgNo();
// Look at all call sites of the function. At this pointer we know we only
// have direct callees.
More information about the llvm-commits
mailing list