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 | 55c536c5901afcbe111e76ed16fbe8ce4434c563 (patch) | |
tree | 1abd139518c4c876c5fe3e647a2555e8fe48a456 /lib | |
parent | a45d5bb59f1d95d850d6bf1ec2448ac6cf653415 (diff) | |
download | clang-55c536c5901afcbe111e76ed16fbe8ce4434c563.tar.gz |
[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
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@316424 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Driver/ToolChains/Arch/AArch64.cpp | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/lib/Driver/ToolChains/Arch/AArch64.cpp b/lib/Driver/ToolChains/Arch/AArch64.cpp index 36186f0ac3..ad04aedd09 100644 --- a/lib/Driver/ToolChains/Arch/AArch64.cpp +++ b/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(); |