From 8ff7785ee19a86289804de9fc1727f799f784f16 Mon Sep 17 00:00:00 2001 From: Reid Kleckner Date: Mon, 10 Apr 2017 23:46:08 +0000 Subject: [PATCH] Remove AttributeSetNode::get(AttributeList, unsigned) and sink constructor 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. llvm-svn: 299900 --- llvm/include/llvm/IR/AttributeSetNode.h | 18 +----------------- llvm/lib/IR/Attributes.cpp | 14 ++++++++++++++ llvm/lib/IR/Core.cpp | 8 ++++---- 3 files changed, 19 insertions(+), 21 deletions(-) diff --git a/llvm/include/llvm/IR/AttributeSetNode.h b/llvm/include/llvm/IR/AttributeSetNode.h index 8a5bb3f475c5..7dcb9f67d715 100644 --- a/llvm/include/llvm/IR/AttributeSetNode.h +++ b/llvm/include/llvm/IR/AttributeSetNode.h @@ -43,19 +43,7 @@ class AttributeSetNode final /// Bitset with a bit for each available attribute Attribute::AttrKind. uint64_t AvailableAttrs; - AttributeSetNode(ArrayRef 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()); - - for (Attribute I : *this) { - if (!I.isStringAttribute()) { - AvailableAttrs |= ((uint64_t)1) << I.getKindAsEnum(); - } - } - } + AttributeSetNode(ArrayRef Attrs); public: // AttributesSetNode is uniqued, these should not be available. @@ -68,10 +56,6 @@ public: static AttributeSetNode *get(LLVMContext &C, ArrayRef 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; } diff --git a/llvm/lib/IR/Attributes.cpp b/llvm/lib/IR/Attributes.cpp index 0cdc48e2d647..158a02337ad1 100644 --- a/llvm/lib/IR/Attributes.cpp +++ b/llvm/lib/IR/Attributes.cpp @@ -495,6 +495,20 @@ bool AttributeImpl::operator<(const AttributeImpl &AI) const { // AttributeSetNode Definition //===----------------------------------------------------------------------===// +AttributeSetNode::AttributeSetNode(ArrayRef 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()); + + for (Attribute I : *this) { + if (!I.isStringAttribute()) { + AvailableAttrs |= ((uint64_t)1) << I.getKindAsEnum(); + } + } +} + AttributeSetNode *AttributeSetNode::get(LLVMContext &C, ArrayRef Attrs) { if (Attrs.empty()) diff --git a/llvm/lib/IR/Core.cpp b/llvm/lib/IR/Core.cpp index f1843593a3bf..2636ca1a724e 100644 --- a/llvm/lib/IR/Core.cpp +++ b/llvm/lib/IR/Core.cpp @@ -1847,7 +1847,7 @@ void LLVMAddAttributeAtIndex(LLVMValueRef F, LLVMAttributeIndex Idx, } unsigned LLVMGetAttributeCountAtIndex(LLVMValueRef F, LLVMAttributeIndex Idx) { - auto *ASN = AttributeSetNode::get(unwrap(F)->getAttributes(), Idx); + auto *ASN = unwrap(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(F)->getAttributes(), Idx); + auto *ASN = unwrap(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(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(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()))