[PATCH] D133759: [Support] Access threadIndex via a wrapper function
Andrew Ng via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 13 07:57:40 PDT 2022
andrewng added a comment.
A couple of suggestions in response to the comment on D133003 <https://reviews.llvm.org/D133003> regarding no TLS support.
================
Comment at: llvm/include/llvm/Support/Parallel.h:31-40
+#ifdef _WIN32
+// Direct access to thread_local variables from a different DLL isn't
+// possible with Windows Native TLS.
+unsigned getThreadIndex();
+#else
+// Don't access this directly, use the getThreadIndex wrapper.
extern thread_local unsigned threadIndex;
----------------
Perhaps place this block within:
```
#if LLVM_ENABLE_THREADS
<HERE>
#else
inline unsigned getThreadIndex() { return 0; }
#endif
```
Which along with the other change, should fix any builds with `LLVM_ENABLE_THREADS=0` that do not support TLS.
================
Comment at: llvm/lib/Support/Parallel.cpp:21-27
+#ifdef _WIN32
+static thread_local unsigned threadIndex;
+
+unsigned llvm::parallel::getThreadIndex() { return threadIndex; }
+#else
thread_local unsigned llvm::parallel::threadIndex;
+#endif
----------------
Move this block down to below the `#if LLVM_ENABLE_THREADS` (line 31) and adjust for the namespaces.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D133759/new/
https://reviews.llvm.org/D133759
More information about the llvm-commits
mailing list