From 331cfc53febc3f9b7e987070567a04a839bc2dc3 Mon Sep 17 00:00:00 2001 From: Arthur Eubanks Date: Thu, 19 Aug 2021 14:41:25 -0700 Subject: [PATCH] [NFC] Simplify some CallBase attribute methods --- llvm/include/llvm/IR/InstrTypes.h | 70 +++++++++---------------------- 1 file changed, 19 insertions(+), 51 deletions(-) diff --git a/llvm/include/llvm/IR/InstrTypes.h b/llvm/include/llvm/IR/InstrTypes.h index ed4fa878b2b1..4b0608d38260 100644 --- a/llvm/include/llvm/IR/InstrTypes.h +++ b/llvm/include/llvm/IR/InstrTypes.h @@ -1487,16 +1487,12 @@ public: /// adds the attribute to the list of attributes. void addAttribute(unsigned i, Attribute::AttrKind Kind) { - AttributeList PAL = getAttributes(); - PAL = PAL.addAttribute(getContext(), i, Kind); - setAttributes(PAL); + Attrs = Attrs.addAttribute(getContext(), i, Kind); } /// adds the attribute to the list of attributes. void addAttribute(unsigned i, Attribute Attr) { - AttributeList PAL = getAttributes(); - PAL = PAL.addAttribute(getContext(), i, Attr); - setAttributes(PAL); + Attrs = Attrs.addAttribute(getContext(), i, Attr); } /// Adds the attribute to the function. @@ -1522,104 +1518,76 @@ public: /// Adds the attribute to the indicated argument void addParamAttr(unsigned ArgNo, Attribute::AttrKind Kind) { assert(ArgNo < getNumArgOperands() && "Out of bounds"); - AttributeList PAL = getAttributes(); - PAL = PAL.addParamAttribute(getContext(), ArgNo, Kind); - setAttributes(PAL); + Attrs = Attrs.addParamAttribute(getContext(), ArgNo, Kind); } /// Adds the attribute to the indicated argument void addParamAttr(unsigned ArgNo, Attribute Attr) { assert(ArgNo < getNumArgOperands() && "Out of bounds"); - AttributeList PAL = getAttributes(); - PAL = PAL.addParamAttribute(getContext(), ArgNo, Attr); - setAttributes(PAL); + Attrs = Attrs.addParamAttribute(getContext(), ArgNo, Attr); } /// removes the attribute from the list of attributes. void removeAttribute(unsigned i, Attribute::AttrKind Kind) { - AttributeList PAL = getAttributes(); - PAL = PAL.removeAttribute(getContext(), i, Kind); - setAttributes(PAL); + Attrs = Attrs.removeAttribute(getContext(), i, Kind); } /// removes the attribute from the list of attributes. void removeAttribute(unsigned i, StringRef Kind) { - AttributeList PAL = getAttributes(); - PAL = PAL.removeAttribute(getContext(), i, Kind); - setAttributes(PAL); + Attrs = Attrs.removeAttribute(getContext(), i, Kind); } /// Removes the attributes from the function - void removeFnAttrs(const AttrBuilder &Attrs) { - AttributeList PAL = getAttributes(); - PAL = PAL.removeFnAttributes(getContext(), Attrs); - setAttributes(PAL); + void removeFnAttrs(const AttrBuilder &AttrsToRemove) { + Attrs = Attrs.removeFnAttributes(getContext(), AttrsToRemove); } /// Removes the attribute from the function void removeFnAttr(Attribute::AttrKind Kind) { - AttributeList PAL = getAttributes(); - PAL = PAL.removeFnAttribute(getContext(), Kind); - setAttributes(PAL); + Attrs = Attrs.removeFnAttribute(getContext(), Kind); } /// Removes the attribute from the return value void removeRetAttr(Attribute::AttrKind Kind) { - AttributeList PAL = getAttributes(); - PAL = PAL.removeRetAttribute(getContext(), Kind); - setAttributes(PAL); + Attrs = Attrs.removeRetAttribute(getContext(), Kind); } /// Removes the attributes from the return value - void removeRetAttrs(const AttrBuilder &Attrs) { - AttributeList PAL = getAttributes(); - PAL = PAL.removeRetAttributes(getContext(), Attrs); - setAttributes(PAL); + void removeRetAttrs(const AttrBuilder &AttrsToRemove) { + Attrs = Attrs.removeRetAttributes(getContext(), AttrsToRemove); } /// Removes the attribute from the given argument void removeParamAttr(unsigned ArgNo, Attribute::AttrKind Kind) { assert(ArgNo < getNumArgOperands() && "Out of bounds"); - AttributeList PAL = getAttributes(); - PAL = PAL.removeParamAttribute(getContext(), ArgNo, Kind); - setAttributes(PAL); + Attrs = Attrs.removeParamAttribute(getContext(), ArgNo, Kind); } /// Removes the attribute from the given argument void removeParamAttr(unsigned ArgNo, StringRef Kind) { assert(ArgNo < getNumArgOperands() && "Out of bounds"); - AttributeList PAL = getAttributes(); - PAL = PAL.removeParamAttribute(getContext(), ArgNo, Kind); - setAttributes(PAL); + Attrs = Attrs.removeParamAttribute(getContext(), ArgNo, Kind); } /// Removes the attributes from the given argument - void removeParamAttrs(unsigned ArgNo, const AttrBuilder &Attrs) { - AttributeList PAL = getAttributes(); - PAL = PAL.removeParamAttributes(getContext(), ArgNo, Attrs); - setAttributes(PAL); + void removeParamAttrs(unsigned ArgNo, const AttrBuilder &AttrsToRemove) { + Attrs = Attrs.removeParamAttributes(getContext(), ArgNo, AttrsToRemove); } /// adds the dereferenceable attribute to the list of attributes. void addDereferenceableParamAttr(unsigned i, uint64_t Bytes) { - AttributeList PAL = getAttributes(); - PAL = PAL.addDereferenceableParamAttr(getContext(), i, Bytes); - setAttributes(PAL); + Attrs = Attrs.addDereferenceableParamAttr(getContext(), i, Bytes); } /// adds the dereferenceable attribute to the list of attributes. void addDereferenceableRetAttr(uint64_t Bytes) { - AttributeList PAL = getAttributes(); - PAL = PAL.addDereferenceableRetAttr(getContext(), Bytes); - setAttributes(PAL); + Attrs = Attrs.addDereferenceableRetAttr(getContext(), Bytes); } /// adds the dereferenceable_or_null attribute to the list of /// attributes. void addDereferenceableOrNullAttr(unsigned i, uint64_t Bytes) { - AttributeList PAL = getAttributes(); - PAL = PAL.addDereferenceableOrNullAttr(getContext(), i, Bytes); - setAttributes(PAL); + Attrs = Attrs.addDereferenceableOrNullAttr(getContext(), i, Bytes); } /// Determine whether the return value has the given attribute.