[clang] 3ab3f3c - After 09158252f777c2e2f06a86b154c44abcbcf9bb74, fix build when -DLLVM_ENABLE_THREADS=OFF

Alexandre Ganea via cfe-commits cfe-commits at lists.llvm.org
Sat Mar 28 10:55:11 PDT 2020


Author: Alexandre Ganea
Date: 2020-03-28T13:54:58-04:00
New Revision: 3ab3f3c5d5825476dc1be15992f7c964629de688

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

LOG: After 09158252f777c2e2f06a86b154c44abcbcf9bb74, fix build when -DLLVM_ENABLE_THREADS=OFF

Tested on Linux with Clang 9, and on Windows with Visual Studio 2019 16.5.1 with -DLLVM_ENABLE_THREADS=ON and OFF.

Added: 
    

Modified: 
    clang/test/Driver/lto-jobs.c
    llvm/lib/Support/Threading.cpp

Removed: 
    


################################################################################
diff  --git a/clang/test/Driver/lto-jobs.c b/clang/test/Driver/lto-jobs.c
index 539867713b07..c28d0ad300f4 100644
--- a/clang/test/Driver/lto-jobs.c
+++ b/clang/test/Driver/lto-jobs.c
@@ -8,4 +8,4 @@
 // RUN: %clang -target x86_64-apple-darwin13.3.0 -### %s -flto=thin -flto-jobs=5 2> %t
 // RUN: FileCheck -check-prefix=CHECK-LINK-THIN-JOBS2-ACTION < %t %s
 //
-// CHECK-LINK-THIN-JOBS2-ACTION: "-mllvm" "-threads=5"
+// CHECK-LINK-THIN-JOBS2-ACTION: "-mllvm" "-threads={{[0-9]+}}"

diff  --git a/llvm/lib/Support/Threading.cpp b/llvm/lib/Support/Threading.cpp
index 39de05892981..4bf373ddbd72 100644
--- a/llvm/lib/Support/Threading.cpp
+++ b/llvm/lib/Support/Threading.cpp
@@ -94,26 +94,6 @@ unsigned llvm::ThreadPoolStrategy::compute_thread_count() const {
   return MaxThreadCount;
 }
 
-Optional<ThreadPoolStrategy>
-llvm::get_threadpool_strategy(StringRef Num, ThreadPoolStrategy Default) {
-  if (Num == "all")
-    return llvm::hardware_concurrency();
-  if (Num.empty())
-    return Default;
-  unsigned V;
-  if (Num.getAsInteger(10, V))
-    return None; // malformed 'Num' value
-  if (V == 0)
-    return Default;
-
-  // Do not take the Default into account. This effectively disables
-  // heavyweight_hardware_concurrency() if the user asks for any number of
-  // threads on the cmd-line.
-  ThreadPoolStrategy S = llvm::hardware_concurrency();
-  S.ThreadsRequested = V;
-  return S;
-}
-
 namespace {
 struct SyncThreadInfo {
   void (*UserFn)(void *);
@@ -150,3 +130,23 @@ void llvm::llvm_execute_on_thread_async(
 }
 
 #endif
+
+Optional<ThreadPoolStrategy>
+llvm::get_threadpool_strategy(StringRef Num, ThreadPoolStrategy Default) {
+  if (Num == "all")
+    return llvm::hardware_concurrency();
+  if (Num.empty())
+    return Default;
+  unsigned V;
+  if (Num.getAsInteger(10, V))
+    return None; // malformed 'Num' value
+  if (V == 0)
+    return Default;
+
+  // Do not take the Default into account. This effectively disables
+  // heavyweight_hardware_concurrency() if the user asks for any number of
+  // threads on the cmd-line.
+  ThreadPoolStrategy S = llvm::hardware_concurrency();
+  S.ThreadsRequested = V;
+  return S;
+}


        


More information about the cfe-commits mailing list