Skip to content

Commit 3ab3f3c

Browse files
committed
After 0915825, 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.
1 parent 672e8bf commit 3ab3f3c

File tree

2 files changed

+21
-21
lines changed

2 files changed

+21
-21
lines changed

clang/test/Driver/lto-jobs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@
88
// RUN: %clang -target x86_64-apple-darwin13.3.0 -### %s -flto=thin -flto-jobs=5 2> %t
99
// RUN: FileCheck -check-prefix=CHECK-LINK-THIN-JOBS2-ACTION < %t %s
1010
//
11-
// CHECK-LINK-THIN-JOBS2-ACTION: "-mllvm" "-threads=5"
11+
// CHECK-LINK-THIN-JOBS2-ACTION: "-mllvm" "-threads={{[0-9]+}}"

llvm/lib/Support/Threading.cpp

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -94,26 +94,6 @@ unsigned llvm::ThreadPoolStrategy::compute_thread_count() const {
9494
return MaxThreadCount;
9595
}
9696

97-
Optional<ThreadPoolStrategy>
98-
llvm::get_threadpool_strategy(StringRef Num, ThreadPoolStrategy Default) {
99-
if (Num == "all")
100-
return llvm::hardware_concurrency();
101-
if (Num.empty())
102-
return Default;
103-
unsigned V;
104-
if (Num.getAsInteger(10, V))
105-
return None; // malformed 'Num' value
106-
if (V == 0)
107-
return Default;
108-
109-
// Do not take the Default into account. This effectively disables
110-
// heavyweight_hardware_concurrency() if the user asks for any number of
111-
// threads on the cmd-line.
112-
ThreadPoolStrategy S = llvm::hardware_concurrency();
113-
S.ThreadsRequested = V;
114-
return S;
115-
}
116-
11797
namespace {
11898
struct SyncThreadInfo {
11999
void (*UserFn)(void *);
@@ -150,3 +130,23 @@ void llvm::llvm_execute_on_thread_async(
150130
}
151131

152132
#endif
133+
134+
Optional<ThreadPoolStrategy>
135+
llvm::get_threadpool_strategy(StringRef Num, ThreadPoolStrategy Default) {
136+
if (Num == "all")
137+
return llvm::hardware_concurrency();
138+
if (Num.empty())
139+
return Default;
140+
unsigned V;
141+
if (Num.getAsInteger(10, V))
142+
return None; // malformed 'Num' value
143+
if (V == 0)
144+
return Default;
145+
146+
// Do not take the Default into account. This effectively disables
147+
// heavyweight_hardware_concurrency() if the user asks for any number of
148+
// threads on the cmd-line.
149+
ThreadPoolStrategy S = llvm::hardware_concurrency();
150+
S.ThreadsRequested = V;
151+
return S;
152+
}

0 commit comments

Comments
 (0)