[llvm-commits] [llvm] r173627 - Start using more of the AttrNode in the AttributeSetImpl class.

Bill Wendling isanbard at gmail.com
Sun Jan 27 13:20:07 PST 2013


Author: void
Date: Sun Jan 27 15:20:06 2013
New Revision: 173627

URL: http://llvm.org/viewvc/llvm-project?rev=173627&view=rev
Log:
Start using more of the AttrNode in the AttributeSetImpl class.

Also add some asserts.

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

Modified: llvm/trunk/lib/IR/AttributeImpl.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/AttributeImpl.h?rev=173627&r1=173626&r2=173627&view=diff
==============================================================================
--- llvm/trunk/lib/IR/AttributeImpl.h (original)
+++ llvm/trunk/lib/IR/AttributeImpl.h Sun Jan 27 15:20:06 2013
@@ -116,15 +116,14 @@ class AttributeSetImpl : public FoldingS
   AttributeSetImpl(const AttributeSetImpl &) LLVM_DELETED_FUNCTION;
 public:
   AttributeSetImpl(LLVMContext &C, ArrayRef<AttributeWithIndex> attrs);
-  AttributeSetImpl(LLVMContext &C,
-                   ArrayRef<std::pair<uint64_t, AttributeSetNode*> > attrs);
 
   LLVMContext &getContext() { return Context; }
   ArrayRef<AttributeWithIndex> getAttributes() const { return AttrList; }
-  unsigned getNumAttributes() const { return AttrList.size(); }
+  unsigned getNumAttributes() const {
+    return AttrNodes.size();
+  }
   unsigned getSlotIndex(unsigned Slot) const {
-    // FIXME: This needs to use AttrNodes instead.
-    return AttrList[Slot].Index;
+    return AttrNodes[Slot].first;
   }
   AttributeSet getSlotAttributes(unsigned Slot) const {
     // FIXME: This needs to use AttrNodes instead.

Modified: llvm/trunk/lib/IR/Attributes.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Attributes.cpp?rev=173627&r1=173626&r2=173627&view=diff
==============================================================================
--- llvm/trunk/lib/IR/Attributes.cpp (original)
+++ llvm/trunk/lib/IR/Attributes.cpp Sun Jan 27 15:20:06 2013
@@ -553,12 +553,14 @@ AttributeSetImpl(LLVMContext &C,
     AttrNodes.push_back(std::make_pair(AWI.Index,
                                        AttributeSetNode::get(C, Attrs)));
   }
-}
 
-AttributeSetImpl::
-AttributeSetImpl(LLVMContext &C,
-                 ArrayRef<std::pair<uint64_t, AttributeSetNode*> > attrs)
-  : Context(C), AttrNodes(attrs.begin(), attrs.end()) {
+  assert(AttrNodes.size() == AttrList.size() &&
+         "Number of attributes is different between lists!");
+#ifndef NDEBUG
+  for (unsigned I = 0, E = AttrNodes.size(); I != E; ++I)
+    assert((I == 0 || AttrNodes[I - 1].first < AttrNodes[I].first) &&
+           "Attributes not in ascending order!");
+#endif
 }
 
 //===----------------------------------------------------------------------===//





More information about the llvm-commits mailing list