[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:50:02 PST 2024
https://github.com/AtariDreams updated https://github.com/llvm/llvm-project/pull/81540
>From d38f16b61a5223fb541fdfe151ae08643fd70505 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 Darwin CPU to apple-a7 for AArch64
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.
---
llvm/lib/LTO/LTOCodeGenerator.cpp | 5 +++--
llvm/lib/LTO/LTOModule.cpp | 5 +++--
llvm/lib/LTO/ThinLTOCodeGenerator.cpp | 7 +++++--
llvm/lib/Object/MachOObjectFile.cpp | 2 +-
4 files changed, 12 insertions(+), 7 deletions(-)
diff --git a/llvm/lib/LTO/LTOCodeGenerator.cpp b/llvm/lib/LTO/LTOCodeGenerator.cpp
index 52d8fff14be9ce..ba5b189b23225e 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.CPU = "apple-a7";
+ else if (Triple.getArch() == llvm::Triple::aarch64_32)
Config.CPU = "cyclone";
}
diff --git a/llvm/lib/LTO/LTOModule.cpp b/llvm/lib/LTO/LTOModule.cpp
index f839fe944e18f7..fc333ab6a5c78a 100644
--- a/llvm/lib/LTO/LTOModule.cpp
+++ b/llvm/lib/LTO/LTOModule.cpp
@@ -224,8 +224,9 @@ LTOModule::makeLTOModule(MemoryBufferRef Buffer, const TargetOptions &options,
CPU = "yonah";
else if (Triple.isArm64e())
CPU = "apple-a12";
- else if (Triple.getArch() == llvm::Triple::aarch64 ||
- Triple.getArch() == llvm::Triple::aarch64_32)
+ else if (Triple.getArch() == llvm::Triple::aarch64)
+ CPU = "apple-a7";
+ else if (Triple.getArch() == llvm::Triple::aarch64_32)
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);
diff --git a/llvm/lib/Object/MachOObjectFile.cpp b/llvm/lib/Object/MachOObjectFile.cpp
index 1cfd0a069463e9..cb784a08d985ed 100644
--- a/llvm/lib/Object/MachOObjectFile.cpp
+++ b/llvm/lib/Object/MachOObjectFile.cpp
@@ -2797,7 +2797,7 @@ Triple MachOObjectFile::getArchTriple(uint32_t CPUType, uint32_t CPUSubType,
switch (CPUSubType & ~MachO::CPU_SUBTYPE_MASK) {
case MachO::CPU_SUBTYPE_ARM64_ALL:
if (McpuDefault)
- *McpuDefault = "cyclone";
+ *McpuDefault = "apple-a7";
if (ArchFlag)
*ArchFlag = "arm64";
return Triple("arm64-apple-darwin");
More information about the llvm-commits
mailing list