Remove the getAttributesAtIndex and getNumAttrs methods in favor of using the getAttr...
authorBill Wendling <isanbard@gmail.com>
Mon, 31 Dec 2012 00:49:59 +0000 (00:49 +0000)
committerBill Wendling <isanbard@gmail.com>
Mon, 31 Dec 2012 00:49:59 +0000 (00:49 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@171271 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Attributes.h
include/llvm/Instructions.h
lib/Target/XCore/XCoreFrameLowering.cpp
lib/Transforms/InstCombine/InstCombineCalls.cpp
lib/VMCore/Attributes.cpp

index 08063c15ed580f1424f906e582c1d2fd42e96a1f..caba9633ebca6a153a6b3957eb4070fbcd76d43a 100644 (file)
@@ -358,9 +358,6 @@ public:
   /// parameter or for the return value.
   bool hasAttrSomewhere(Attribute::AttrKind Attr) const;
 
-  unsigned getNumAttrs() const;
-  Attribute &getAttributesAtIndex(unsigned i) const;
-
   /// operator==/!= - Provide equality predicates.
   bool operator==(const AttributeSet &RHS) const {
     return AttrList == RHS.AttrList;
index e5faf6e209e10460f699f092481137bd5f9661c5..a2f3125f9e01418f9e11a0122712b9b3e49536c8 100644 (file)
@@ -1352,10 +1352,7 @@ public:
 
   /// \brief Determine if any call argument is an aggregate passed by value.
   bool hasByValArgument() const {
-    for (unsigned I = 0, E = AttributeList.getNumAttrs(); I != E; ++I)
-      if (AttributeList.getAttributesAtIndex(I).hasAttribute(Attribute::ByVal))
-        return true;
-    return false;
+    return AttributeList.hasAttrSomewhere(Attribute::ByVal);
   }
 
   /// getCalledFunction - Return the function called, or null if this is an
@@ -3092,10 +3089,7 @@ public:
 
   /// \brief Determine if any call argument is an aggregate passed by value.
   bool hasByValArgument() const {
-    for (unsigned I = 0, E = AttributeList.getNumAttrs(); I != E; ++I)
-      if (AttributeList.getAttributesAtIndex(I).hasAttribute(Attribute::ByVal))
-        return true;
-    return false;
+    return AttributeList.hasAttrSomewhere(Attribute::ByVal);
   }
 
   /// getCalledFunction - Return the function called, or null if this is an
index aa185d67380796d7bc9ac063679e1a317fbf87b5..ffb0c53b3b24e03d5147ccb125a8b468e6e9e696 100644 (file)
@@ -100,11 +100,8 @@ void XCoreFrameLowering::emitPrologue(MachineFunction &MF) const {
   bool FP = hasFP(MF);
   const AttributeSet &PAL = MF.getFunction()->getAttributes();
 
-  for (unsigned I = 0, E = PAL.getNumAttrs(); I != E; ++I)
-    if (PAL.getAttributesAtIndex(I).hasAttribute(Attribute::Nest)) {
-      loadFromStack(MBB, MBBI, XCore::R11, 0, dl, TII);
-      break;
-    }
+  if (PAL.hasAttrSomewhere(Attribute::Nest))
+    loadFromStack(MBB, MBBI, XCore::R11, 0, dl, TII);
 
   // Work out frame sizes.
   int FrameSize = MFI->getStackSize();
index 23306b4079b48eb4eed1e766fb758d67b2adcdd3..fcd16b82ccd52df3e0e6ca105a87e4bad22d3dad 100644 (file)
@@ -1248,9 +1248,8 @@ InstCombiner::transformCallThroughTrampoline(CallSite CS,
 
   // If the call already has the 'nest' attribute somewhere then give up -
   // otherwise 'nest' would occur twice after splicing in the chain.
-  for (unsigned I = 0, E = Attrs.getNumAttrs(); I != E; ++I)
-    if (Attrs.getAttributesAtIndex(I).hasAttribute(Attribute::Nest))
-      return 0;
+  if (Attrs.hasAttrSomewhere(Attribute::Nest))
+    return 0;
 
   assert(Tramp &&
          "transformCallThroughTrampoline called with incorrect CallSite.");
index de83deb2e9ad0bfcc30ebd487345df985c0ca2e1..e8c6b2a01c8200fac3b0145bbc83b35486c2c7d9 100644 (file)
@@ -478,7 +478,7 @@ uint64_t AttributeSet::getBitMask(unsigned Index) const {
 Attribute AttributeSet::getAttributes(unsigned Idx) const {
   if (AttrList == 0) return Attribute();
 
-  const SmallVector<AttributeWithIndex, 4> &Attrs = AttrList->Attrs;
+  const SmallVectorImpl<AttributeWithIndex> &Attrs = AttrList->Attrs;
   for (unsigned i = 0, e = Attrs.size(); i != e && Attrs[i].Index <= Idx; ++i)
     if (Attrs[i].Index == Idx)
       return Attrs[i].Attrs;
@@ -499,18 +499,8 @@ bool AttributeSet::hasAttrSomewhere(Attribute::AttrKind Attr) const {
   return false;
 }
 
-unsigned AttributeSet::getNumAttrs() const {
-  return AttrList ? AttrList->Attrs.size() : 0;
-}
-
-Attribute &AttributeSet::getAttributesAtIndex(unsigned i) const {
-  assert(AttrList && "Trying to get an attribute from an empty list!");
-  assert(i < AttrList->Attrs.size() && "Index out of range!");
-  return AttrList->Attrs[i].Attrs;
-}
-
 AttributeSet AttributeSet::addAttr(LLVMContext &C, unsigned Idx,
-                                 Attribute Attrs) const {
+                                   Attribute Attrs) const {
   Attribute OldAttrs = getAttributes(Idx);
 #ifndef NDEBUG
   // FIXME it is not obvious how this should work for alignment.
@@ -555,7 +545,7 @@ AttributeSet AttributeSet::addAttr(LLVMContext &C, unsigned Idx,
 }
 
 AttributeSet AttributeSet::removeAttr(LLVMContext &C, unsigned Idx,
-                                    Attribute Attrs) const {
+                                      Attribute Attrs) const {
 #ifndef NDEBUG
   // FIXME it is not obvious how this should work for alignment.
   // For now, say we can't pass in alignment, which no current use does.