Make getSlotAttributes return an AttributeSet instead of a wrapper list
authorReid Kleckner <rnk@google.com>
Mon, 24 Apr 2017 22:25:02 +0000 (22:25 +0000)
committerReid Kleckner <rnk@google.com>
Mon, 24 Apr 2017 22:25:02 +0000 (22:25 +0000)
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.

llvm-svn: 301267

llvm/include/llvm/IR/Attributes.h
llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
llvm/lib/Bitcode/Writer/ValueEnumerator.cpp
llvm/lib/IR/AttributeImpl.h
llvm/lib/IR/Attributes.cpp

index f73e4a6..e2cd4c2 100644 (file)
@@ -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;
 };
index bb016e4..e5aba03 100644 (file)
@@ -779,7 +779,7 @@ void ModuleBitcodeWriter::writeAttributeTable() {
     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();
index c6f80f0..8611507 100644 (file)
@@ -900,7 +900,7 @@ void ValueEnumerator::EnumerateAttributes(AttributeList PAL) {
 
   // 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);
index 09f0373..cf29252 100644 (file)
@@ -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,
index f6deba6..e304145 100644 (file)
@@ -955,13 +955,13 @@ AttributeList AttributeList::addAttribute(LLVMContext &C,
   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::addAttribute(LLVMContext &C,
 
   // 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::addAttributes(LLVMContext &C, unsigned Index,
   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::addAttributes(LLVMContext &C, unsigned Index,
 
   // 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::removeAttributes(LLVMContext &C, unsigned Index,
   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::removeAttributes(LLVMContext &C, unsigned Index,
 
   // 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::removeAttributes(LLVMContext &C,
   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::getAttributes(unsigned Index) const {
   // 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(unsigned Slot) const {
   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";