llvm-project/lld/wasm
Thomas Lively a1ae9566ea [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
2020-05-08 13:52:39 -07:00
..
CMakeLists.txt [ThinLTO] Pass CodeGenOpts like UnrollLoops/VectorizeLoop/VectorizeSLP 2020-01-09 21:13:11 -08:00
Config.h [lld][WebAssembly] Handle 4gb max memories 2020-04-09 13:06:41 -07:00
Driver.cpp [Support] Move LLD's parallel algorithm wrappers to support 2020-05-05 15:21:05 -07:00
InputChunks.cpp [WebAssembly] Fix faulty logic in verifyRelocTargets 2020-04-16 18:19:56 -07:00
InputChunks.h [WebAssembly] Support wasm exports with zero-length names. 2020-03-26 16:20:43 -07:00
InputEvent.h [Coding style change][lld] Rename variables for non-ELF ports 2019-07-11 05:40:30 +00:00
InputFiles.cpp [WebAssembly] Add int32 DW_OP_WASM_location variant 2020-04-16 16:32:17 -07:00
InputFiles.h [lld][WebAssembly] Fail if bitcode objects are pulled in after LTO 2020-02-11 17:36:15 -08:00
InputGlobal.h [Coding style change][lld] Rename variables for non-ELF ports 2019-07-11 05:40:30 +00:00
LTO.cpp [ThinLTO] Allow usage of all hardware threads in the system 2020-03-27 10:20:58 -04:00
LTO.h [Coding style change][lld] Rename variables for non-ELF ports 2019-07-11 05:40:30 +00:00
MarkLive.cpp [lld][WebAssembly] Refactor markLive.cpp. NFC 2019-10-10 03:23:06 +00:00
MarkLive.h Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
Options.td [lld][COFF][ELF][WebAssembly] Replace --[no-]threads /threads[:no] with --threads={1,2,...} /threads:{1,2,...} 2020-03-31 08:46:12 -07:00
OutputSections.cpp [Support] Move LLD's parallel algorithm wrappers to support 2020-05-05 15:21:05 -07:00
OutputSections.h [WebAssembly] Elide data segments for .bss sections 2019-10-15 19:05:11 +00:00
OutputSegment.h [WebAssembly] Elide data segments for .bss sections 2019-10-15 19:05:11 +00:00
Relocations.cpp [lld][WebAssembly] Honor --allow-undefined for data symbols too 2020-05-06 12:39:29 -07:00
Relocations.h [Coding style change][lld] Rename variables for non-ELF ports 2019-07-11 05:40:30 +00:00
SymbolTable.cpp [lld][WebAssembly] Fix crash on function signature mismatch with --relocatable 2020-04-25 10:26:11 -07:00
SymbolTable.h [lld] NFC: fix trivial typos in comments 2020-04-02 01:21:36 +09:00
Symbols.cpp [lld] NFC: fix trivial typos in comments 2020-04-02 01:21:36 +09:00
Symbols.h [lld] NFC: fix trivial typos in comments 2020-04-02 01:21:36 +09:00
SyntheticSections.cpp [WebAssembly] Move event section before global section 2020-03-25 11:49:03 -07:00
SyntheticSections.h [WebAssembly] Move event section before global section 2020-03-25 11:49:03 -07:00
Writer.cpp [WebAssembly] Disallow 'shared-mem' rather than 'atomics' 2020-05-08 13:52:39 -07:00
Writer.h [WebAssembly] Refactor synthetic sections and relocation processing. NFC. 2019-05-21 09:13:09 +00:00
WriterUtils.cpp [WebAssmebly] Add support for defined wasm globals in MC and lld 2020-04-30 12:43:15 -07:00
WriterUtils.h [WebAssembly] Initialize memory in start function 2019-09-04 19:50:39 +00:00