You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Use Binaryen StackIR at the end of the pipeline (#22218)
Before this PR, if we did -O3 then we ended up doing this:
* wasm-opt -O3
* wasm-metadce
* wasm-opt --minify-imports-and-exports
The first invocation uses StackIR (which is enabled by default in -O3), but then the
later invocations "lose" those optimizations, since they read the wasm binary and
generate structured BinaryenIR once more. We would need to do StackIR opts again,
but even more, we'd need to do work to undo the effects of stackiness, which can
lead to more locals and such, see #22196
After this PR, we do this:
* wasm-opt -O3 --no-stack-ir
* wasm-metadce
* wasm-opt --minify-imports-and-exports --optimize-stack-ir
The first command is now told to not use StackIR. The second remains unchanged.
The last then does StackIR optimizations.
This is the same amount of work (we just shuffle around the StackIR opts), so
compile times are unaffected, but we gain some code improvements. To see them,
see the commit before last which applies the size changes on top of a recent rebase.
Many tests improve by small but noticeable amounts, though two wasm2js tests
somehow lose by a few bytes, which I think is noise.
There is a slight code complexity downside here, but given this avoids corner
cases that may be quite annoying (#22196) it seems worthwhile.
Also improve our handling of --emit-symbol-map to use llvm-objcopy, which avoids
wasm-opt roundtrip issues (this is necessary in this commit as otherwise the
improvements of this PR are undone by that roundtrip, which was caught by a test).
0 commit comments