From 8f93f757c3464fe46d84323f2dc5e0d073076290 Mon Sep 17 00:00:00 2001 From: Ahmed Bougacha Date: Mon, 11 Aug 2025 11:39:16 -0700 Subject: [PATCH 1/2] [AArch64] Bump default CPUs for iOS 26/watchOS 26 to A12/S6. (#152235) iOS 26/watchOS 26 deprecate some devices, allowing the default CPU to be raised based on the deployment target. watchOS 26 also introduces arm64 (vs. arm64_32/arm64e). The defaults are now: - arm64-apple-ios26 apple-a12 - arm64-apple-watchos26 apple-s6 - arm64_32-apple-watchos26 apple-s6 - arm64e-apple-watchos26 apple-s6 Left unchanged are: - arm64-apple-tvos26 apple-a7 - arm64e-apple-tvos26 apple-a12 - arm64e-apple-ios26 apple-a12 - arm64_32-apple-watchos11 apple-s4 While there, rewrite an outdated comment in a related Mac test. (cherry picked from commit 69d141712a107ed9f38fbfa12b0c35504f8bfb7c) --- clang/lib/Driver/ToolChains/Arch/AArch64.cpp | 16 ++++++++++++++ .../Driver/aarch64-cpu-defaults-appleos26.c | 22 +++++++++++++++++++ clang/test/Driver/aarch64-mac-cpus.c | 2 +- 3 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 clang/test/Driver/aarch64-cpu-defaults-appleos26.c diff --git a/clang/lib/Driver/ToolChains/Arch/AArch64.cpp b/clang/lib/Driver/ToolChains/Arch/AArch64.cpp index 418f9fd9ca4c4..98f5efbe5652f 100644 --- a/clang/lib/Driver/ToolChains/Arch/AArch64.cpp +++ b/clang/lib/Driver/ToolChains/Arch/AArch64.cpp @@ -52,6 +52,22 @@ std::string aarch64::getAArch64TargetCPU(const ArgList &Args, return "apple-m1"; } + if (Triple.getOS() == llvm::Triple::IOS) { + assert(!Triple.isSimulatorEnvironment() && "iossim should be mac-like"); + // iOS 26 only runs on apple-a12 and later CPUs. + if (!Triple.isOSVersionLT(26)) + return "apple-a12"; + } + + if (Triple.isWatchOS()) { + assert(!Triple.isSimulatorEnvironment() && "watchossim should be mac-like"); + // arm64_32/arm64e watchOS requires S4 before watchOS 26, S6 after. + if (Triple.getArch() == llvm::Triple::aarch64_32 || Triple.isArm64e()) + return Triple.isOSVersionLT(26) ? "apple-s4" : "apple-s6"; + // arm64 (non-e, non-32) watchOS comes later, and requires S6 anyway. + return "apple-s6"; + } + if (Triple.isXROS()) { // The xrOS simulator runs on M1 as well, it should have been covered above. assert(!Triple.isSimulatorEnvironment() && "xrossim should be mac-like"); diff --git a/clang/test/Driver/aarch64-cpu-defaults-appleos26.c b/clang/test/Driver/aarch64-cpu-defaults-appleos26.c new file mode 100644 index 0000000000000..99176050bf5ae --- /dev/null +++ b/clang/test/Driver/aarch64-cpu-defaults-appleos26.c @@ -0,0 +1,22 @@ +/// iOS 26 and watchOS 26 bump the default arm64 CPU targets. + +/// arm64 iOS 26 defaults to apple-a12. arm64e already did. +// RUN: %clang -target arm64-apple-ios26 -### -c %s 2>&1 | FileCheck %s --check-prefix=A12 +// RUN: %clang -target arm64e-apple-ios26 -### -c %s 2>&1 | FileCheck %s --check-prefix=A12 + +/// arm64e/arm64_32 watchOS 26 default to apple-s6. +// RUN: %clang -target arm64e-apple-watchos26 -### -c %s 2>&1 | FileCheck %s --check-prefix=S6 +// RUN: %clang -target arm64_32-apple-watchos26 -### -c %s 2>&1 | FileCheck %s --check-prefix=S6 + +/// arm64 is new in watchOS 26, and defaults to apple-s6. +// RUN: %clang -target arm64-apple-watchos26 -### -c %s 2>&1 | FileCheck %s --check-prefix=S6 + +/// llvm usually treats tvOS like iOS, but it runs on different hardware. +// RUN: %clang -target arm64-apple-tvos26 -### -c %s 2>&1 | FileCheck %s --check-prefix=A7 +// RUN: %clang -target arm64e-apple-tvos26 -### -c %s 2>&1 | FileCheck %s --check-prefix=A12 + +/// Simulators are tested with other Mac-like targets in aarch64-mac-cpus.c. + +// A12: "-target-cpu" "apple-a12" +// S6: "-target-cpu" "apple-s6" +// A7: "-target-cpu" "apple-a7" diff --git a/clang/test/Driver/aarch64-mac-cpus.c b/clang/test/Driver/aarch64-mac-cpus.c index 8d23ad8c956fd..1aef1ae285e86 100644 --- a/clang/test/Driver/aarch64-mac-cpus.c +++ b/clang/test/Driver/aarch64-mac-cpus.c @@ -1,4 +1,4 @@ -// arm64 Mac-based targets default to Apple A13. +// arm64/arm64e Mac-based targets default to Apple M1. // RUN: %clang --target=arm64-apple-macos -### -c %s 2>&1 | FileCheck %s // RUN: %clang --target=arm64-apple-ios-macabi -### -c %s 2>&1 | FileCheck %s From 74310bdcbb70e04c4fdaf1ac6eaa62c74056409d Mon Sep 17 00:00:00 2001 From: Ahmed Bougacha Date: Tue, 7 Oct 2025 14:44:20 -0700 Subject: [PATCH 2/2] [AArch64] Bump default CPUs for iOS 18/watchOS 26 to A10/S9. (#162325) We previously bumped the defaults for 26.0 Apple OS targets to conservative CPU targets in 69d141712a10. We can further bump it for watchOS arm64 (which lets us be a little bit more aggressive than arm64e/arm64_32), as well as for the iOS predecessor, iOS 18. (cherry picked from commit b54f01e91163abb7cfcca76da34efebbee4622b4) --- clang/lib/Driver/ToolChains/Arch/AArch64.cpp | 7 +++++-- clang/test/Driver/aarch64-cpu-defaults-appleos26.c | 10 ++++++++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/clang/lib/Driver/ToolChains/Arch/AArch64.cpp b/clang/lib/Driver/ToolChains/Arch/AArch64.cpp index 98f5efbe5652f..eb5d542f55605 100644 --- a/clang/lib/Driver/ToolChains/Arch/AArch64.cpp +++ b/clang/lib/Driver/ToolChains/Arch/AArch64.cpp @@ -57,6 +57,9 @@ std::string aarch64::getAArch64TargetCPU(const ArgList &Args, // iOS 26 only runs on apple-a12 and later CPUs. if (!Triple.isOSVersionLT(26)) return "apple-a12"; + // arm64 (non-e) iOS 18 only runs on apple-a10 and later CPUs. + if (!Triple.isOSVersionLT(18) && !Triple.isArm64e()) + return "apple-a10"; } if (Triple.isWatchOS()) { @@ -64,8 +67,8 @@ std::string aarch64::getAArch64TargetCPU(const ArgList &Args, // arm64_32/arm64e watchOS requires S4 before watchOS 26, S6 after. if (Triple.getArch() == llvm::Triple::aarch64_32 || Triple.isArm64e()) return Triple.isOSVersionLT(26) ? "apple-s4" : "apple-s6"; - // arm64 (non-e, non-32) watchOS comes later, and requires S6 anyway. - return "apple-s6"; + // arm64 (non-e, non-32) watchOS comes later, and requires S9 anyway. + return "apple-s9"; } if (Triple.isXROS()) { diff --git a/clang/test/Driver/aarch64-cpu-defaults-appleos26.c b/clang/test/Driver/aarch64-cpu-defaults-appleos26.c index 99176050bf5ae..fe468a57c6763 100644 --- a/clang/test/Driver/aarch64-cpu-defaults-appleos26.c +++ b/clang/test/Driver/aarch64-cpu-defaults-appleos26.c @@ -4,12 +4,16 @@ // RUN: %clang -target arm64-apple-ios26 -### -c %s 2>&1 | FileCheck %s --check-prefix=A12 // RUN: %clang -target arm64e-apple-ios26 -### -c %s 2>&1 | FileCheck %s --check-prefix=A12 +/// iOS 18 came before iOS 26, compare its defaults. +// RUN: %clang -target arm64-apple-ios18 -### -c %s 2>&1 | FileCheck %s --check-prefix=A10 +// RUN: %clang -target arm64e-apple-ios18 -### -c %s 2>&1 | FileCheck %s --check-prefix=A12 + /// arm64e/arm64_32 watchOS 26 default to apple-s6. // RUN: %clang -target arm64e-apple-watchos26 -### -c %s 2>&1 | FileCheck %s --check-prefix=S6 // RUN: %clang -target arm64_32-apple-watchos26 -### -c %s 2>&1 | FileCheck %s --check-prefix=S6 -/// arm64 is new in watchOS 26, and defaults to apple-s6. -// RUN: %clang -target arm64-apple-watchos26 -### -c %s 2>&1 | FileCheck %s --check-prefix=S6 +/// arm64 is new in watchOS 26, and defaults to apple-s9. +// RUN: %clang -target arm64-apple-watchos26 -### -c %s 2>&1 | FileCheck %s --check-prefix=S9 /// llvm usually treats tvOS like iOS, but it runs on different hardware. // RUN: %clang -target arm64-apple-tvos26 -### -c %s 2>&1 | FileCheck %s --check-prefix=A7 @@ -18,5 +22,7 @@ /// Simulators are tested with other Mac-like targets in aarch64-mac-cpus.c. // A12: "-target-cpu" "apple-a12" +// A10: "-target-cpu" "apple-a10" // S6: "-target-cpu" "apple-s6" +// S9: "-target-cpu" "apple-s9" // A7: "-target-cpu" "apple-a7"