hardware_physical_concurrency() should return 1 when LLVM is built with LLVM_ENABLE_T...
authorMehdi Amini <mehdi.amini@apple.com>
Fri, 14 Oct 2016 21:32:35 +0000 (21:32 +0000)
committerMehdi Amini <mehdi.amini@apple.com>
Fri, 14 Oct 2016 21:32:35 +0000 (21:32 +0000)
llvm-svn: 284283

llvm/include/llvm/Support/Threading.h
llvm/lib/Support/Threading.cpp

index 7e4a289..8c9c0da 100644 (file)
@@ -118,6 +118,7 @@ namespace llvm {
 
   /// Get the amount of currency based on physical cores, if available for the
   /// host system, otherwise falls back to thread::hardware_concurrency().
+  /// Returns 1 when LLVM is configured with LLVM_ENABLE_THREADS=OFF
   unsigned hardware_physical_concurrency();
 }
 
index 415c63f..fd303af 100644 (file)
@@ -119,6 +119,9 @@ void llvm::llvm_execute_on_thread(void (*Fn)(void*), void *UserData,
 #endif
 
 unsigned llvm::hardware_physical_concurrency() {
+#if !LLVM_ENABLE_THREADS
+  return 1;
+#endif
   int NumPhysical = sys::getHostNumPhysicalCores();
   if (NumPhysical == -1)
     return thread::hardware_concurrency();