[clang] 475e526 - [Driver][AArch64] Simplify -mtune

Fangrui Song via cfe-commits cfe-commits at lists.llvm.org
Fri Jul 22 14:19:33 PDT 2022


Author: Fangrui Song
Date: 2022-07-22T14:19:27-07:00
New Revision: 475e526d85003404ba521e15f8acef1b439fb910

URL: https://github.com/llvm/llvm-project/commit/475e526d85003404ba521e15f8acef1b439fb910
DIFF: https://github.com/llvm/llvm-project/commit/475e526d85003404ba521e15f8acef1b439fb910.diff

LOG: [Driver][AArch64] Simplify -mtune

llvm::sys::getHostCPUName()'s return value is not empty. `-mtune=` (empty value)
has caused a driver error. So we can omit `!TuneCPU.empty()` check.

Added: 
    

Modified: 
    clang/lib/Driver/ToolChains/Clang.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp
index 3ad08ad7e11d1..4cf4bc8171442 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -1923,18 +1923,11 @@ void Clang::AddAArch64TargetArgs(const ArgList &Args,
   AddAAPCSVolatileBitfieldArgs(Args, CmdArgs);
 
   if (const Arg *A = Args.getLastArg(clang::driver::options::OPT_mtune_EQ)) {
-    StringRef Name = A->getValue();
-
-    std::string TuneCPU;
-    if (Name == "native")
-      TuneCPU = std::string(llvm::sys::getHostCPUName());
+    CmdArgs.push_back("-tune-cpu");
+    if (strcmp(A->getValue(), "native") == 0)
+      CmdArgs.push_back(Args.MakeArgString(llvm::sys::getHostCPUName()));
     else
-      TuneCPU = std::string(Name);
-
-    if (!TuneCPU.empty()) {
-      CmdArgs.push_back("-tune-cpu");
-      CmdArgs.push_back(Args.MakeArgString(TuneCPU));
-    }
+      CmdArgs.push_back(A->getValue());
   }
 
   AddUnalignedAccessWarning(CmdArgs);


        


More information about the cfe-commits mailing list