diff options
author | Vedant Kumar <vsk@apple.com> | 2016-09-08 22:53:19 +0000 |
---|---|---|
committer | Vedant Kumar <vsk@apple.com> | 2016-09-08 22:53:19 +0000 |
commit | 10037b93e90672f1819b3bc32d8d2dbeec68ae83 (patch) | |
tree | e65ed7bb6562f04e3bc4356f25fb77c91b9ec001 | |
parent | b6a11acb533132bd1da786c73962ed8307b50ff7 (diff) | |
download | bcm5719-llvm-10037b93e90672f1819b3bc32d8d2dbeec68ae83.tar.gz bcm5719-llvm-10037b93e90672f1819b3bc32d8d2dbeec68ae83.zip |
[Driver] Report invalid -mtune/-mcpu parameters when -arch=arm64
Differential Revision: https://reviews.llvm.org/D23643
llvm-svn: 280998
-rw-r--r-- | clang/lib/Driver/Tools.cpp | 20 | ||||
-rw-r--r-- | clang/test/Driver/arm-cortex-cpus.c | 3 |
2 files changed, 14 insertions, 9 deletions
diff --git a/clang/lib/Driver/Tools.cpp b/clang/lib/Driver/Tools.cpp index 8922218d921..8cd86434624 100644 --- a/clang/lib/Driver/Tools.cpp +++ b/clang/lib/Driver/Tools.cpp @@ -1140,9 +1140,9 @@ void Clang::AddARMTargetArgs(const llvm::Triple &Triple, const ArgList &Args, // ARM tools end. /// getAArch64TargetCPU - Get the (LLVM) name of the AArch64 cpu we are -/// targeting. -static std::string getAArch64TargetCPU(const ArgList &Args) { - Arg *A; +/// targeting. Set \p A to the Arg corresponding to the -mcpu or -mtune +/// arguments if they are provided, or to nullptr otherwise. +static std::string getAArch64TargetCPU(const ArgList &Args, Arg *&A) { std::string CPU; // If we have -mtune or -mcpu, use that. if ((A = Args.getLastArg(options::OPT_mtune_EQ))) { @@ -1919,13 +1919,15 @@ static StringRef getWebAssemblyTargetCPU(const ArgList &Args) { static std::string getCPUName(const ArgList &Args, const llvm::Triple &T, bool FromAs = false) { + Arg *A; + switch (T.getArch()) { default: return ""; case llvm::Triple::aarch64: case llvm::Triple::aarch64_be: - return getAArch64TargetCPU(Args); + return getAArch64TargetCPU(Args, A); case llvm::Triple::arm: case llvm::Triple::armeb: @@ -2443,8 +2445,8 @@ static void getAArch64TargetFeatures(const Driver &D, const ArgList &Args, else if ((A = Args.getLastArg(options::OPT_mcpu_EQ))) success = getAArch64ArchFeaturesFromMcpu(D, A->getValue(), Args, Features); else if (Args.hasArg(options::OPT_arch)) - success = getAArch64ArchFeaturesFromMcpu(D, getAArch64TargetCPU(Args), Args, - Features); + success = getAArch64ArchFeaturesFromMcpu(D, getAArch64TargetCPU(Args, A), + Args, Features); if (success && (A = Args.getLastArg(options::OPT_mtune_EQ))) success = @@ -2452,9 +2454,9 @@ static void getAArch64TargetFeatures(const Driver &D, const ArgList &Args, else if (success && (A = Args.getLastArg(options::OPT_mcpu_EQ))) success = getAArch64MicroArchFeaturesFromMcpu(D, A->getValue(), Args, Features); - else if (Args.hasArg(options::OPT_arch)) - success = getAArch64MicroArchFeaturesFromMcpu(D, getAArch64TargetCPU(Args), - Args, Features); + else if (success && Args.hasArg(options::OPT_arch)) + success = getAArch64MicroArchFeaturesFromMcpu( + D, getAArch64TargetCPU(Args, A), Args, Features); if (!success) D.Diag(diag::err_drv_clang_unsupported) << A->getAsString(Args); diff --git a/clang/test/Driver/arm-cortex-cpus.c b/clang/test/Driver/arm-cortex-cpus.c index 5bf89394949..ca04f116057 100644 --- a/clang/test/Driver/arm-cortex-cpus.c +++ b/clang/test/Driver/arm-cortex-cpus.c @@ -303,7 +303,10 @@ // ================== Check that a bogus CPU gives an error // RUN: %clang -target arm -mcpu=bogus -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BOGUS-CPU %s +// RUN: %clang -target armv8-apple-darwin -arch arm64 -mcpu=bogus -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BOGUS-CPU %s // CHECK-BOGUS-CPU: error: {{.*}} does not support '-mcpu=bogus' +// RUN: %clang -target armv8-apple-darwin -arch arm64 -mtune=bogus -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BOGUS-TUNE %s +// CHECK-BOGUS-TUNE: error: {{.*}} does not support '-mtune=bogus' // ================== Check default Architecture on each ARM11 CPU // RUN: %clang -target arm-linux-gnueabi -mcpu=arm1136j-s -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CPUV6 %s |