[PATCH] D108850: [LLD] Remove global state in lldCommon
Mehdi AMINI via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 14 16:40:54 PDT 2021
mehdi_amini added a comment.
> The goal is to make the patch that changes Support as small as possible. MLIR uses the parallel APIs, so we should ask them (@mehdi_amini, @rriddle, maybe others) to review the changes to llvm/Support/Parallel.h.
Actually MLIR does not use Parallel.h anymore, especially to avoid relying on any global. We're using instead a ThreadPool owned by the MLIRContext, the client applications can inject a thread pool in the context to manage sharing threads how they see fit.
Our wrappers are in https://github.com/llvm/llvm-project/blob/main/mlir/include/mlir/IR/Threading.h and operate around llvm/Support/ThreadPool.h.
The mechanism introduced in Parallel.h in this revision (wrapThreadState) seems mostly like some sort of "workaround" to be able to continue to rely on some global way to pass state around in `lld` instead of having something more explicit, which we favored in MLIR (where like in LLVM, the Context is fairly centric and not accessed through a global).
================
Comment at: llvm/lib/Support/Parallel.cpp:87
+ std::function<void(std::function<void()> &)> ThreadStateFn;
+
----------------
Seems like worth documenting.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D108850/new/
https://reviews.llvm.org/D108850
More information about the llvm-commits
mailing list