diff options
author | Peter Smith <peter.smith@linaro.org> | 2017-10-24 09:51:55 +0000 |
---|---|---|
committer | Peter Smith <peter.smith@linaro.org> | 2017-10-24 09:51:55 +0000 |
commit | 820e46f3b2b3edbf86315185ea403deb6f5b623c (patch) | |
tree | 70c78a3e6b34cebe2c7d9ffa9a303c873def5549 /clang/lib/Driver | |
parent | ce256a3a01b9f207f9a5eba6b313c008fa373241 (diff) | |
download | bcm5719-llvm-820e46f3b2b3edbf86315185ea403deb6f5b623c.tar.gz bcm5719-llvm-820e46f3b2b3edbf86315185ea403deb6f5b623c.zip |
[AArch64] Fix PR34625 -mtune without -mcpu should not set -target-cpu
When -mtune is used on AArch64 the -target-cpu is passed the value of the
cpu given to -mtune. As well as setting micro-architectural features of the
-mtune cpu, this will also add the architectural features such as support
for instructions. This can result in the backend using instructions that
are supported in the -mtune cpu but not supported in the target
architecture. For example use of the v8.1-a LSE extensions with -march=v8.
This change removes the setting of -target-cpu for -mtune, the -mcpu must
be used to set -target-cpu. This has the effect of removing all non-hard
coded benefits of mtune but it does produce correct output when -mtune cpu
with a later architecture than v8 is used.
Fixes PR34625
Differential Revision: https://reviews.llvm.org/D39179
llvm-svn: 316424
Diffstat (limited to 'clang/lib/Driver')
-rw-r--r-- | clang/lib/Driver/ToolChains/Arch/AArch64.cpp | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/clang/lib/Driver/ToolChains/Arch/AArch64.cpp b/clang/lib/Driver/ToolChains/Arch/AArch64.cpp index 36186f0ac32..ad04aedd098 100644 --- a/clang/lib/Driver/ToolChains/Arch/AArch64.cpp +++ b/clang/lib/Driver/ToolChains/Arch/AArch64.cpp @@ -20,14 +20,12 @@ using namespace clang; using namespace llvm::opt; /// getAArch64TargetCPU - Get the (LLVM) name of the AArch64 cpu we are -/// targeting. Set \p A to the Arg corresponding to the -mcpu or -mtune -/// arguments if they are provided, or to nullptr otherwise. +/// targeting. Set \p A to the Arg corresponding to the -mcpu argument if it is +/// provided, or to nullptr otherwise. std::string aarch64::getAArch64TargetCPU(const ArgList &Args, Arg *&A) { std::string CPU; - // If we have -mtune or -mcpu, use that. - if ((A = Args.getLastArg(clang::driver::options::OPT_mtune_EQ))) { - CPU = StringRef(A->getValue()).lower(); - } else if ((A = Args.getLastArg(options::OPT_mcpu_EQ))) { + // If we have -mcpu, use that. + if ((A = Args.getLastArg(options::OPT_mcpu_EQ))) { StringRef Mcpu = A->getValue(); CPU = Mcpu.split("+").first.lower(); } @@ -122,6 +120,12 @@ getAArch64MicroArchFeaturesFromMtune(const Driver &D, StringRef Mtune, const ArgList &Args, std::vector<StringRef> &Features) { std::string MtuneLowerCase = Mtune.lower(); + // Check CPU name is valid + std::vector<StringRef> MtuneFeatures; + StringRef Tune; + if (!DecodeAArch64Mcpu(D, MtuneLowerCase, Tune, MtuneFeatures)) + return false; + // Handle CPU name is 'native'. if (MtuneLowerCase == "native") MtuneLowerCase = llvm::sys::getHostCPUName(); |