diff options
author | Fangrui Song <maskray@google.com> | 2020-03-17 12:40:19 -0700 |
---|---|---|
committer | Fangrui Song <maskray@google.com> | 2020-03-31 08:46:12 -0700 |
commit | eb4663d8c6add351d758748383f1a9fc231e5e64 (patch) | |
tree | 2287d04d40ec50579d5e9936169e35e2f8b4fe84 /llvm/lib/Support/Parallel.cpp | |
parent | f3a7d790df3357d52c10ec5ef48606944bcf5c6c (diff) | |
download | llvm-eb4663d8c6add351d758748383f1a9fc231e5e64.zip llvm-eb4663d8c6add351d758748383f1a9fc231e5e64.tar.gz llvm-eb4663d8c6add351d758748383f1a9fc231e5e64.tar.bz2 |
[lld][COFF][ELF][WebAssembly] Replace --[no-]threads /threads[:no] with --threads={1,2,...} /threads:{1,2,...}
--no-threads is a name copied from gold.
gold has --no-thread, --thread-count and several other --thread-count-*.
There are needs to customize the number of threads (running several lld
processes concurrently or customizing the number of LTO threads).
Having a single --threads=N is a straightforward replacement of gold's
--no-threads + --thread-count.
--no-threads is used rarely. So just delete --no-threads instead of
keeping it for compatibility for a while.
If --threads= is specified (ELF,wasm; COFF /threads: is similar),
--thinlto-jobs= defaults to --threads=,
otherwise all available hardware threads are used.
There is currently no way to override a --threads={1,2,...}. It is still
a debate whether we should use --threads=all.
Reviewed By: rnk, aganea
Differential Revision: https://reviews.llvm.org/D76885
Diffstat (limited to 'llvm/lib/Support/Parallel.cpp')
-rw-r--r-- | llvm/lib/Support/Parallel.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/llvm/lib/Support/Parallel.cpp b/llvm/lib/Support/Parallel.cpp index 0272a53..7f6ce82 100644 --- a/llvm/lib/Support/Parallel.cpp +++ b/llvm/lib/Support/Parallel.cpp @@ -20,6 +20,8 @@ #include <thread> #include <vector> +llvm::ThreadPoolStrategy llvm::parallel::strategy; + namespace llvm { namespace parallel { namespace detail { @@ -78,6 +80,9 @@ public: T.join(); } + struct Creator { + static void *call() { return new ThreadPoolExecutor(strategy); } + }; struct Deleter { static void call(void *Ptr) { ((ThreadPoolExecutor *)Ptr)->stop(); } }; @@ -131,7 +136,8 @@ Executor *Executor::getDefaultExecutor() { // are more frequent with the debug static runtime. // // This also prevents intermittent deadlocks on exit with the MinGW runtime. - static ManagedStatic<ThreadPoolExecutor, object_creator<ThreadPoolExecutor>, + + static ManagedStatic<ThreadPoolExecutor, ThreadPoolExecutor::Creator, ThreadPoolExecutor::Deleter> ManagedExec; static std::unique_ptr<ThreadPoolExecutor> Exec(&(*ManagedExec)); |