[llvm-commits] [llvm] r173313 - in /llvm/trunk: include/llvm/IR/Attributes.h lib/IR/AttributeImpl.h lib/IR/Attributes.cpp

Bill Wendling isanbard at gmail.com
Wed Jan 23 17:01:34 PST 2013


Author: void
Date: Wed Jan 23 19:01:34 2013
New Revision: 173313

URL: http://llvm.org/viewvc/llvm-project?rev=173313&view=rev
Log:
Add a profile for uniquifying the AttributeSet with the AttributeSetNodes.

Modified:
    llvm/trunk/include/llvm/IR/Attributes.h
    llvm/trunk/lib/IR/AttributeImpl.h
    llvm/trunk/lib/IR/Attributes.cpp

Modified: llvm/trunk/include/llvm/IR/Attributes.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/Attributes.h?rev=173313&r1=173312&r2=173313&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/Attributes.h (original)
+++ llvm/trunk/include/llvm/IR/Attributes.h Wed Jan 23 19:01:34 2013
@@ -132,7 +132,9 @@
 
   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 {

Modified: llvm/trunk/lib/IR/AttributeImpl.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/AttributeImpl.h?rev=173313&r1=173312&r2=173313&view=diff
==============================================================================
--- llvm/trunk/lib/IR/AttributeImpl.h (original)
+++ llvm/trunk/lib/IR/AttributeImpl.h Wed Jan 23 19:01:34 2013
@@ -107,12 +107,17 @@
   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 @@
     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

Modified: llvm/trunk/lib/IR/Attributes.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Attributes.cpp?rev=173313&r1=173312&r2=173313&view=diff
==============================================================================
--- llvm/trunk/lib/IR/Attributes.cpp (original)
+++ llvm/trunk/lib/IR/Attributes.cpp Wed Jan 23 19:01:34 2013
@@ -99,11 +99,6 @@
   return *pImpl < *A.pImpl;
 }
 
-
-void Attribute::Profile(FoldingSetNodeID &ID) const {
-  ID.AddPointer(pImpl);
-}
-
 uint64_t Attribute::Raw() const {
   return pImpl ? pImpl->Raw() : 0;
 }





More information about the llvm-commits mailing list