[PATCH] D69597: Implement `sys::getHostCPUName()` for Darwin ARM

Eli Friedman via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 30 13:16:08 PDT 2019


efriedma added inline comments.


================
Comment at: llvm/lib/Support/Host.cpp:1238
+    switch (hostInfo.cpu_subtype) {
+    case CPU_SUBTYPE_ARM_V7S:
+      return "swift";
----------------
beanz wrote:
> efriedma wrote:
> > What do 64-bit devices return here?  (I assume the call returns CPU_TYPE_ARM for 32-bit code regardless of the CPU?)
> Modern Apple 64-bit devices can't execute 32bit code, so that really should never happen. If it does, returning a value that matches the binary's CPU type/subtype is probably reasonable.
> 
> I could break the arm 32/64-bit implementations up into separate `ifdef` blocks if that seems more sane to you. In that case we could return `cyclone` for arm 32 in the arm 64 implementation, but we would still likely want the sys call to determine if the cpu type is 64 or 32 bit.
If you're not sure what cpu_type the kernel returns for a 32-bit userspace on top of a 64-bit kernel, you could check on x86.  That said, I don't want to add codepaths you can't reasonably test.

Splitting the ifdef blocks probably makes sense.


================
Comment at: llvm/lib/Support/Host.cpp:1245
+  if (hostInfo.cpu_type == CPU_TYPE_ARM64) {
+   switch (hostInfo.cpu_subtype) {
+    default:
----------------
beanz wrote:
> efriedma wrote:
> > Can we skip the syscall on `__aarch64__` targets, since you don't really check the result?
> Sure... Until arm64e pointer authentication lands in upstream (see @rjmccall's RFC). At which point this changes. I tried to structure the code to take that into account.
Okay.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D69597/new/

https://reviews.llvm.org/D69597





More information about the llvm-commits mailing list