[PATCH] D134658: Fix -mcpu=native on non-macos Apple platforms

Jon Roelofs via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 26 11:09:52 PDT 2022


jroelofs created this revision.
jroelofs added reviewers: ab, t.p.northover, keith.
Herald added subscribers: hiraditya, kristof.beyls.
Herald added a project: All.
jroelofs requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

The fallback to apple-m1 is not correct, for example, when llvm is built for
iOS hosts. When the host is ARM64e, we can do a little better, but otherwise
fall back on "generic".


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D134658

Files:
  llvm/lib/Support/Host.cpp


Index: llvm/lib/Support/Host.cpp
===================================================================
--- llvm/lib/Support/Host.cpp
+++ llvm/lib/Support/Host.cpp
@@ -43,6 +43,7 @@
 #include <mach/machine.h>
 #include <sys/param.h>
 #include <sys/sysctl.h>
+#include <TargetConditionals.h>
 #endif
 #ifdef _AIX
 #include <sys/systemcfg.h>
@@ -1362,10 +1363,18 @@
   case CPUFAMILY_ARM_LIGHTNING_THUNDER:
     return "apple-a13";
   case CPUFAMILY_ARM_FIRESTORM_ICESTORM:
-    return "apple-m1";
+    return "apple-a14";
   default:
+#if TARGET_OS_OSX
     // Default to the newest CPU we know about.
     return "apple-m1";
+#elif defined(__arm64e__)
+    // Pointer authentication requires ARMv8.3a+, and apple-a12 was the first
+    // Apple CPU to support that ISA.
+    return "apple-a12";
+#endif
+    return "generic";
+#endif
   }
 }
 #elif defined(_AIX)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D134658.462970.patch
Type: text/x-patch
Size: 860 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220926/003289a9/attachment.bin>


More information about the llvm-commits mailing list