[llvm] r301267 - Make getSlotAttributes return an AttributeSet instead of a wrapper list

Reid Kleckner via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 24 15:25:02 PDT 2017


Author: rnk
Date: Mon Apr 24 17:25:02 2017
New Revision: 301267

URL: http://llvm.org/viewvc/llvm-project?rev=301267&view=rev
Log:
Make getSlotAttributes return an AttributeSet instead of a wrapper list

Remove the temporary, poorly named getSlotSet method which did the same
thing. Also remove getSlotNode, which is a hold-over from when we were
dealing with AttributeSetNode* instead of AttributeSet.

Modified:
    llvm/trunk/include/llvm/IR/Attributes.h
    llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp
    llvm/trunk/lib/Bitcode/Writer/ValueEnumerator.cpp
    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=301267&r1=301266&r2=301267&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/Attributes.h (original)
+++ llvm/trunk/include/llvm/IR/Attributes.h Mon Apr 24 17:25:02 2017
@@ -509,10 +509,7 @@ public:
   unsigned getSlotIndex(unsigned Slot) const;
 
   /// \brief Return the attributes at the given slot.
-  AttributeList getSlotAttributes(unsigned Slot) const;
-
-  /// \brief Return the attributes at the given slot.
-  AttributeSet getSlotSet(unsigned Slot) const;
+  AttributeSet getSlotAttributes(unsigned Slot) const;
 
   void dump() const;
 };

Modified: llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp?rev=301267&r1=301266&r2=301267&view=diff
==============================================================================
--- llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp (original)
+++ llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp Mon Apr 24 17:25:02 2017
@@ -779,7 +779,7 @@ void ModuleBitcodeWriter::writeAttribute
     const AttributeList &A = Attrs[i];
     for (unsigned i = 0, e = A.getNumSlots(); i != e; ++i)
       Record.push_back(
-          VE.getAttributeGroupID({A.getSlotIndex(i), A.getSlotSet(i)}));
+          VE.getAttributeGroupID({A.getSlotIndex(i), A.getSlotAttributes(i)}));
 
     Stream.EmitRecord(bitc::PARAMATTR_CODE_ENTRY, Record);
     Record.clear();

Modified: llvm/trunk/lib/Bitcode/Writer/ValueEnumerator.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Writer/ValueEnumerator.cpp?rev=301267&r1=301266&r2=301267&view=diff
==============================================================================
--- llvm/trunk/lib/Bitcode/Writer/ValueEnumerator.cpp (original)
+++ llvm/trunk/lib/Bitcode/Writer/ValueEnumerator.cpp Mon Apr 24 17:25:02 2017
@@ -900,7 +900,7 @@ void ValueEnumerator::EnumerateAttribute
 
   // Do lookups for all attribute groups.
   for (unsigned i = 0, e = PAL.getNumSlots(); i != e; ++i) {
-    IndexAndAttrSet Pair = {PAL.getSlotIndex(i), PAL.getSlotSet(i)};
+    IndexAndAttrSet Pair = {PAL.getSlotIndex(i), PAL.getSlotAttributes(i)};
     unsigned &Entry = AttributeGroupMap[Pair];
     if (Entry == 0) {
       AttributeGroups.push_back(Pair);

Modified: llvm/trunk/lib/IR/AttributeImpl.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/AttributeImpl.h?rev=301267&r1=301266&r2=301267&view=diff
==============================================================================
--- llvm/trunk/lib/IR/AttributeImpl.h (original)
+++ llvm/trunk/lib/IR/AttributeImpl.h Mon Apr 24 17:25:02 2017
@@ -255,17 +255,10 @@ public:
 
   /// \brief Retrieve the attribute set node for the given "slot" in the
   /// AttrNode list.
-  AttributeSet getSlotNode(unsigned Slot) const {
+  AttributeSet getSlotAttributes(unsigned Slot) const {
     return getSlotPair(Slot)->second;
   }
 
-  /// \brief Retrieve the attributes for the given "slot" in the AttrNode list.
-  /// \p Slot is an index into the AttrNodes list, not the index of the return /
-  /// parameter/ function which the attributes apply to.
-  AttributeList getSlotAttributes(unsigned Slot) const {
-    return AttributeList::get(Context, *getSlotPair(Slot));
-  }
-
   /// \brief Return true if the AttributeSet or the FunctionIndex has an
   /// enum attribute of the given kind.
   bool hasFnAttribute(Attribute::AttrKind Kind) const {
@@ -273,8 +266,10 @@ public:
   }
 
   typedef AttributeSet::iterator iterator;
-  iterator begin(unsigned Slot) const { return getSlotNode(Slot).begin(); }
-  iterator end(unsigned Slot) const { return getSlotNode(Slot).end(); }
+  iterator begin(unsigned Slot) const {
+    return getSlotAttributes(Slot).begin();
+  }
+  iterator end(unsigned Slot) const { return getSlotAttributes(Slot).end(); }
 
   void Profile(FoldingSetNodeID &ID) const;
   static void Profile(FoldingSetNodeID &ID,

Modified: llvm/trunk/lib/IR/Attributes.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Attributes.cpp?rev=301267&r1=301266&r2=301267&view=diff
==============================================================================
--- llvm/trunk/lib/IR/Attributes.cpp (original)
+++ llvm/trunk/lib/IR/Attributes.cpp Mon Apr 24 17:25:02 2017
@@ -955,13 +955,13 @@ AttributeList AttributeList::addAttribut
   for (unsigned Index : Indices) {
     // Add all attribute slots before the current index.
     for (; I < E && getSlotIndex(I) < Index; ++I)
-      AttrVec.emplace_back(getSlotIndex(I), pImpl->getSlotNode(I));
+      AttrVec.emplace_back(getSlotIndex(I), pImpl->getSlotAttributes(I));
 
     // Add the attribute at this index. If we already have attributes at this
     // index, merge them into a new set.
     AttrBuilder B;
     if (I < E && getSlotIndex(I) == Index) {
-      B.merge(AttrBuilder(pImpl->getSlotNode(I)));
+      B.merge(AttrBuilder(pImpl->getSlotAttributes(I)));
       ++I;
     }
     B.addAttribute(A);
@@ -970,7 +970,7 @@ AttributeList AttributeList::addAttribut
 
   // Add remaining attributes.
   for (; I < E; ++I)
-    AttrVec.emplace_back(getSlotIndex(I), pImpl->getSlotNode(I));
+    AttrVec.emplace_back(getSlotIndex(I), pImpl->getSlotAttributes(I));
 
   return get(C, AttrVec);
 }
@@ -1008,13 +1008,13 @@ AttributeList AttributeList::addAttribut
   for (I = 0; I < NumAttrs; ++I) {
     if (getSlotIndex(I) >= Index)
       break;
-    AttrVec.emplace_back(getSlotIndex(I), pImpl->getSlotNode(I));
+    AttrVec.emplace_back(getSlotIndex(I), pImpl->getSlotAttributes(I));
   }
 
   AttrBuilder NewAttrs;
   if (I < NumAttrs && getSlotIndex(I) == Index) {
     // We need to merge the attribute sets.
-    NewAttrs.merge(pImpl->getSlotNode(I));
+    NewAttrs.merge(pImpl->getSlotAttributes(I));
     ++I;
   }
   NewAttrs.merge(B);
@@ -1024,7 +1024,7 @@ AttributeList AttributeList::addAttribut
 
   // Add the remaining entries.
   for (; I < NumAttrs; ++I)
-    AttrVec.emplace_back(getSlotIndex(I), pImpl->getSlotNode(I));
+    AttrVec.emplace_back(getSlotIndex(I), pImpl->getSlotAttributes(I));
 
   return get(C, AttrVec);
 }
@@ -1063,11 +1063,11 @@ AttributeList AttributeList::removeAttri
   for (unsigned I = 0, E = NumAttrs; I != E; ++I) {
     if (getSlotIndex(I) >= Index) {
       if (getSlotIndex(I) == Index)
-        B = AttrBuilder(pImpl->getSlotNode(LastIndex++));
+        B = AttrBuilder(getSlotAttributes(LastIndex++));
       break;
     }
     LastIndex = I + 1;
-    AttrSets.push_back({getSlotIndex(I), pImpl->getSlotNode(I)});
+    AttrSets.push_back({getSlotIndex(I), getSlotAttributes(I)});
   }
 
   // Remove the attributes from the existing set and add them.
@@ -1077,7 +1077,7 @@ AttributeList AttributeList::removeAttri
 
   // Add the remaining attribute slots.
   for (unsigned I = LastIndex, E = NumAttrs; I < E; ++I)
-    AttrSets.push_back({getSlotIndex(I), pImpl->getSlotNode(I)});
+    AttrSets.push_back({getSlotIndex(I), getSlotAttributes(I)});
 
   return get(C, AttrSets);
 }
@@ -1091,7 +1091,7 @@ AttributeList AttributeList::removeAttri
   for (unsigned I = 0, E = pImpl->getNumSlots(); I != E; ++I) {
     unsigned Index = getSlotIndex(I);
     if (Index != WithoutIndex)
-      AttrSet.push_back({Index, pImpl->getSlotNode(I)});
+      AttrSet.push_back({Index, pImpl->getSlotAttributes(I)});
   }
   return get(C, AttrSet);
 }
@@ -1220,7 +1220,7 @@ AttributeSet AttributeList::getAttribute
   // Loop through to find the attribute node we want.
   for (unsigned I = 0, E = pImpl->getNumSlots(); I != E; ++I)
     if (pImpl->getSlotIndex(I) == Index)
-      return pImpl->getSlotNode(I);
+      return pImpl->getSlotAttributes(I);
 
   return AttributeSet();
 }
@@ -1251,18 +1251,12 @@ unsigned AttributeList::getSlotIndex(uns
   return pImpl->getSlotIndex(Slot);
 }
 
-AttributeList AttributeList::getSlotAttributes(unsigned Slot) const {
+AttributeSet AttributeList::getSlotAttributes(unsigned Slot) const {
   assert(pImpl && Slot < pImpl->getNumSlots() &&
          "Slot # out of range!");
   return pImpl->getSlotAttributes(Slot);
 }
 
-AttributeSet AttributeList::getSlotSet(unsigned Slot) const {
-  assert(pImpl && Slot < pImpl->getNumSlots() &&
-         "Slot # out of range!");
-  return pImpl->getSlotNode(Slot);
-}
-
 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
 LLVM_DUMP_METHOD void AttributeList::dump() const {
   dbgs() << "PAL[\n";




More information about the llvm-commits mailing list