OSDN Git Service

[CodeGen] Use an AttrBuilder to bulk remove 'target-cpu', 'target-features', and...
authorCraig Topper <craig.topper@intel.com>
Thu, 27 Aug 2020 19:32:17 +0000 (12:32 -0700)
committerCraig Topper <craig.topper@intel.com>
Thu, 27 Aug 2020 19:54:20 +0000 (12:54 -0700)
I think the removeAttributes interface should be faster than
calling removeAttribute 3 times.

clang/lib/CodeGen/CodeGenModule.cpp

index 65e5e27..77a5079 100644 (file)
@@ -1829,9 +1829,11 @@ void CodeGenModule::setNonAliasAttributes(GlobalDecl GD,
         // We know that GetCPUAndFeaturesAttributes will always have the
         // newest set, since it has the newest possible FunctionDecl, so the
         // new ones should replace the old.
-        F->removeFnAttr("target-cpu");
-        F->removeFnAttr("target-features");
-        F->removeFnAttr("tune-cpu");
+        llvm::AttrBuilder RemoveAttrs;
+        RemoveAttrs.addAttribute("target-cpu");
+        RemoveAttrs.addAttribute("target-features");
+        RemoveAttrs.addAttribute("tune-cpu");
+        F->removeAttributes(llvm::AttributeList::FunctionIndex, RemoveAttrs);
         F->addAttributes(llvm::AttributeList::FunctionIndex, Attrs);
       }
     }