aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBill Wendling <isanbard@gmail.com>2013-01-27 23:41:29 +0000
committerBill Wendling <isanbard@gmail.com>2013-01-27 23:41:29 +0000
commitd05204aea4977eaec25e96bc7605a7bb9d806fc0 (patch)
tree45de322cc717d8d239c4d81686520f55e4fd84e0
parent2d5be6c313c0f9e23e56620fa8f8ae8d9b539bf0 (diff)
Push the calculation of the 'Raw' attribute mask down into the implementation. It in turn uses the correct list for calculating the 'Raw' value.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@173637 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/llvm/IR/Attributes.h5
-rw-r--r--lib/IR/AttributeImpl.h3
-rw-r--r--lib/IR/Attributes.cpp31
3 files changed, 29 insertions, 10 deletions
diff --git a/include/llvm/IR/Attributes.h b/include/llvm/IR/Attributes.h
index 5eca5d6d08..297abb9648 100644
--- a/include/llvm/IR/Attributes.h
+++ b/include/llvm/IR/Attributes.h
@@ -234,7 +234,10 @@ private:
public:
AttributeSet() : pImpl(0) {}
AttributeSet(const AttributeSet &P) : pImpl(P.pImpl) {}
- const AttributeSet &operator=(const AttributeSet &RHS);
+ const AttributeSet &operator=(const AttributeSet &RHS) {
+ pImpl = RHS.pImpl;
+ return *this;
+ }
//===--------------------------------------------------------------------===//
// Attribute List Construction and Mutation
diff --git a/lib/IR/AttributeImpl.h b/lib/IR/AttributeImpl.h
index b4fb0c0aa6..babc14e1fa 100644
--- a/lib/IR/AttributeImpl.h
+++ b/lib/IR/AttributeImpl.h
@@ -165,6 +165,9 @@ public:
ID.AddPointer(Nodes[i].second);
}
}
+
+ // FIXME: This atrocity is temporary.
+ uint64_t Raw(uint64_t Index) const;
};
} // end llvm namespace
diff --git a/lib/IR/Attributes.cpp b/lib/IR/Attributes.cpp
index 1b057bbbb9..81390f0bc1 100644
--- a/lib/IR/Attributes.cpp
+++ b/lib/IR/Attributes.cpp
@@ -574,6 +574,24 @@ AttributeSetImpl(LLVMContext &C,
#endif
}
+uint64_t AttributeSetImpl::Raw(uint64_t Index) const {
+ for (unsigned I = 0, E = getNumAttributes(); I != E; ++I) {
+ if (getSlotIndex(I) != Index) continue;
+ const AttributeSetNode *ASN = AttrNodes[I].second;
+ AttrBuilder B;
+
+ for (AttributeSetNode::const_iterator II = ASN->begin(),
+ IE = ASN->end(); II != IE; ++II)
+ B.addAttributes(*II);
+
+ assert(B.Raw() == AttrList[I].Attrs.Raw() &&
+ "Attributes aren't the same!");
+ return B.Raw();
+ }
+
+ return 0;
+}
+
//===----------------------------------------------------------------------===//
// AttributeSet Method Implementations
//===----------------------------------------------------------------------===//
@@ -669,14 +687,9 @@ AttributeSet AttributeSet::get(LLVMContext &C, ArrayRef<AttributeSet> Attrs) {
return get(C, AttrList);
}
-const AttributeSet &AttributeSet::operator=(const AttributeSet &RHS) {
- pImpl = RHS.pImpl;
- return *this;
-}
-
-/// getNumSlots - Return the number of slots used in this attribute list.
-/// This is the number of arguments that have an attribute set on them
-/// (including the function itself).
+/// \brief Return the number of slots used in this attribute list. This is the
+/// number of arguments that have an attribute set on them (including the
+/// function itself).
unsigned AttributeSet::getNumSlots() const {
return pImpl ? pImpl->getNumAttributes() : 0;
}
@@ -715,7 +728,7 @@ unsigned AttributeSet::getStackAlignment(unsigned Index) const {
uint64_t AttributeSet::Raw(unsigned Index) const {
// FIXME: Remove this.
- return getAttributes(Index).Raw();
+ return pImpl ? pImpl->Raw(Index) : 0;
}
/// getAttributes - The attributes for the specified index are returned.