[clang] 7cffaf5 - [X89] Ignore -mtune=generic to fix failures some users are seeing after D85384

Craig Topper via cfe-commits cfe-commits at lists.llvm.org
Wed Aug 19 13:18:34 PDT 2020


Author: Craig Topper
Date: 2020-08-19T13:17:57-07:00
New Revision: 7cffaf510f97eabef89b0d45aeb939df40e8e9d3

URL: https://github.com/llvm/llvm-project/commit/7cffaf510f97eabef89b0d45aeb939df40e8e9d3
DIFF: https://github.com/llvm/llvm-project/commit/7cffaf510f97eabef89b0d45aeb939df40e8e9d3.diff

LOG: [X89] Ignore -mtune=generic to fix failures some users are seeing after D85384

Some code bases out there pass -mtune=generic to clang. This would have
been ignored prior to D85384. Now it results in an error
because "generic" isn't recognized by isValidCPUName.

And if we let it go through to the backend as a tune
setting it would get the tune flags closer to i386 rather
than a modern CPU.

I plan to change what tune=generic does in the backend in
a future patch. And allow this in the frontend.
But this should be a quick fix for the error some users
are seeing.

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 4f37590ffbfb..2054069daa5b 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -2081,8 +2081,13 @@ void Clang::AddX86TargetArgs(const ArgList &Args,
     if (Name == "native")
       Name = llvm::sys::getHostCPUName();
 
-    CmdArgs.push_back("-tune-cpu");
-    CmdArgs.push_back(Args.MakeArgString(Name));
+    // Ignore generic either from getHostCPUName or from command line.
+    // FIXME: We need to support this eventually but isValidCPUName and the
+    // backend aren't ready for it yet.
+    if (Name != "generic") {
+      CmdArgs.push_back("-tune-cpu");
+      CmdArgs.push_back(Args.MakeArgString(Name));
+    }
   }
 }
 


        


More information about the cfe-commits mailing list