Author: ctopper
Date: Tue Mar 31 00:45:00 2015
New Revision: 233672

URL: http://llvm.org/viewvc/llvm-project?rev=233672&view=rev
Log:
[X86] Use getHostCPUFeatures when 'native' is specified for cpu.

This is necessary because not aall Sandybridge, Ivybrige, Haswell, and 
Broadwell CPUs support AVX. Currently we modify the CPU name back to Nehalem 
for this case, but that turns off additional features for these CPUs.

Modified:
    cfe/trunk/lib/Driver/Tools.cpp

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=233672&r1=233671&r2=233672&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Tue Mar 31 00:45:00 2015
@@ -1566,6 +1566,17 @@ static void AddGoldPlugin(const ToolChai
 static void getX86TargetFeatures(const Driver &D, const llvm::Triple &Triple,
                                  const ArgList &Args,
                                  std::vector<const char *> &Features) {
+  // If -march=native, autodetect the feature list.
+  if (const Arg *A = Args.getLastArg(options::OPT_march_EQ)) {
+    if (StringRef(A->getValue()) == "native") {
+      llvm::StringMap<bool> HostFeatures;
+      if (llvm::sys::getHostCPUFeatures(HostFeatures))
+        for (auto &F : HostFeatures)
+          Features.push_back(Args.MakeArgString((F.second ? "+" : "-") +
+                                                F.first()));
+    }
+  }
+
   if (Triple.getArchName() == "x86_64h") {
     // x86_64h implies quite a few of the more modern subtarget features
     // for Haswell class CPUs, but not all of them. Opt-out of a few.


_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to