]> granicus.if.org Git - llvm/commitdiff
[GlobalOpt] Simplify attribute code stripping nest, NFC
authorReid Kleckner <rnk@google.com>
Wed, 19 Apr 2017 23:26:44 +0000 (23:26 +0000)
committerReid Kleckner <rnk@google.com>
Wed, 19 Apr 2017 23:26:44 +0000 (23:26 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@300787 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/IPO/GlobalOpt.cpp

index ade4f21ceb5240171c1b22cec766bfce5f73b34c..ae9d4ce11e0db9181303d77e279ea1233d511837 100644 (file)
@@ -1979,16 +1979,11 @@ static void ChangeCalleesToFastCall(Function *F) {
   }
 }
 
-static AttributeList StripNest(LLVMContext &C, const AttributeList &Attrs) {
-  for (unsigned i = 0, e = Attrs.getNumSlots(); i != e; ++i) {
-    unsigned Index = Attrs.getSlotIndex(i);
-    if (!Attrs.getSlotAttributes(i).hasAttribute(Index, Attribute::Nest))
-      continue;
-
-    // There can be only one.
-    return Attrs.removeAttribute(C, Index, Attribute::Nest);
-  }
-
+static AttributeList StripNest(LLVMContext &C, AttributeList Attrs) {
+  // There can be at most one attribute set with a nest attribute.
+  unsigned NestIndex;
+  if (Attrs.hasAttrSomewhere(Attribute::Nest, &NestIndex))
+    return Attrs.removeAttribute(C, NestIndex, Attribute::Nest);
   return Attrs;
 }