[clang] cedb5b0 - [AArch64] Don't always override CPU for arm64e.

Ahmed Bougacha via cfe-commits cfe-commits at lists.llvm.org
Tue Apr 20 08:41:58 PDT 2021


Author: Ahmed Bougacha
Date: 2021-04-20T08:41:04-07:00
New Revision: cedb5b06df1bab31e0484df31a40585ac7e7af19

URL: https://github.com/llvm/llvm-project/commit/cedb5b06df1bab31e0484df31a40585ac7e7af19
DIFF: https://github.com/llvm/llvm-project/commit/cedb5b06df1bab31e0484df31a40585ac7e7af19.diff

LOG: [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.

Added: 
    

Modified: 
    clang/lib/Driver/ToolChains/Arch/AArch64.cpp
    clang/test/Driver/aarch64-mac-cpus.c

Removed: 
    


################################################################################
diff  --git a/clang/lib/Driver/ToolChains/Arch/AArch64.cpp b/clang/lib/Driver/ToolChains/Arch/AArch64.cpp
index a6d81044f20d..4ce797f9bc73 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 4f6e7e71d306..a1070f9f26f1 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


        


More information about the cfe-commits mailing list