Extend function attributes bitset size from 64 to 96.
Summary: We are going to add a function attribute number 64.
Reviewers: pcc, jdoerfert, lebedev.ri
Subscribers: hiraditya, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D64663
llvm-svn: 365980
diff --git a/llvm/lib/IR/Attributes.cpp b/llvm/lib/IR/Attributes.cpp
index 90b3c22..1ba703b 100644
--- a/llvm/lib/IR/Attributes.cpp
+++ b/llvm/lib/IR/Attributes.cpp
@@ -718,13 +718,18 @@
//===----------------------------------------------------------------------===//
AttributeSetNode::AttributeSetNode(ArrayRef<Attribute> Attrs)
- : AvailableAttrs(0), NumAttrs(Attrs.size()) {
+ : NumAttrs(Attrs.size()) {
// There's memory after the node where we can store the entries in.
llvm::copy(Attrs, getTrailingObjects<Attribute>());
+ static_assert(Attribute::EndAttrKinds <=
+ sizeof(AvailableAttrs) * CHAR_BIT,
+ "Too many attributes");
+
for (const auto I : *this) {
if (!I.isStringAttribute()) {
- AvailableAttrs |= ((uint64_t)1) << I.getKindAsEnum();
+ Attribute::AttrKind Kind = I.getKindAsEnum();
+ AvailableAttrs[Kind / 8] |= 1ULL << (Kind % 8);
}
}
}
@@ -896,7 +901,7 @@
AttributeListImpl::AttributeListImpl(LLVMContext &C,
ArrayRef<AttributeSet> Sets)
- : AvailableFunctionAttrs(0), Context(C), NumAttrSets(Sets.size()) {
+ : Context(C), NumAttrSets(Sets.size()) {
assert(!Sets.empty() && "pointless AttributeListImpl");
// There's memory after the node where we can store the entries in.
@@ -909,8 +914,10 @@
static_assert(attrIdxToArrayIdx(AttributeList::FunctionIndex) == 0U,
"function should be stored in slot 0");
for (const auto I : Sets[0]) {
- if (!I.isStringAttribute())
- AvailableFunctionAttrs |= 1ULL << I.getKindAsEnum();
+ if (!I.isStringAttribute()) {
+ Attribute::AttrKind Kind = I.getKindAsEnum();
+ AvailableFunctionAttrs[Kind / 8] |= 1ULL << (Kind % 8);
+ }
}
}