[all-commits] [llvm/llvm-project] 74f984: [lld][WebAssembly] Allow use of statically allocat...

Sam Clegg via All-commits all-commits at lists.llvm.org
Mon May 23 17:27:52 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 74f98419770041deb983b4f736ebdc06de4ee2ac
      https://github.com/llvm/llvm-project/commit/74f98419770041deb983b4f736ebdc06de4ee2ac
  Author: Sam Clegg <sbc at chromium.org>
  Date:   2022-05-23 (Mon, 23 May 2022)

  Changed paths:
    M lld/test/wasm/data-segments.ll
    M lld/test/wasm/tls_init_symbols.s
    M lld/wasm/Writer.cpp
    M llvm/include/llvm/BinaryFormat/Wasm.h

  Log Message:
  -----------
  [lld][WebAssembly] Allow use of statically allocated TLS region.

It turns out we were already allocating static address space for TLS
data along with the non-TLS static data, but this space was going
unused/ignored.

With this change, we include the TLS segment in `__wasm_init_memory`
(which does the work of loading the passive segments into memory when a
module is first loaded).  We also set the `__tls_base` global to point
to the start of this segment.

This means that the runtime can use this static copy of the TLS data for
the first/primary thread if it chooses, rather than doing a runtime
allocation prior to calling `__wasm_init_tls`.

Practically speaking, this will allow emscripten to avoid dynamic
allocation of TLS region on the main thread.

Differential Revision: https://reviews.llvm.org/D126107




More information about the All-commits mailing list