diff options
author | Sam Clegg <sbc@chromium.org> | 2021-04-16 17:55:35 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-16 17:55:35 -0700 |
commit | da4e17d827c444bbbcceb08d577c528020d4d959 (patch) | |
tree | 7b979220507d3d7273f3fb864da50eb5ca8f3db1 /src/passes/LegalizeJSInterface.cpp | |
parent | 423cf0b890e44356fbfa80c5bdfd4032fcc1da01 (diff) | |
download | binaryen-da4e17d827c444bbbcceb08d577c528020d4d959.tar.gz binaryen-da4e17d827c444bbbcceb08d577c528020d4d959.tar.bz2 binaryen-da4e17d827c444bbbcceb08d577c528020d4d959.zip |
LegalizeJSInterface: Remove illegal imports once they are no longer used (#3815)
This prevents used imports which also happen to have duplicate names and
therefore cannot be provided by wasm (JS is happen to fill these in with
polymorphic JS functions).
I noticed this when working on emscripten and directly hooking modules
together. I was seeing failures, but not in release builds (because
wasm-opt would mop these up in release builds).
Diffstat (limited to 'src/passes/LegalizeJSInterface.cpp')
-rw-r--r-- | src/passes/LegalizeJSInterface.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/passes/LegalizeJSInterface.cpp b/src/passes/LegalizeJSInterface.cpp index e840e375b..10e751701 100644 --- a/src/passes/LegalizeJSInterface.cpp +++ b/src/passes/LegalizeJSInterface.cpp @@ -144,6 +144,11 @@ struct LegalizeJSInterface : public Pass { Fixer fixer(&illegalImportsToLegal); fixer.run(runner, module); fixer.walkModuleCode(module); + + // Finally we can remove all the now-unused illegal imports + for (const auto& pair : illegalImportsToLegal) { + module->removeFunction(pair.first); + } } } |