diff --git a/llvm/include/llvm/IR/Attributes.h b/llvm/include/llvm/IR/Attributes.h --- a/llvm/include/llvm/IR/Attributes.h +++ b/llvm/include/llvm/IR/Attributes.h @@ -1016,53 +1016,9 @@ return MaybeAlign(getRawIntAttr(Attribute::Alignment)); } - /// Retrieve the stack alignment attribute, if it exists. - MaybeAlign getStackAlignment() const { - return MaybeAlign(getRawIntAttr(Attribute::StackAlignment)); - } - - /// Retrieve the number of dereferenceable bytes, if the - /// dereferenceable attribute exists (zero is returned otherwise). - uint64_t getDereferenceableBytes() const { - return getRawIntAttr(Attribute::Dereferenceable); - } - - /// Retrieve the number of dereferenceable_or_null bytes, if the - /// dereferenceable_or_null attribute exists (zero is returned otherwise). - uint64_t getDereferenceableOrNullBytes() const { - return getRawIntAttr(Attribute::DereferenceableOrNull); - } - /// Retrieve type for the given type attribute. Type *getTypeAttr(Attribute::AttrKind Kind) const; - /// Retrieve the byval type. - Type *getByValType() const { return getTypeAttr(Attribute::ByVal); } - - /// Retrieve the sret type. - Type *getStructRetType() const { return getTypeAttr(Attribute::StructRet); } - - /// Retrieve the byref type. - Type *getByRefType() const { return getTypeAttr(Attribute::ByRef); } - - /// Retrieve the preallocated type. - Type *getPreallocatedType() const { - return getTypeAttr(Attribute::Preallocated); - } - - /// Retrieve the inalloca type. - Type *getInAllocaType() const { return getTypeAttr(Attribute::InAlloca); } - - /// Retrieve the allocsize args, if the allocsize attribute exists. If it - /// doesn't exist, pair(0, 0) is returned. - std::pair> getAllocSizeArgs() const; - - /// Retrieve the minimum value of 'vscale_range'. - unsigned getVScaleRangeMin() const; - - /// Retrieve the maximum value of 'vscale_range' or None when unknown. - Optional getVScaleRangeMax() const; - /// Add integer attribute with raw value (packed/encoded if necessary). AttrBuilder &addRawIntAttr(Attribute::AttrKind Kind, uint64_t Value); diff --git a/llvm/lib/IR/Attributes.cpp b/llvm/lib/IR/Attributes.cpp --- a/llvm/lib/IR/Attributes.cpp +++ b/llvm/lib/IR/Attributes.cpp @@ -1637,18 +1637,6 @@ return *this; } -std::pair> AttrBuilder::getAllocSizeArgs() const { - return unpackAllocSizeArgs(getRawIntAttr(Attribute::AllocSize)); -} - -unsigned AttrBuilder::getVScaleRangeMin() const { - return unpackVScaleRangeArgs(getRawIntAttr(Attribute::VScaleRange)).first; -} - -Optional AttrBuilder::getVScaleRangeMax() const { - return unpackVScaleRangeArgs(getRawIntAttr(Attribute::VScaleRange)).second; -} - AttrBuilder &AttrBuilder::addAlignmentAttr(MaybeAlign Align) { if (!Align) return *this; diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp --- a/llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp +++ b/llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp @@ -553,12 +553,12 @@ ArgAttributes.push_back(InvokeAL.getParamAttrs(I)); AttrBuilder FnAttrs(InvokeAL.getFnAttrs()); - if (FnAttrs.contains(Attribute::AllocSize)) { + if (InvokeAL.getFnAttrs().hasAttribute(Attribute::AllocSize)) { // The allocsize attribute (if any) referes to parameters by index and needs // to be adjusted. unsigned SizeArg; Optional NEltArg; - std::tie(SizeArg, NEltArg) = FnAttrs.getAllocSizeArgs(); + std::tie(SizeArg, NEltArg) = InvokeAL.getFnAttrs().getAllocSizeArgs(); SizeArg += 1; if (NEltArg.hasValue()) NEltArg = NEltArg.getValue() + 1; diff --git a/llvm/lib/Transforms/Utils/CallPromotionUtils.cpp b/llvm/lib/Transforms/Utils/CallPromotionUtils.cpp --- a/llvm/lib/Transforms/Utils/CallPromotionUtils.cpp +++ b/llvm/lib/Transforms/Utils/CallPromotionUtils.cpp @@ -504,9 +504,9 @@ ArgAttrs.remove(AttributeFuncs::typeIncompatible(FormalTy)); // We may have a different byval/inalloca type. - if (ArgAttrs.getByValType()) + if (CallerPAL.getParamAttrs(ArgNo).getByValType()) ArgAttrs.addByValAttr(Callee->getParamByValType(ArgNo)); - if (ArgAttrs.getInAllocaType()) + if (CallerPAL.getParamAttrs(ArgNo).getInAllocaType()) ArgAttrs.addInAllocaAttr(Callee->getParamInAllocaType(ArgNo)); NewArgAttrs.push_back(AttributeSet::get(Ctx, ArgAttrs)); diff --git a/llvm/lib/Transforms/Utils/InlineFunction.cpp b/llvm/lib/Transforms/Utils/InlineFunction.cpp --- a/llvm/lib/Transforms/Utils/InlineFunction.cpp +++ b/llvm/lib/Transforms/Utils/InlineFunction.cpp @@ -1184,21 +1184,20 @@ } static AttrBuilder IdentifyValidAttributes(CallBase &CB) { - - AttrBuilder AB(CB.getAttributes(), AttributeList::ReturnIndex); - if (AB.empty()) - return AB; + auto Attrs = CB.getAttributes().getRetAttrs(); AttrBuilder Valid; + if (!Attrs.hasAttributes()) + return Valid; // Only allow these white listed attributes to be propagated back to the // callee. This is because other attributes may only be valid on the call // itself, i.e. attributes such as signext and zeroext. - if (auto DerefBytes = AB.getDereferenceableBytes()) + if (auto DerefBytes = Attrs.getDereferenceableBytes()) Valid.addDereferenceableAttr(DerefBytes); - if (auto DerefOrNullBytes = AB.getDereferenceableOrNullBytes()) + if (auto DerefOrNullBytes = Attrs.getDereferenceableOrNullBytes()) Valid.addDereferenceableOrNullAttr(DerefOrNullBytes); - if (AB.contains(Attribute::NoAlias)) + if (Attrs.hasAttribute(Attribute::NoAlias)) Valid.addAttribute(Attribute::NoAlias); - if (AB.contains(Attribute::NonNull)) + if (Attrs.hasAttribute(Attribute::NonNull)) Valid.addAttribute(Attribute::NonNull); return Valid; }