From cedb5b06df1bab31e0484df31a40585ac7e7af19 Mon Sep 17 00:00:00 2001 From: Ahmed Bougacha Date: Fri, 16 Apr 2021 13:59:08 -0700 Subject: [PATCH] [AArch64] Don't always override CPU for arm64e. This demotes the apple-a12 CPU selection for arm64e to just be the last-resort default. Concretely, this means: - an explicitly-specified -mcpu will override the arm64e default; a user could potentially pick an invalid CPU that doesn't have v8.3a support, but that's not a major problem anymore - arm64e-apple-macos (and variants) will pick apple-m1 instead of being forced to apple-a12. --- clang/lib/Driver/ToolChains/Arch/AArch64.cpp | 8 ++++---- clang/test/Driver/aarch64-mac-cpus.c | 2 ++ 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/clang/lib/Driver/ToolChains/Arch/AArch64.cpp b/clang/lib/Driver/ToolChains/Arch/AArch64.cpp index a6d8104..4ce797f 100644 --- a/clang/lib/Driver/ToolChains/Arch/AArch64.cpp +++ b/clang/lib/Driver/ToolChains/Arch/AArch64.cpp @@ -41,10 +41,6 @@ std::string aarch64::getAArch64TargetCPU(const ArgList &Args, if (CPU == "native") return std::string(llvm::sys::getHostCPUName()); - // arm64e requires v8.3a and only runs on apple-a12 and later CPUs. - if (Triple.isArm64e()) - return "apple-a12"; - if (CPU.size()) return CPU; @@ -54,6 +50,10 @@ std::string aarch64::getAArch64TargetCPU(const ArgList &Args, return "apple-m1"; } + // arm64e requires v8.3a and only runs on apple-a12 and later CPUs. + if (Triple.isArm64e()) + return "apple-a12"; + // Make sure we pick the appropriate Apple CPU if -arch is used or when // targetting a Darwin OS. if (Args.getLastArg(options::OPT_arch) || Triple.isOSDarwin()) diff --git a/clang/test/Driver/aarch64-mac-cpus.c b/clang/test/Driver/aarch64-mac-cpus.c index 4f6e7e7..a1070f9 100644 --- a/clang/test/Driver/aarch64-mac-cpus.c +++ b/clang/test/Driver/aarch64-mac-cpus.c @@ -8,6 +8,8 @@ // RUN: %clang -target arm64-apple-macos -arch arm64 -### -c %s 2>&1 | FileCheck %s +// RUN: %clang -target arm64e-apple-macos -### -c %s 2>&1 | FileCheck %s + // RUN: %clang -target arm64-apple-macos -mcpu=apple-a11 -### -c %s 2>&1 | FileCheck --check-prefix=EXPLICIT-A11 %s // RUN: %clang -target arm64-apple-macos -mcpu=apple-a7 -### -c %s 2>&1 | FileCheck --check-prefix=EXPLICIT-A7 %s // RUN: %clang -target arm64-apple-macos -mcpu=apple-a14 -### -c %s 2>&1 | FileCheck --check-prefix=EXPLICIT-A14 %s -- 2.7.4