Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CHANGELOG entry for v102 OptimizeInstructions #4526

Merged
merged 1 commit into from
Mar 14, 2022

Conversation

ospencer
Copy link
Contributor

@ospencer ospencer commented Mar 8, 2022

We (the Grain team) ran into a funny thing when upgrading to Binaryen 102—we occasionally use tuples to use the wasm stack via a direct BinaryenTupleExtract on a BinaryenTupleMake to avoid managing an extra local. We support some runtimes that still don't have multivalue, but by never returning a tuple from an if or block we've avoided any actual use of multivalue in the generated binaries. The update to OptimizeInstructions allows the BinaryenTupleExtract to be pulled outside of an if, which makes the if actually return multiple values. We shouldn't have been abusing tuples in this way, but we figured we'd call it out in the changelog for anyone else who might have done the same 😅

Copy link
Member

@kripken kripken left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good to mention this if it's helpful!

@kripken kripken merged commit e8cc796 into WebAssembly:main Mar 14, 2022
@tlively
Copy link
Member

tlively commented Mar 14, 2022

@ospencer, out of curiosity, do you plan to take advantage of multivalue in the future? (or alternatively, would you use it now if it were better supported by tools + engines?)

@ospencer
Copy link
Contributor Author

Yes, absolutely. In fact, something I was working on just this weekend I really wished I could use multivalue to do codegen for. It's mostly an engine thing—multivalue would be fantastic for avoiding allocations when passing around ADT variants, would be helpful for cleaner FFIs, would be excellent for tuples and records, etc. At some point we'll decide to leave some engines behind, likely the moment Wasm GC hits stage 5 😄

@ospencer ospencer deleted the patch-2 branch March 14, 2022 21:34
@tlively
Copy link
Member

tlively commented Mar 14, 2022

Interesting! Yes, I can see that multivalue would be useful for all those things. I was working about a year and a half ago to improve our multivalue codegen by transforming Binaryen IR into a stack machine format called Poppy IR and performing stack-machine-specific optimizations on it that can't be expressed in Binaryen IR's AST format. The tracking issue is here: #3059.

Unfortunately, I never finished the project because it wasn't very important for the things we were working on at the time. In particular, clang is not in a great position to use multivalue in C/C++ and we estimated that multivalue optimizations in Binaryen would only decrease code size by about 1.5%. If you start using Binaryen's existing multivalue support heavily, it would probably be worth picking that project back up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants