Add CHANGELOG entry for v102 OptimizeInstructions - #4526
Conversation
kripken
left a comment
There was a problem hiding this comment.
Sounds good to mention this if it's helpful!
|
@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?) |
|
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 😄 |
|
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. |
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
BinaryenTupleExtracton aBinaryenTupleMaketo avoid managing an extra local. We support some runtimes that still don't have multivalue, but by never returning a tuple from aniforblockwe've avoided any actual use of multivalue in the generated binaries. The update to OptimizeInstructions allows theBinaryenTupleExtractto be pulled outside of anif, which makes theifactually 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 😅