[llvm] [LTO] Set default Darwin CPU to apple-a7 for AArch64 (PR #81540)

via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 12 13:36:35 PST 2024


https://github.com/AtariDreams created https://github.com/llvm/llvm-project/pull/81540

Use apple-a7 as default for AArch64 Darwin targets that are not arm64e, as apple-a7 is the first AArch64 CPU that can run Darwin.

>From b47c3da8673d171960919d5e8a9bd388e86803d4 Mon Sep 17 00:00:00 2001
From: Rose <83477269+AtariDreams at users.noreply.github.com>
Date: Mon, 12 Feb 2024 16:31:12 -0500
Subject: [PATCH] [LTO] Set default cpu to apple-a7 for aarch64

Use apple-a7 as default for AArch64 Darwin targets that are not not arm64e, as apple-a7 is the first AArch64 cpu that can run Darwin.
---
 llvm/lib/LTO/LTOCodeGenerator.cpp     | 5 +++--
 llvm/lib/LTO/ThinLTOCodeGenerator.cpp | 7 +++++--
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/llvm/lib/LTO/LTOCodeGenerator.cpp b/llvm/lib/LTO/LTOCodeGenerator.cpp
index 52d8fff14be9ce..93fdde9c9b1d97 100644
--- a/llvm/lib/LTO/LTOCodeGenerator.cpp
+++ b/llvm/lib/LTO/LTOCodeGenerator.cpp
@@ -417,8 +417,9 @@ bool LTOCodeGenerator::determineTarget() {
       Config.CPU = "yonah";
     else if (Triple.isArm64e())
       Config.CPU = "apple-a12";
-    else if (Triple.getArch() == llvm::Triple::aarch64 ||
-             Triple.getArch() == llvm::Triple::aarch64_32)
+    else if (Triple.getArch() == llvm::Triple::aarch64)
+      Config.MCpu = "apple-a7";
+    else if (Triple.getArch() == llvm::Triple::aarch64_32)
       Config.CPU = "cyclone";
   }
 
diff --git a/llvm/lib/LTO/ThinLTOCodeGenerator.cpp b/llvm/lib/LTO/ThinLTOCodeGenerator.cpp
index 535faf5f780474..1c58cef5c3dc8d 100644
--- a/llvm/lib/LTO/ThinLTOCodeGenerator.cpp
+++ b/llvm/lib/LTO/ThinLTOCodeGenerator.cpp
@@ -546,8 +546,11 @@ static void initTMBuilder(TargetMachineBuilder &TMBuilder,
       TMBuilder.MCpu = "core2";
     else if (TheTriple.getArch() == llvm::Triple::x86)
       TMBuilder.MCpu = "yonah";
-    else if (TheTriple.getArch() == llvm::Triple::aarch64 ||
-             TheTriple.getArch() == llvm::Triple::aarch64_32)
+    else if (TheTriple.isArm64e())
+      TMBuilder.MCpu = "apple-a12";
+    else if (TheTriple.getArch() == llvm::Triple::aarch64)
+      TMBuilder.MCpu = "apple-a7";
+    else if (TheTriple.getArch() == llvm::Triple::aarch64_32)
       TMBuilder.MCpu = "cyclone";
   }
   TMBuilder.TheTriple = std::move(TheTriple);



More information about the llvm-commits mailing list