hardware_physical_concurrency() should return 1 when LLVM is built with LLVM_ENABLE_THREADS=OFF

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@284283 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Mehdi Amini 2016-10-14 21:32:35 +00:00
parent 31164bc2c9
commit cb11533e7b
2 changed files with 4 additions and 0 deletions

View 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();
}

View 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();