[PATCH] D126107: [lld][WebAssembly] Allow first thread to use static TLS region

Sam Clegg via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun May 22 13:16:10 PDT 2022


sbc100 added a comment.

OK I simplified and refactored and re-wrote the description.     Maybe it will be more clear what is going on here now?



================
Comment at: lld/wasm/Writer.cpp:280
     if (!config->relocatable && seg->isTLS()) {
-      if (config->sharedMemory) {
+      if (WasmSym::tlsSize) {
         auto *tlsSize = cast<DefinedGlobal>(WasmSym::tlsSize);
----------------
tlively wrote:
> Why these changes?
P


================
Comment at: lld/wasm/Writer.cpp:280
     if (!config->relocatable && seg->isTLS()) {
-      if (config->sharedMemory) {
+      if (WasmSym::tlsSize) {
         auto *tlsSize = cast<DefinedGlobal>(WasmSym::tlsSize);
----------------
sbc100 wrote:
> tlively wrote:
> > Why these changes?
> P
Previously `__tls_base` was not set at all (just set to zero) in the shared memory case, and we relied on the embedder always calling `__wasm_tls_init` to set it.

After this change the embedder only needs to call `__wasm_tls_init` on secondary threads.

In the primary thread we initialize `__tls_base`here to the offset of the segment from `__memory_base`, then we call 
`__wasm_tls_init` as part of `__wasm_memory_init`.. which adjusts it accordingly.




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126107



More information about the llvm-commits mailing list