[clang] [Clang][AArch64] set default mtune for macOS (PR #179136)

Tomer Shafir via cfe-commits cfe-commits at lists.llvm.org
Tue Feb 10 10:09:18 PST 2026


================
@@ -97,6 +98,47 @@ std::string aarch64::getAArch64TargetCPU(const ArgList &Args,
   return getAArch64TargetCPUByTriple(Triple);
 }
 
+/// \return the target tune CPU LLVM name based on the target triple.
+static std::optional<std::string>
+getAArch64TargetTuneCPUByTriple(const llvm::Triple &Triple) {
+  // Apple Silicon macs default to the latest available target for tuning.
+  if (Triple.isTargetMachineMac() &&
+      Triple.getArch() == llvm::Triple::aarch64) {
+    return "apple-m5";
+  }
+  return std::nullopt;
+}
+
+/// \return the LLVM name of the AArch64 tune CPU we should target.
+/// Returns std::nullopt if no tune CPU should be specified.
+///
+/// Note: Unlike getAArch64TargetCPU, this function does not resolve
+/// CPU aliases, as it is currently not used for target architecture feature
+/// collection, but defers it to the backend.
+std::optional<std::string>
+aarch64::getAArch64TargetTuneCPU(const llvm::opt::ArgList &Args,
+                                 const llvm::Triple &Triple) {
+  std::string TuneCPU;
----------------
tomershafir wrote:

I think its not a very trivial function, and is not called on a hot path, then if a new caller appears the inline decl may be invalidated and it can be a bit harder to maintain

https://github.com/llvm/llvm-project/pull/179136


More information about the cfe-commits mailing list