summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/IPO/ArgumentPromotion.cpp
diff options
context:
space:
mode:
authorReid Kleckner <rnk@google.com>2017-05-03 18:17:31 +0000
committerReid Kleckner <rnk@google.com>2017-05-03 18:17:31 +0000
commita0b45f4bfccb3ab197ca504032c28160ce82eac2 (patch)
tree91fbb62cc8ff2350e9319c9d020f148632427bc7 /llvm/lib/Transforms/IPO/ArgumentPromotion.cpp
parent2e23ce4cadeace53fd7de8c89d786f59108f378a (diff)
downloadbcm5719-llvm-a0b45f4bfccb3ab197ca504032c28160ce82eac2.tar.gz
bcm5719-llvm-a0b45f4bfccb3ab197ca504032c28160ce82eac2.zip
[IR] Abstract away ArgNo+1 attribute indexing as much as possible
Summary: Do three things to help with that: - Add AttributeList::FirstArgIndex, which is an enumerator currently set to 1. It allows us to change the indexing scheme with fewer changes. - Add addParamAttr/removeParamAttr. This just shortens addAttribute call sites that would otherwise need to spell out FirstArgIndex. - Remove some attribute-specific getters and setters from Function that take attribute list indices. Most of these were only used from BuildLibCalls, and doesNotAlias was only used to test or set if the return value is malloc-like. I'm happy to split the patch, but I think they are probably easier to review when taken together. This patch should be NFC, but it sets the stage to change the indexing scheme to this, which is more convenient when indexing into an array: 0: func attrs 1: retattrs 2...: arg attrs Reviewers: chandlerc, pete, javed.absar Subscribers: david2050, llvm-commits Differential Revision: https://reviews.llvm.org/D32811 llvm-svn: 302060
Diffstat (limited to 'llvm/lib/Transforms/IPO/ArgumentPromotion.cpp')
-rw-r--r--llvm/lib/Transforms/IPO/ArgumentPromotion.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/llvm/lib/Transforms/IPO/ArgumentPromotion.cpp b/llvm/lib/Transforms/IPO/ArgumentPromotion.cpp
index 25db0eff884..6408cad08d5 100644
--- a/llvm/lib/Transforms/IPO/ArgumentPromotion.cpp
+++ b/llvm/lib/Transforms/IPO/ArgumentPromotion.cpp
@@ -839,12 +839,12 @@ promoteArguments(Function *F, function_ref<AAResults &(Function &F)> AARGetter,
// avoiding a register copy.
if (PtrArg->hasStructRetAttr()) {
unsigned ArgNo = PtrArg->getArgNo();
- F->removeAttribute(ArgNo + 1, Attribute::StructRet);
- F->addAttribute(ArgNo + 1, Attribute::NoAlias);
+ F->removeParamAttr(ArgNo, Attribute::StructRet);
+ F->addParamAttr(ArgNo, Attribute::NoAlias);
for (Use &U : F->uses()) {
CallSite CS(U.getUser());
- CS.removeAttribute(ArgNo + 1, Attribute::StructRet);
- CS.addAttribute(ArgNo + 1, Attribute::NoAlias);
+ CS.removeParamAttr(ArgNo, Attribute::StructRet);
+ CS.addParamAttr(ArgNo, Attribute::NoAlias);
}
}
OpenPOWER on IntegriCloud