Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> Instructions, blocks, and functions can now return more than one result value, sometimes supporting faster calling conventions and avoiding indirections.

Unfortunately, despite being "enabled", Rust+LLVM don't take advantage of this because of ABI compatibility mess. I don't know whether the story on Clang's side is similar.



This is indeed unfortunate, but on the other hand, multivalue's benefits are probably very small.

Inside functions, there is perhaps a 1-3% code size opportunity at best (https://github.com/WebAssembly/binaryen?tab=readme-ov-file#b...), and no performance advantage.

Between functions there might be a performance advantage, but as wasm VMs do more things like runtime inlining (which becomes more and more important with wasm GC and the languages that compile to it), that benefit goes away.


I figured out the way to get multi-value results on GCC for 32-bit ARM. Use a union to pack two 32-bit values into a 64-bit value. Return the 64-bit value. Then use a union to split the 64-bit value into two 32-bit values. I haven't tested it on other 32-bit architectures though.


I'm using the same trick in Zig via packed structs


Interesting, got any links to more information?


https://blog.rust-lang.org/2024/09/24/webassembly-targets-ch...

"As a result there is no longer any possible method of writing a function in Rust that returns multiple values at the WebAssembly function type level."

And similar queries in Rust's zulip: https://rust-lang.zulipchat.com/#narrow/channel/122651-gener...





Consider applying for YC's Winter 2026 batch! Applications are open till Nov 10

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: