<div dir="ltr">I think this should be ok. It'll turn some "hidden" features that would have been "target-cpu" features into "target-features" features explicitly, but that'll just mean wordier attribute descriptions (and will be more accurate).<div><br></div><div>-eric<br><br><div class="gmail_quote">On Sun, Mar 29, 2015 at 9:16 PM Craig Topper <<a href="mailto:craig.topper@gmail.com">craig.topper@gmail.com</a>> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi chandlerc, echristo, rafael, grosbach,<br>
<br>
Some versions of Sandybridge, Ivybridge, Haswell, and Broadwell CPUs don't support AVX. Currently, getHostCPUName changes the CPU name to Nehalem when it detects one of the CPUs. This also ends up disabling other features that these CPUs might still have as well as changing the scheduling model, etc.<br>
<br>
This patch attempts to correct this by allowing the CPU name to work unaltered and then use getHostCPUFeatures to explicitly specify which features are enabled and disabled.<br>
<br>
Similar patch will also be made to llc.<br>
<br>
<a href="http://reviews.llvm.org/D8694" target="_blank">http://reviews.llvm.org/D8694</a><br>
<br>
Files:<br>
  lib/Driver/Tools.cpp<br>
<br>
Index: lib/Driver/Tools.cpp<br>
==============================<u></u>==============================<u></u>=======<br>
--- lib/Driver/Tools.cpp<br>
+++ lib/Driver/Tools.cpp<br>
@@ -1566,6 +1566,17 @@<br>
 static void getX86TargetFeatures(const Driver &D, const llvm::Triple &Triple,<br>
                                  const ArgList &Args,<br>
                                  std::vector<const char *> &Features) {<br>
+  // If -march=native, autodetect the feature list.<br>
+  if (const Arg *A = Args.getLastArg(options::OPT_<u></u>march_EQ)) {<br>
+    if (StringRef(A->getValue()) == "native") {<br>
+      llvm::StringMap<bool> HostFeatures;<br>
+      if (llvm::sys::<u></u>getHostCPUFeatures(<u></u>HostFeatures))<br>
+        for (auto &F : HostFeatures)<br>
+          Features.push_back(Args.<u></u>MakeArgString((F.second ? "+" : "-") +<br>
+                                                F.first()));<br>
+    }<br>
+  }<br>
+<br>
   if (Triple.getArchName() == "x86_64h") {<br>
     // x86_64h implies quite a few of the more modern subtarget features<br>
     // for Haswell class CPUs, but not all of them. Opt-out of a few.<br>
<br>
EMAIL PREFERENCES<br>
  <a href="http://reviews.llvm.org/settings/panel/emailpreferences/" target="_blank">http://reviews.llvm.org/<u></u>settings/panel/<u></u>emailpreferences/</a><br>
</blockquote></div></div></div>