summaryrefslogtreecommitdiffstats
path: root/llvm/lib/IR/Instructions.cpp
diff options
context:
space:
mode:
authorReid Kleckner <rnk@google.com>2017-05-31 19:23:09 +0000
committerReid Kleckner <rnk@google.com>2017-05-31 19:23:09 +0000
commit5fbdd17714e2b0ab6974787c43bf1758ea451d78 (patch)
tree5b0b68a3b37f1146ef3a77fb9055372886286793 /llvm/lib/IR/Instructions.cpp
parent23db6360804901e2df536c821c5a9f829e89545d (diff)
downloadbcm5719-llvm-5fbdd17714e2b0ab6974787c43bf1758ea451d78.tar.gz
bcm5719-llvm-5fbdd17714e2b0ab6974787c43bf1758ea451d78.zip
[IR] Add additional addParamAttr/removeParamAttr to AttributeList API
Summary: Fairly straightforward patch to fill in some of the holes in the attributes API with respect to accessing parameter/argument attributes. The patch aims to step further towards encapsulating the idx+FirstArgIndex pattern to access these attributes to within the AttributeList. Patch by Daniel Neilson! Reviewers: rnk, chandlerc, pete, javed.absar, reames Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D33355 llvm-svn: 304329
Diffstat (limited to 'llvm/lib/IR/Instructions.cpp')
-rw-r--r--llvm/lib/IR/Instructions.cpp32
1 files changed, 28 insertions, 4 deletions
diff --git a/llvm/lib/IR/Instructions.cpp b/llvm/lib/IR/Instructions.cpp
index d7baa9ebc22..46c27331ff9 100644
--- a/llvm/lib/IR/Instructions.cpp
+++ b/llvm/lib/IR/Instructions.cpp
@@ -393,7 +393,17 @@ void CallInst::addAttribute(unsigned i, Attribute Attr) {
}
void CallInst::addParamAttr(unsigned ArgNo, Attribute::AttrKind Kind) {
- addAttribute(ArgNo + AttributeList::FirstArgIndex, Kind);
+ assert(ArgNo < getNumArgOperands() && "Out of bounds");
+ AttributeList PAL = getAttributes();
+ PAL = PAL.addParamAttribute(getContext(), ArgNo, Kind);
+ setAttributes(PAL);
+}
+
+void CallInst::addParamAttr(unsigned ArgNo, Attribute Attr) {
+ assert(ArgNo < getNumArgOperands() && "Out of bounds");
+ AttributeList PAL = getAttributes();
+ PAL = PAL.addParamAttribute(getContext(), ArgNo, Attr);
+ setAttributes(PAL);
}
void CallInst::removeAttribute(unsigned i, Attribute::AttrKind Kind) {
@@ -409,7 +419,17 @@ void CallInst::removeAttribute(unsigned i, StringRef Kind) {
}
void CallInst::removeParamAttr(unsigned ArgNo, Attribute::AttrKind Kind) {
- removeAttribute(ArgNo + AttributeList::FirstArgIndex, Kind);
+ assert(ArgNo < getNumArgOperands() && "Out of bounds");
+ AttributeList PAL = getAttributes();
+ PAL = PAL.removeParamAttribute(getContext(), ArgNo, Kind);
+ setAttributes(PAL);
+}
+
+void CallInst::removeParamAttr(unsigned ArgNo, StringRef Kind) {
+ assert(ArgNo < getNumArgOperands() && "Out of bounds");
+ AttributeList PAL = getAttributes();
+ PAL = PAL.removeParamAttribute(getContext(), ArgNo, Kind);
+ setAttributes(PAL);
}
void CallInst::addDereferenceableAttr(unsigned i, uint64_t Bytes) {
@@ -808,7 +828,9 @@ void InvokeInst::addAttribute(unsigned i, Attribute Attr) {
}
void InvokeInst::addParamAttr(unsigned ArgNo, Attribute::AttrKind Kind) {
- addAttribute(ArgNo + AttributeList::FirstArgIndex, Kind);
+ AttributeList PAL = getAttributes();
+ PAL = PAL.addParamAttribute(getContext(), ArgNo, Kind);
+ setAttributes(PAL);
}
void InvokeInst::removeAttribute(unsigned i, Attribute::AttrKind Kind) {
@@ -824,7 +846,9 @@ void InvokeInst::removeAttribute(unsigned i, StringRef Kind) {
}
void InvokeInst::removeParamAttr(unsigned ArgNo, Attribute::AttrKind Kind) {
- removeAttribute(ArgNo + AttributeList::FirstArgIndex, Kind);
+ AttributeList PAL = getAttributes();
+ PAL = PAL.removeParamAttribute(getContext(), ArgNo, Kind);
+ setAttributes(PAL);
}
void InvokeInst::addDereferenceableAttr(unsigned i, uint64_t Bytes) {
OpenPOWER on IntegriCloud