[all-commits] [llvm/llvm-project] a1ae95: [WebAssembly] Disallow 'shared-mem' rather than 'a...

Thomas Lively via All-commits all-commits at lists.llvm.org
Fri May 8 13:52:58 PDT 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: a1ae9566ea9ce46bf7f2af9ab1253eed05b5b622
      https://github.com/llvm/llvm-project/commit/a1ae9566ea9ce46bf7f2af9ab1253eed05b5b622
  Author: Thomas Lively <tlively at google.com>
  Date:   2020-05-08 (Fri, 08 May 2020)

  Changed paths:
    M lld/test/wasm/shared-memory-no-atomics.yaml
    M lld/wasm/Writer.cpp
    M llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp
    M llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
    M llvm/test/CodeGen/WebAssembly/target-features-tls.ll

  Log Message:
  -----------
  [WebAssembly] Disallow 'shared-mem' rather than 'atomics'

Summary:
The WebAssembly backend automatically lowers atomic operations and TLS
to nonatomic operations and non-TLS data when either are present and
the atomics or bulk-memory features are not present, respectively. The
resulting object is no longer thread-safe, so the linker has to be
told not to allow it to be linked into a module with shared
memory. This was previously done by disallowing the 'atomics' feature,
which prevented any objct with its atomic operations or TLS removed
from being linked with any object containing atomics or TLS, and
therefore preventing it from being linked into a module with shared
memory since shared memory requires atomics.

However, as of https://github.com/WebAssembly/threads/issues/144, the
validation rules are relaxed to allow atomic operations to validate
with unshared memories, which makes it perfectly safe to link an
object with stripped atomics and TLS with another object that still
contains TLS and atomics as long as the resulting module has an
unshared memory. To allow this kind of link, this patch disallows a
pseudo-feature 'shared-mem' rather than 'atomics' to communicate to
the linker that the object is not thread-safe. This means that the
'atomics' feature is available to accurately reflect whether or not an
object has atomics enabled.

As a drive-by tweak, this change also requires that bulk-memory be
enabled in addition to atomics in order to use shared memory. This is
because initializing shared memories requires bulk-memory operations.

Reviewers: aheejin, sbc100

Subscribers: dschuff, jgravelle-google, hiraditya, sunfish, jfb, llvm-commits

Tags: #llvm

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




More information about the All-commits mailing list