[llvm] b28f317 - Fix build for ThreadPool when using -DLLVM_ENABLE_THREADS=OFF

Mehdi Amini via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 3 18:23:31 PST 2021


Author: Mehdi Amini
Date: 2021-12-04T02:23:20Z
New Revision: b28f317c81561aa6c52681e03e9f68401e173966

URL: https://github.com/llvm/llvm-project/commit/b28f317c81561aa6c52681e03e9f68401e173966
DIFF: https://github.com/llvm/llvm-project/commit/b28f317c81561aa6c52681e03e9f68401e173966.diff

LOG: Fix build for ThreadPool when using -DLLVM_ENABLE_THREADS=OFF

Differential Revision: https://reviews.llvm.org/D115019

Added: 
    

Modified: 
    llvm/include/llvm/Support/ThreadPool.h
    llvm/lib/Support/ThreadPool.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/Support/ThreadPool.h b/llvm/include/llvm/Support/ThreadPool.h
index b0f4c8e04ca2..e1b77a6bb554 100644
--- a/llvm/include/llvm/Support/ThreadPool.h
+++ b/llvm/include/llvm/Support/ThreadPool.h
@@ -40,8 +40,7 @@ class ThreadPool {
   /// execution resources (threads, cores, CPUs)
   /// Defaults to using the maximum execution resources in the system, but
   /// accounting for the affinity mask.
-  ThreadPool(ThreadPoolStrategy S = hardware_concurrency())
-      : Strategy(S), MaxThreadCount(S.compute_thread_count()) {}
+  ThreadPool(ThreadPoolStrategy S = hardware_concurrency());
 
   /// Blocking destructor: the pool will wait for all the threads to complete.
   ~ThreadPool();

diff  --git a/llvm/lib/Support/ThreadPool.cpp b/llvm/lib/Support/ThreadPool.cpp
index 734e8f8e274f..b917fda5f7ef 100644
--- a/llvm/lib/Support/ThreadPool.cpp
+++ b/llvm/lib/Support/ThreadPool.cpp
@@ -20,6 +20,9 @@ using namespace llvm;
 
 #if LLVM_ENABLE_THREADS
 
+ThreadPool::ThreadPool(ThreadPoolStrategy S)
+    : Strategy(S), MaxThreadCount(S.compute_thread_count()) {}
+
 void ThreadPool::grow() {
   if (Threads.size() >= MaxThreadCount)
     return; // Already hit the max thread pool size.
@@ -94,8 +97,8 @@ ThreadPool::~ThreadPool() {
 #else // LLVM_ENABLE_THREADS Disabled
 
 // No threads are launched, issue a warning if ThreadCount is not 0
-ThreadPool::ThreadPool(ThreadPoolStrategy S)
-    : ThreadCount(S.compute_thread_count()) {
+ThreadPool::ThreadPool(ThreadPoolStrategy S) : MaxThreadCount(1) {
+  int ThreadCount = S.compute_thread_count();
   if (ThreadCount != 1) {
     errs() << "Warning: request a ThreadPool with " << ThreadCount
            << " threads, but LLVM_ENABLE_THREADS has been turned off\n";


        


More information about the llvm-commits mailing list