[llvm] r299900 - Remove AttributeSetNode::get(AttributeList, unsigned) and sink constructor
Reid Kleckner via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 10 16:46:09 PDT 2017
Author: rnk
Date: Mon Apr 10 18:46:08 2017
New Revision: 299900
URL: http://llvm.org/viewvc/llvm-project?rev=299900&view=rev
Log:
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.
Modified:
llvm/trunk/include/llvm/IR/AttributeSetNode.h
llvm/trunk/lib/IR/Attributes.cpp
llvm/trunk/lib/IR/Core.cpp
Modified: llvm/trunk/include/llvm/IR/AttributeSetNode.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/AttributeSetNode.h?rev=299900&r1=299899&r2=299900&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/AttributeSetNode.h (original)
+++ llvm/trunk/include/llvm/IR/AttributeSetNode.h Mon Apr 10 18:46:08 2017
@@ -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; }
Modified: llvm/trunk/lib/IR/Attributes.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Attributes.cpp?rev=299900&r1=299899&r2=299900&view=diff
==============================================================================
--- llvm/trunk/lib/IR/Attributes.cpp (original)
+++ llvm/trunk/lib/IR/Attributes.cpp Mon Apr 10 18:46:08 2017
@@ -495,6 +495,20 @@ bool AttributeImpl::operator<(const Attr
// 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())
Modified: llvm/trunk/lib/IR/Core.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Core.cpp?rev=299900&r1=299899&r2=299900&view=diff
==============================================================================
--- llvm/trunk/lib/IR/Core.cpp (original)
+++ llvm/trunk/lib/IR/Core.cpp Mon Apr 10 18:46:08 2017
@@ -1847,7 +1847,7 @@ void LLVMAddAttributeAtIndex(LLVMValueRe
}
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(LL
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(LLVMValueR
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(L
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()))
More information about the llvm-commits
mailing list