[IR] AttributeList::getContext has a single user, remove it.
authorBenjamin Kramer <benny.kra@googlemail.com>
Fri, 1 May 2020 12:18:29 +0000 (14:18 +0200)
committerBenjamin Kramer <benny.kra@googlemail.com>
Fri, 1 May 2020 12:18:29 +0000 (14:18 +0200)
llvm/include/llvm/IR/Attributes.h
llvm/lib/IR/AttributeImpl.h
llvm/lib/IR/Attributes.cpp
llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp

index 20b86ed..05c0768 100644 (file)
@@ -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;
 
index 94cde85..46eb4a1 100644 (file)
@@ -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<AttributeSet>) { return NumAttrSets; }
 
 public:
-  AttributeListImpl(LLVMContext &C, ArrayRef<AttributeSet> Sets);
+  AttributeListImpl(ArrayRef<AttributeSet> 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 {
index 4ae6904..7a8068e 100644 (file)
@@ -974,9 +974,8 @@ static constexpr unsigned attrIdxToArrayIdx(unsigned Index) {
   return Index == AttributeList::FunctionIndex ? 0 : Index + 1;
 }
 
-AttributeListImpl::AttributeListImpl(LLVMContext &C,
-                                     ArrayRef<AttributeSet> Sets)
-    : Context(C), NumAttrSets(Sets.size()) {
+AttributeListImpl::AttributeListImpl(ArrayRef<AttributeSet> 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<AttributeSet>(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);
 }
index 652baa5..482c43e 100644 (file)
@@ -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;