[PATCH] D122922: [lld][common][lld-macho] Support per-thread allocators and StringSavers

Jez Ng via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 1 15:32:21 PDT 2022


int3 added inline comments.


================
Comment at: lld/Common/Memory.cpp:35
+PerThreadContext *CommonLinkerContext::perThreadContext() {
+  llvm::sys::RWMutex &contextMutex = context().contextMutex;
+  void *contextKey = &threadTag;
----------------
I was hoping we could avoid mutexes altogether. I was thinking of something like

```
std::atomic<size_t> contextCount;
std::array<PerThreadContext *, MAX_THREADS> perThreadContexts;

if (threadTag == 0) {
  threadTag = contextCount++;
  perThreadContexts[threadTag] = new PerThreadContext;
}
```


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D122922/new/

https://reviews.llvm.org/D122922



More information about the llvm-commits mailing list