Add a profile for uniquifying the AttributeSet with the AttributeSetNodes.
authorBill Wendling <isanbard@gmail.com>
Thu, 24 Jan 2013 01:01:34 +0000 (01:01 +0000)
committerBill Wendling <isanbard@gmail.com>
Thu, 24 Jan 2013 01:01:34 +0000 (01:01 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@173313 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/IR/Attributes.h
lib/IR/AttributeImpl.h
lib/IR/Attributes.cpp

index 6ff033715dba959c83a06a568bc456e9c4cd8989..30129b45cb6cdf56761fc15eef214188534d14bc 100644 (file)
@@ -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 {
index b02cc8bdefeefad14b621bd155227b1990b63a2e..b35e5e0f0b313ea0367b9850d0bf5030e5593ea2 100644 (file)
@@ -107,12 +107,17 @@ class AttributeSetImpl : public FoldingSetNode {
   LLVMContext &Context;
   SmallVector<AttributeWithIndex, 4> AttrList;
 
+  SmallVector<std::pair<uint64_t, AttributeSetNode*>, 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<AttributeWithIndex> attrs)
     : Context(C), AttrList(attrs.begin(), attrs.end()) {}
+  AttributeSetImpl(LLVMContext &C,
+                   ArrayRef<std::pair<uint64_t, AttributeSetNode*> > attrs)
+    : Context(C), AttrNodes(attrs.begin(), attrs.end()) {}
 
   LLVMContext &getContext() { return Context; }
   ArrayRef<AttributeWithIndex> getAttributes() const { return AttrList; }
@@ -122,12 +127,20 @@ public:
     Profile(ID, AttrList);
   }
   static void Profile(FoldingSetNodeID &ID,
-                      ArrayRef<AttributeWithIndex> AttrList){
+                      ArrayRef<AttributeWithIndex> 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<std::pair<uint64_t, AttributeSetNode*> > Nodes) {
+    for (unsigned i = 0, e = Nodes.size(); i != e; ++i) {
+      ID.AddInteger(Nodes[i].first);
+      ID.AddPointer(Nodes[i].second);
+    }
+  }
 };
 
 } // end llvm namespace
index 8623b98b9f6c032faec9e9cb25bbdb3ba77f8673..8ee7057c1962d9d028c9a1e0cdedaff0441f1123 100644 (file)
@@ -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;
 }