diff options
author | Thomas Lively <tlively@google.com> | 2019-07-03 22:04:54 +0000 |
---|---|---|
committer | Thomas Lively <tlively@google.com> | 2019-07-03 22:04:54 +0000 |
commit | 6004d9a13d1f5796844d802ff0486f842a06f674 (patch) | |
tree | 4ef1c40af1c8d3f4ee41c6a9dc9a2130f3a38893 /lld/wasm/MarkLive.cpp | |
parent | c96c174557c079aab31429aed3f3f8ec34384592 (diff) | |
download | llvm-6004d9a13d1f5796844d802ff0486f842a06f674.zip llvm-6004d9a13d1f5796844d802ff0486f842a06f674.tar.gz llvm-6004d9a13d1f5796844d802ff0486f842a06f674.tar.bz2 |
[WebAssembly] Add option to emit passive segments
Summary:
Adds `--passive-segments` and `--active-segments` flags to control
what kind of segments are emitted. For now the default is always
to emit active segments so this is not a breaking change, but in
the future the default will be changed to passive segments when
shared memory is requested and active segments otherwise. When
passive segments are emitted, corresponding memory.init and
data.drop instructions are emitted in a `__wasm_init_memory`
function that is automatically called at the beginning of
`__wasm_call_ctors`.
Reviewers: sbc100, aheejin, dschuff
Subscribers: azakai, dschuff, jgravelle-google, sunfish, jfb, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D59343
llvm-svn: 365088
Diffstat (limited to 'lld/wasm/MarkLive.cpp')
-rw-r--r-- | lld/wasm/MarkLive.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/lld/wasm/MarkLive.cpp b/lld/wasm/MarkLive.cpp index b3dce23..0826492 100644 --- a/lld/wasm/MarkLive.cpp +++ b/lld/wasm/MarkLive.cpp @@ -50,6 +50,10 @@ void lld::wasm::markLive() { // function. However, this function does not contain relocations so we // have to manually mark the ctors as live if CallCtors itself is live. if (Sym == WasmSym::CallCtors) { + if (Config->PassiveSegments) + Enqueue(WasmSym::InitMemory); + if (Config->Pic) + Enqueue(WasmSym::ApplyRelocs); for (const ObjFile *Obj : Symtab->ObjectFiles) { const WasmLinkingData &L = Obj->getWasmObj()->linkingData(); for (const WasmInitFunc &F : L.InitFunctions) { @@ -79,10 +83,8 @@ void lld::wasm::markLive() { } } - if (Config->Pic) { + if (Config->Pic) Enqueue(WasmSym::CallCtors); - Enqueue(WasmSym::ApplyRelocs); - } // Follow relocations to mark all reachable chunks. while (!Q.empty()) { |