OSDN Git Service

Remove AttributeSetNode::get(AttributeList, unsigned) and sink constructor
authorReid Kleckner <rnk@google.com>
Mon, 10 Apr 2017 23:46:08 +0000 (23:46 +0000)
committerReid Kleckner <rnk@google.com>
Mon, 10 Apr 2017 23:46:08 +0000 (23:46 +0000)
The getter was equivalent to AttributeList::getAttributes(unsigned),
which seems like a better way to express getting the AttributeSet for a
given index. This static helper was only used in one place anyway.

The constructor doesn't benefit from inlining and doesn't need to be in
a header.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@299900 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/IR/AttributeSetNode.h
lib/IR/Attributes.cpp
lib/IR/Core.cpp

index 8a5bb3f..7dcb9f6 100644 (file)
@@ -43,19 +43,7 @@ class AttributeSetNode final
   /// Bitset with a bit for each available attribute Attribute::AttrKind.
   uint64_t AvailableAttrs;
 
-  AttributeSetNode(ArrayRef<Attribute> Attrs)
-    : NumAttrs(Attrs.size()), AvailableAttrs(0) {
-    static_assert(Attribute::EndAttrKinds <= sizeof(AvailableAttrs) * CHAR_BIT,
-                  "Too many attributes for AvailableAttrs");
-    // There's memory after the node where we can store the entries in.
-    std::copy(Attrs.begin(), Attrs.end(), getTrailingObjects<Attribute>());
-
-    for (Attribute I : *this) {
-      if (!I.isStringAttribute()) {
-        AvailableAttrs |= ((uint64_t)1) << I.getKindAsEnum();
-      }
-    }
-  }
+  AttributeSetNode(ArrayRef<Attribute> Attrs);
 
 public:
   // AttributesSetNode is uniqued, these should not be available.
@@ -68,10 +56,6 @@ public:
 
   static AttributeSetNode *get(LLVMContext &C, ArrayRef<Attribute> Attrs);
 
-  static AttributeSetNode *get(AttributeList AS, unsigned Index) {
-    return AS.getAttributes(Index);
-  }
-
   /// \brief Return the number of attributes this AttributeList contains.
   unsigned getNumAttributes() const { return NumAttrs; }
 
index 0cdc48e..158a023 100644 (file)
@@ -495,6 +495,20 @@ bool AttributeImpl::operator<(const AttributeImpl &AI) const {
 // AttributeSetNode Definition
 //===----------------------------------------------------------------------===//
 
+AttributeSetNode::AttributeSetNode(ArrayRef<Attribute> Attrs)
+    : NumAttrs(Attrs.size()), AvailableAttrs(0) {
+  static_assert(Attribute::EndAttrKinds <= sizeof(AvailableAttrs) * CHAR_BIT,
+                "Too many attributes for AvailableAttrs");
+  // There's memory after the node where we can store the entries in.
+  std::copy(Attrs.begin(), Attrs.end(), getTrailingObjects<Attribute>());
+
+  for (Attribute I : *this) {
+    if (!I.isStringAttribute()) {
+      AvailableAttrs |= ((uint64_t)1) << I.getKindAsEnum();
+    }
+  }
+}
+
 AttributeSetNode *AttributeSetNode::get(LLVMContext &C,
                                         ArrayRef<Attribute> Attrs) {
   if (Attrs.empty())
index f184359..2636ca1 100644 (file)
@@ -1847,7 +1847,7 @@ void LLVMAddAttributeAtIndex(LLVMValueRef F, LLVMAttributeIndex Idx,
 }
 
 unsigned LLVMGetAttributeCountAtIndex(LLVMValueRef F, LLVMAttributeIndex Idx) {
-  auto *ASN = AttributeSetNode::get(unwrap<Function>(F)->getAttributes(), Idx);
+  auto *ASN = unwrap<Function>(F)->getAttributes().getAttributes(Idx);
   if (!ASN)
     return 0;
   return ASN->getNumAttributes();
@@ -1855,7 +1855,7 @@ unsigned LLVMGetAttributeCountAtIndex(LLVMValueRef F, LLVMAttributeIndex Idx) {
 
 void LLVMGetAttributesAtIndex(LLVMValueRef F, LLVMAttributeIndex Idx,
                               LLVMAttributeRef *Attrs) {
-  auto *ASN = AttributeSetNode::get(unwrap<Function>(F)->getAttributes(), Idx);
+  auto *ASN = unwrap<Function>(F)->getAttributes().getAttributes(Idx);
   if (!ASN)
     return;
   for (auto A: make_range(ASN->begin(), ASN->end()))
@@ -2178,7 +2178,7 @@ void LLVMAddCallSiteAttribute(LLVMValueRef C, LLVMAttributeIndex Idx,
 unsigned LLVMGetCallSiteAttributeCount(LLVMValueRef C,
                                        LLVMAttributeIndex Idx) {
   auto CS = CallSite(unwrap<Instruction>(C));
-  auto *ASN = AttributeSetNode::get(CS.getAttributes(), Idx);
+  auto *ASN = CS.getAttributes().getAttributes(Idx);
   if (!ASN)
     return 0;
   return ASN->getNumAttributes();
@@ -2187,7 +2187,7 @@ unsigned LLVMGetCallSiteAttributeCount(LLVMValueRef C,
 void LLVMGetCallSiteAttributes(LLVMValueRef C, LLVMAttributeIndex Idx,
                                LLVMAttributeRef *Attrs) {
   auto CS = CallSite(unwrap<Instruction>(C));
-  auto *ASN = AttributeSetNode::get(CS.getAttributes(), Idx);
+  auto *ASN = CS.getAttributes().getAttributes(Idx);
   if (!ASN)
     return;
   for (auto A: make_range(ASN->begin(), ASN->end()))