From 8e189381a8c70442583bf825bc9d1ad622ff648f Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Thu, 24 Jan 2013 01:01:34 +0000 Subject: [PATCH] Add a profile for uniquifying the AttributeSet with the AttributeSetNodes. llvm-svn: 173313 --- include/llvm/IR/Attributes.h | 4 +++- lib/IR/AttributeImpl.h | 15 ++++++++++++++- lib/IR/Attributes.cpp | 5 ----- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/include/llvm/IR/Attributes.h b/include/llvm/IR/Attributes.h index 6ff033715db..30129b45cb6 100644 --- a/include/llvm/IR/Attributes.h +++ b/include/llvm/IR/Attributes.h @@ -132,7 +132,9 @@ public: bool operator<(Attribute A) const; - void Profile(FoldingSetNodeID &ID) const; + void Profile(FoldingSetNodeID &ID) const { + ID.AddPointer(pImpl); + } // FIXME: Remove these 'operator' methods. bool operator==(const Attribute &A) const { diff --git a/lib/IR/AttributeImpl.h b/lib/IR/AttributeImpl.h index b02cc8bdefe..b35e5e0f0b3 100644 --- a/lib/IR/AttributeImpl.h +++ b/lib/IR/AttributeImpl.h @@ -107,12 +107,17 @@ class AttributeSetImpl : public FoldingSetNode { LLVMContext &Context; SmallVector AttrList; + SmallVector, 4> AttrNodes; + // AttributesSet is uniqued, these should not be publicly available. void operator=(const AttributeSetImpl &) LLVM_DELETED_FUNCTION; AttributeSetImpl(const AttributeSetImpl &) LLVM_DELETED_FUNCTION; public: AttributeSetImpl(LLVMContext &C, ArrayRef attrs) : Context(C), AttrList(attrs.begin(), attrs.end()) {} + AttributeSetImpl(LLVMContext &C, + ArrayRef > attrs) + : Context(C), AttrNodes(attrs.begin(), attrs.end()) {} LLVMContext &getContext() { return Context; } ArrayRef getAttributes() const { return AttrList; } @@ -122,12 +127,20 @@ public: Profile(ID, AttrList); } static void Profile(FoldingSetNodeID &ID, - ArrayRef AttrList){ + ArrayRef AttrList) { for (unsigned i = 0, e = AttrList.size(); i != e; ++i) { ID.AddInteger(AttrList[i].Index); ID.AddInteger(AttrList[i].Attrs.Raw()); } } + + static void Profile(FoldingSetNodeID &ID, + ArrayRef > Nodes) { + for (unsigned i = 0, e = Nodes.size(); i != e; ++i) { + ID.AddInteger(Nodes[i].first); + ID.AddPointer(Nodes[i].second); + } + } }; } // end llvm namespace diff --git a/lib/IR/Attributes.cpp b/lib/IR/Attributes.cpp index 8623b98b9f6..8ee7057c196 100644 --- a/lib/IR/Attributes.cpp +++ b/lib/IR/Attributes.cpp @@ -99,11 +99,6 @@ bool Attribute::operator<(Attribute A) const { return *pImpl < *A.pImpl; } - -void Attribute::Profile(FoldingSetNodeID &ID) const { - ID.AddPointer(pImpl); -} - uint64_t Attribute::Raw() const { return pImpl ? pImpl->Raw() : 0; }