[AArch64] Don't always override CPU for arm64e.
authorAhmed Bougacha <ahmed@bougacha.org>
Fri, 16 Apr 2021 20:59:08 +0000 (13:59 -0700)
committerAhmed Bougacha <ahmed@bougacha.org>
Tue, 20 Apr 2021 15:41:04 +0000 (08:41 -0700)
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
clang/test/Driver/aarch64-mac-cpus.c

index a6d8104..4ce797f 100644 (file)
@@ -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())
index 4f6e7e7..a1070f9 100644 (file)
@@ -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