diff --git a/llvm/lib/Support/Unix/Threading.inc b/llvm/lib/Support/Unix/Threading.inc --- a/llvm/lib/Support/Unix/Threading.inc +++ b/llvm/lib/Support/Unix/Threading.inc @@ -371,6 +371,14 @@ } return CPU_COUNT(&Enabled); } +#elif defined(__linux__) && defined(__aarch64__) +static int computeHostNumPhysicalCores() { + cpu_set_t Affinity; + if (sched_getaffinity(0, sizeof(Affinity), &Affinity) == 0) + return CPU_COUNT(&Affinity); + + return -1; +} #elif defined(__linux__) && defined(__s390x__) static int computeHostNumPhysicalCores() { return sysconf(_SC_NPROCESSORS_ONLN); diff --git a/llvm/unittests/Support/Threading.cpp b/llvm/unittests/Support/Threading.cpp --- a/llvm/unittests/Support/Threading.cpp +++ b/llvm/unittests/Support/Threading.cpp @@ -28,6 +28,7 @@ // some systems. return (Host.isOSWindows() && llvm_is_multithreaded()) || Host.isOSDarwin() || (Host.isX86() && Host.isOSLinux()) || + (Host.isAArch64() && Host.isOSLinux()) || (Host.isOSLinux() && !Host.isAndroid()) || (Host.isSystemZ() && Host.isOSzOS()); #else