[all-commits] [llvm/llvm-project] 577e9a: [WebAssembly] WASIP3 Library Call Thread Context S...

Sy Brand via All-commits all-commits at lists.llvm.org
Tue May 26 15:46:35 PDT 2026


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 577e9a7cc82faf3dae98dba4aea917a6ffaab293
      https://github.com/llvm/llvm-project/commit/577e9a7cc82faf3dae98dba4aea917a6ffaab293
  Author: Sy Brand <sy.brand at fastly.com>
  Date:   2026-05-26 (Tue, 26 May 2026)

  Changed paths:
    M clang/lib/Basic/Targets/WebAssembly.cpp
    M clang/lib/Basic/Targets/WebAssembly.h
    M clang/lib/Driver/ToolChains/WebAssembly.cpp
    M clang/test/Preprocessor/wasm-target-features.c
    A lld/test/wasm/stack-pointer-abi.s
    A lld/test/wasm/thread-context-abi-mismatch.s
    A lld/test/wasm/tls-libcall.s
    M lld/wasm/Config.h
    M lld/wasm/Driver.cpp
    M lld/wasm/Options.td
    M lld/wasm/SyntheticSections.cpp
    M lld/wasm/Writer.cpp
    M llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCTargetDesc.h
    M llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp
    M llvm/lib/Target/WebAssembly/WebAssemblyExplicitLocals.cpp
    M llvm/lib/Target/WebAssembly/WebAssemblyFrameLowering.cpp
    M llvm/lib/Target/WebAssembly/WebAssemblyFrameLowering.h
    M llvm/lib/Target/WebAssembly/WebAssemblyISelDAGToDAG.cpp
    M llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
    M llvm/lib/Target/WebAssembly/WebAssemblyLateEHPrepare.cpp
    M llvm/lib/Target/WebAssembly/WebAssemblyRegStackify.cpp
    M llvm/lib/Target/WebAssembly/WebAssemblySubtarget.cpp
    M llvm/lib/Target/WebAssembly/WebAssemblySubtarget.h
    M llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
    M llvm/lib/Target/WebAssembly/WebAssemblyUtilities.cpp
    M llvm/lib/Target/WebAssembly/WebAssemblyUtilities.h
    A llvm/test/CodeGen/WebAssembly/stack-abi.ll
    M llvm/test/CodeGen/WebAssembly/thread_pointer.ll
    M llvm/test/CodeGen/WebAssembly/tls-local-exec.ll
    A llvm/test/DebugInfo/WebAssembly/thread-context-abi.ll

  Log Message:
  -----------
  [WebAssembly] WASIP3 Library Call Thread Context Support (#175800)

The [WebAssembly Component
Model](https://component-model.bytecodealliance.org/) has added support
for [cooperative
multithreading](https://github.com/WebAssembly/component-model/pull/557).
This has been implemented in the [Wasmtime
engine](https://github.com/bytecodealliance/wasmtime/pull/11751) and is
part of the wider project of [WASI preview
3](https://wasi.dev/roadmap#upcoming-wasi-03-releases), which is
currently tracked
[here](https://github.com/orgs/bytecodealliance/projects/16).

These changes require updating the way that `__stack_pointer` and
`__tls_base` work purely for a new `wasm32-wasip3` target; other targets
will not be touched. Specifically, rather than using a Wasm global for
tracking the stack pointer and TLS base, the new
[`context.get/set`](https://github.com/WebAssembly/component-model/blob/main/design/mvp/CanonicalABI.md#-canon-contextget)
component model builtin functions will be used (the intention being that
runtimes will need to aggressively optimize these calls into single
load/stores). For justification on this choice rather than switching out
the global at context-switch boundaries, see [this
comment](https://github.com/WebAssembly/wasi-libc/issues/691#issuecomment-3716405618)
and [this
comment](https://github.com/WebAssembly/wasi-libc/issues/691#issuecomment-3716916730).

This PR adds support for using library calls instead of globals for
holding the stack pointer and TLS base. When used, this thread context
ABI emits calls to `__wasm_{get,set}_{stack_pointer,tls_base}` when
needed. These functions can then be implemented in `libc`. This is
enabled only for the WASIp3 target.

There is a temporary macro define for `__wasm_libcall_thread_context__`
which can be removed once `wasi-libc` has fully migrated to the new ABI
for the WASIp3 target.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list