From 7a5a1e94609c0b28ff36fe8177181464c42702df Mon Sep 17 00:00:00 2001 From: Benjamin Kramer Date: Fri, 1 May 2020 14:18:29 +0200 Subject: [PATCH] [IR] AttributeList::getContext has a single user, remove it. --- llvm/include/llvm/IR/Attributes.h | 3 --- llvm/lib/IR/AttributeImpl.h | 6 +----- llvm/lib/IR/Attributes.cpp | 9 +++------ llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp | 10 ++++++---- 4 files changed, 10 insertions(+), 18 deletions(-) diff --git a/llvm/include/llvm/IR/Attributes.h b/llvm/include/llvm/IR/Attributes.h index 20b86ed..05c0768 100644 --- a/llvm/include/llvm/IR/Attributes.h +++ b/llvm/include/llvm/IR/Attributes.h @@ -544,9 +544,6 @@ public: // AttributeList Accessors //===--------------------------------------------------------------------===// - /// Retrieve the LLVM context. - LLVMContext &getContext() const; - /// The attributes for the specified index are returned. AttributeSet getAttributes(unsigned Index) const; diff --git a/llvm/lib/IR/AttributeImpl.h b/llvm/lib/IR/AttributeImpl.h index 94cde85..46eb4a1 100644 --- a/llvm/lib/IR/AttributeImpl.h +++ b/llvm/lib/IR/AttributeImpl.h @@ -266,7 +266,6 @@ class AttributeListImpl final friend TrailingObjects; private: - LLVMContext &Context; unsigned NumAttrSets; ///< Number of entries in this set. /// Bitset with a bit for each available attribute Attribute::AttrKind. uint8_t AvailableFunctionAttrs[12] = {}; @@ -275,15 +274,12 @@ private: size_t numTrailingObjects(OverloadToken) { return NumAttrSets; } public: - AttributeListImpl(LLVMContext &C, ArrayRef Sets); + AttributeListImpl(ArrayRef Sets); // AttributesSetImpt is uniqued, these should not be available. AttributeListImpl(const AttributeListImpl &) = delete; AttributeListImpl &operator=(const AttributeListImpl &) = delete; - /// Get the context that created this AttributeListImpl. - LLVMContext &getContext() { return Context; } - /// Return true if the AttributeSet or the FunctionIndex has an /// enum attribute of the given kind. bool hasFnAttribute(Attribute::AttrKind Kind) const { diff --git a/llvm/lib/IR/Attributes.cpp b/llvm/lib/IR/Attributes.cpp index 4ae6904..7a8068e 100644 --- a/llvm/lib/IR/Attributes.cpp +++ b/llvm/lib/IR/Attributes.cpp @@ -974,9 +974,8 @@ static constexpr unsigned attrIdxToArrayIdx(unsigned Index) { return Index == AttributeList::FunctionIndex ? 0 : Index + 1; } -AttributeListImpl::AttributeListImpl(LLVMContext &C, - ArrayRef Sets) - : Context(C), NumAttrSets(Sets.size()) { +AttributeListImpl::AttributeListImpl(ArrayRef Sets) + : NumAttrSets(Sets.size()) { assert(!Sets.empty() && "pointless AttributeListImpl"); // There's memory after the node where we can store the entries in. @@ -1035,7 +1034,7 @@ AttributeList AttributeList::getImpl(LLVMContext &C, void *Mem = pImpl->Alloc.Allocate( AttributeListImpl::totalSizeToAlloc(AttrSets.size()), alignof(AttributeListImpl)); - PA = new (Mem) AttributeListImpl(C, AttrSets); + PA = new (Mem) AttributeListImpl(AttrSets); pImpl->AttrsLists.InsertNode(PA, InsertPoint); } @@ -1360,8 +1359,6 @@ AttributeList::addAllocSizeAttr(LLVMContext &C, unsigned Index, // AttributeList Accessor Methods //===----------------------------------------------------------------------===// -LLVMContext &AttributeList::getContext() const { return pImpl->getContext(); } - AttributeSet AttributeList::getParamAttributes(unsigned ArgNo) const { return getAttributes(ArgNo + FirstArgIndex); } diff --git a/llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp b/llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp index 652baa5..482c43e 100644 --- a/llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp +++ b/llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp @@ -1260,7 +1260,8 @@ normalizeForInvokeSafepoint(BasicBlock *BB, BasicBlock *InvokeParent, // Create new attribute set containing only attributes which can be transferred // from original call to the safepoint. -static AttributeList legalizeCallAttributes(AttributeList AL) { +static AttributeList legalizeCallAttributes(LLVMContext &Ctx, + AttributeList AL) { if (AL.isEmpty()) return AL; @@ -1274,7 +1275,6 @@ static AttributeList legalizeCallAttributes(AttributeList AL) { } // Just skip parameter and return attributes for now - LLVMContext &Ctx = AL.getContext(); return AttributeList::get(Ctx, AttributeList::FunctionIndex, AttributeSet::get(Ctx, FnAttrs)); } @@ -1520,7 +1520,8 @@ makeStatepointExplicitImpl(CallBase *Call, /* to replace */ // function attributes. In case if we can handle this set of attributes - // set up function attrs directly on statepoint and return attrs later for // gc_result intrinsic. - SPCall->setAttributes(legalizeCallAttributes(CI->getAttributes())); + SPCall->setAttributes( + legalizeCallAttributes(CI->getContext(), CI->getAttributes())); Token = SPCall; @@ -1546,7 +1547,8 @@ makeStatepointExplicitImpl(CallBase *Call, /* to replace */ // function attributes. In case if we can handle this set of attributes - // set up function attrs directly on statepoint and return attrs later for // gc_result intrinsic. - SPInvoke->setAttributes(legalizeCallAttributes(II->getAttributes())); + SPInvoke->setAttributes( + legalizeCallAttributes(II->getContext(), II->getAttributes())); Token = SPInvoke; -- 2.7.4