[lld] [WebAssembly] Fix __init_tls_base global in coop threading (PR #208597)

Sam Clegg via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 13 11:58:19 PDT 2026


================
@@ -1416,13 +1416,32 @@ void Writer::createInitMemoryFunction() {
         // When we initialize the TLS segment we also set the TLS base.
         // This allows the runtime to use this static copy of the TLS data
         // for the first/main thread.
+        //
+        // Note that for `--cooperative-threading` this additionally configures
+        // the `__init_tls_base` global which is the initial TLS value that can
+        // be used for all new component model tasks. For non-PIC builds this
+        // global's statically known value is now calculated, so it's updated
+        // here. For PIC builds the result of the address computation above is
+        // what's stored into the global.
+        //
+        // Finally, note that a temporary local is used here to ensure that the
+        // result of the addition above can be reused a number of times.
----------------
sbc100 wrote:

Is this last sentence still accurate?

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


More information about the llvm-commits mailing list