aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNick Lewycky <nicholas@mxc.ca>2013-07-18 22:32:32 +0000
committerNick Lewycky <nicholas@mxc.ca>2013-07-18 22:32:32 +0000
commitb05ad799e7dc19d7c88576820b1cf16b43a4de9e (patch)
tree4dec6ac1a48c1fbfc2f3e96001d245e2ee4618c5
parent771e0ab32a81eb501edcd4027e07c5c14d591a09 (diff)
downloadexternal_llvm-b05ad799e7dc19d7c88576820b1cf16b43a4de9e.zip
external_llvm-b05ad799e7dc19d7c88576820b1cf16b43a4de9e.tar.gz
external_llvm-b05ad799e7dc19d7c88576820b1cf16b43a4de9e.tar.bz2
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
-rw-r--r--lib/Transforms/IPO/ArgumentPromotion.cpp21
1 files changed, 8 insertions, 13 deletions
diff --git a/lib/Transforms/IPO/ArgumentPromotion.cpp b/lib/Transforms/IPO/ArgumentPromotion.cpp
index e6fa4ed..c42d506 100644
--- a/lib/Transforms/IPO/ArgumentPromotion.cpp
+++ b/lib/Transforms/IPO/ArgumentPromotion.cpp
@@ -126,12 +126,10 @@ CallGraphNode *ArgPromotion::PromoteArguments(CallGraphNode *CGN) {
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::PromoteArguments(CallGraphNode *CGN) {
// 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::PromoteArguments(CallGraphNode *CGN) {
}
// 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::PromoteArguments(CallGraphNode *CGN) {
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.