[PATCH] D79542: [WebAssembly] Disallow 'shared-mem' rather than 'atomics'

Thomas Lively via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed May 6 19:53:54 PDT 2020


tlively created this revision.
tlively added reviewers: aheejin, sbc100.
Herald added subscribers: llvm-commits, jfb, sunfish, hiraditya, jgravelle-google, dschuff.
Herald added a project: LLVM.

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,
but that could lead to an awkward situation in which an object was
marked as disallowing atomics when it in fact used atomics
itself. Once atomic operations are allowed in modules with unshared
memory, this would result in modules containing atomics but not having
the 'atomics' feature in their target-features sections.

To fix this issue, 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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D79542

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

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D79542.262527.patch
Type: text/x-patch
Size: 6799 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200507/4d699048/attachment-0001.bin>


More information about the llvm-commits mailing list