[llvm] Add thread-local overrides for `llvm::errs()` and `llvm::outs()`. (PR #90374)

Alexandre Ganea via llvm-commits llvm-commits at lists.llvm.org
Tue May 14 10:07:41 PDT 2024


aganea wrote:

Similar to what is discussed above, in LLD we have a global context: https://github.com/llvm/llvm-project/blob/main/lld/Common/CommonLinkerContext.cpp#L23. I have a unfinished yet patch that makes that thread_local, but that requires other core changes in LLVMSupport (some ManagedStatics for instance). Ideally, I'd like to use LLVM "tools" like Clang or LLD in a daemon, mainly for performance reasons. In that perspective, each thread context will be associated to a "tool instance", however a tool could use many threads at any point (LLD being the obvious example). I think we would need something similiar at the LLVMSupport level, a global thread_local context that contains all that is "static" today, cl::opt states, std streams in this PR, some ManagedObjects that are tool-specific, etc. That goal would be to get to this: https://reviews.llvm.org/D86351 and beyond (inputs caching, direct communication between compiler and linker without going through the FS, caching of compiler steps like zapcc, etc). I think all this might go a bit along what is proposed in this PR.

https://github.com/llvm/llvm-project/pull/90374


More information about the llvm-commits mailing list