-
Notifications
You must be signed in to change notification settings - Fork 757
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
Some Questions Related to BinaryenExpressionPrint()'s Output #6016
Comments
Binaryen's IR is an AST where each node produces at most one value consumed by its parent node. Wherever a control flow structure returns multiple values, we have to package them up as a single tuple value in the AST structure. That's where the tuple pseudoinstructions are coming from. Similarly, whenever you have "stacky" code that leaves values on the value stack while it goes and does some other operation, that code doesn't translate cleanly into the AST form. We end up putting the values left on the stack into locals to resolve the mismatch. That's where the extra locals are coming from. If you optimize this module, Binaryen should be able to remove some of the bloat that the parser inserted. |
Aha I get it, just to make sure I understand it right, does the second situation (extra locals) similar to the situation mentioned in issue #663? In other words, the following code will also introduce extra locals to save values on the stack, right?
|
Yes, exactly |
Thanks for your kind response, that helps a lot :) |
Hello developers, I am currently working on a work that modifies the contents of wasm modules, since I could not find a way to traverse the Binaryen IR like we do in LLVM IR (which contains control flow graph), I try to inspect how Binaryen constructs a function's body by the following code:
And the sample module provided is of the following WAT form:
The resulting output is listed below, which is a little bit tedious, but in essense, I have three questions:
tuple.make
instruction appearing in the result, which is not a valid WebAssembly instruction?i32.const
instructions are surrounded bylocal.set
instructions, what's the point of doing this or is it related to optimizations?Thanks in advance for any helpful replies ;) !
The text was updated successfully, but these errors were encountered: