summaryrefslogtreecommitdiff
path: root/src/tools
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2019-01-28 11:32:19 -0800
committerGitHub <noreply@github.com>2019-01-28 11:32:19 -0800
commit153ba18ba99dc4dcef29a61e1e586af3df8d921d (patch)
tree5e2f85732dfc40811aa22d17a50bea729167bcbf /src/tools
parent85e95e315a8023c46eb804fe80ebc244bcfdae3e (diff)
downloadbinaryen-153ba18ba99dc4dcef29a61e1e586af3df8d921d.tar.gz
binaryen-153ba18ba99dc4dcef29a61e1e586af3df8d921d.tar.bz2
binaryen-153ba18ba99dc4dcef29a61e1e586af3df8d921d.zip
Handle EM_ASM/EM_JS in LLVM wasm backend O0 output (#1888)
See emscripten-core/emscripten#7928 - we have been optimizing all wasms until now, and noticed this when the wasm object file path did not do so. When not optimizing, our methods of handling EM_ASM and EM_JS fail since the patterns are different. Specifically, for EM_ASM we hunt for emscripten_asm_const(X, where X is a constant, but without opts it may be a get of a local. For EM_JS, the function body may not just contain a const, but a block with a set of the const and a return of a get later. This adds logic to track gets and sets in basic blocks, which is sufficient to handle this.
Diffstat (limited to 'src/tools')
-rw-r--r--src/tools/wasm-emscripten-finalize.cpp18
1 files changed, 10 insertions, 8 deletions
diff --git a/src/tools/wasm-emscripten-finalize.cpp b/src/tools/wasm-emscripten-finalize.cpp
index 3ea3629c5..5c2e37ac3 100644
--- a/src/tools/wasm-emscripten-finalize.cpp
+++ b/src/tools/wasm-emscripten-finalize.cpp
@@ -173,14 +173,16 @@ int main(int argc, const char *argv[]) {
EmscriptenGlueGenerator generator(wasm);
generator.fixInvokeFunctionNames();
- PassRunner passRunner(&wasm);
- passRunner.setDebug(options.debug);
- passRunner.setDebugInfo(debugInfo);
- passRunner.add(ABI::getLegalizationPass(
- legalizeJavaScriptFFI ? ABI::LegalizationLevel::Full
- : ABI::LegalizationLevel::Minimal
- ));
- passRunner.run();
+ {
+ PassRunner passRunner(&wasm);
+ passRunner.setDebug(options.debug);
+ passRunner.setDebugInfo(debugInfo);
+ passRunner.add(ABI::getLegalizationPass(
+ legalizeJavaScriptFFI ? ABI::LegalizationLevel::Full
+ : ABI::LegalizationLevel::Minimal
+ ));
+ passRunner.run();
+ }
std::vector<Name> initializerFunctions;