diff options
author | Reid Kleckner <rnk@google.com> | 2017-04-10 23:46:08 +0000 |
---|---|---|
committer | Reid Kleckner <rnk@google.com> | 2017-04-10 23:46:08 +0000 |
commit | 8ff7785ee19a86289804de9fc1727f799f784f16 (patch) | |
tree | e99dce0b5b9f47a6c143db3e83abdc420114923f /llvm/lib/IR | |
parent | eb9dd5b87f43cbd9641fba0555b775589e49af33 (diff) | |
download | bcm5719-llvm-8ff7785ee19a86289804de9fc1727f799f784f16.tar.gz bcm5719-llvm-8ff7785ee19a86289804de9fc1727f799f784f16.zip |
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
Diffstat (limited to 'llvm/lib/IR')
-rw-r--r-- | llvm/lib/IR/Attributes.cpp | 14 | ||||
-rw-r--r-- | llvm/lib/IR/Core.cpp | 8 |
2 files changed, 18 insertions, 4 deletions
diff --git a/llvm/lib/IR/Attributes.cpp b/llvm/lib/IR/Attributes.cpp index 0cdc48e2d64..158a02337ad 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<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()) diff --git a/llvm/lib/IR/Core.cpp b/llvm/lib/IR/Core.cpp index f1843593a3b..2636ca1a724 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<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())) |