diff options
| author | Craig Topper <craig.topper@gmail.com> | 2015-03-31 05:45:00 +0000 |
|---|---|---|
| committer | Craig Topper <craig.topper@gmail.com> | 2015-03-31 05:45:00 +0000 |
| commit | a8bd6008ee99a5b9a53d510a6523fe0a3109a0c6 (patch) | |
| tree | 40424e9f8a4a8104b4bf69c6247732c20213e01e /clang/lib | |
| parent | 1214bdcb8c95ffa2764ab5720b7b24140288f959 (diff) | |
| download | bcm5719-llvm-a8bd6008ee99a5b9a53d510a6523fe0a3109a0c6.tar.gz bcm5719-llvm-a8bd6008ee99a5b9a53d510a6523fe0a3109a0c6.zip | |
[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.
llvm-svn: 233672
Diffstat (limited to 'clang/lib')
| -rw-r--r-- | clang/lib/Driver/Tools.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/clang/lib/Driver/Tools.cpp b/clang/lib/Driver/Tools.cpp index 0ec9e5067a5..daaea63c716 100644 --- a/clang/lib/Driver/Tools.cpp +++ b/clang/lib/Driver/Tools.cpp @@ -1566,6 +1566,17 @@ static void AddGoldPlugin(const ToolChain &ToolChain, const ArgList &Args, 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. |

