Skip to content

Add stacky mode to BinaryenIR#2784

Draft
tlively wants to merge 27 commits intoWebAssembly:mainfrom
tlively:stackify
Draft

Add stacky mode to BinaryenIR#2784
tlively wants to merge 27 commits intoWebAssembly:mainfrom
tlively:stackify

Conversation

@tlively
Copy link
Member

@tlively tlively commented Apr 22, 2020

As an alternative to StackIR, adds a "stacky" mode to the normal
BinaryenIR in which normal instructions are completely flat and have
only pops as their children. This means that all instructions in
blocks may have arbitrary concrete types, not just the last
instructions.

The potential benefits of introducing a new mode for Binaryen IR are
that many passes will be agnostic to whether they run on the stacky or
unstacky code and stacky optimizations might be easier to write. This
will require further comparative exploration.

The next steps in this direction are:

  • Perform the actual tuple lowering in Stackify.cpp

  • Add a new validation mode that checks invariants for stacky code

  • Testing and fuzzing support

  • Reimplement the StackIR optimizations on the stacky BinaryenIR

  • Add checking to the pass runner to ensure passes get only code
    forms they can handle.

No more work will be done on this PR until tuples are made to work
with the current StackIR. Then maybe we can look more concretely at
the tradeoffs involved.

@kripken
Copy link
Member

kripken commented Apr 22, 2020

How would this handle the problems we discussed on the whiteboard a while ago about pops? IIRC the order of pops was potentially very confusing etc.

@tlively
Copy link
Member Author

tlively commented Apr 23, 2020

The difference here is that it is an all-or-nothing approach. Pops are only hard to reason about when they are mixed with normal nested IR. In this approach mixing nested IR and stacky IR is forbidden. My hope is that sharing IR data structures will make it much easier to make passes that are stackiness-agnostic, but I expect that most passes will still expect one form or the other, as they do today.

@kripken
Copy link
Member

kripken commented Apr 24, 2020

I see, thanks. Interesting!

@tlively tlively force-pushed the stackify branch 3 times, most recently from 1117764 to 1b84cfc Compare June 25, 2020 08:34
tlively added 23 commits August 18, 2020 13:20
This avoids Stack IR from being generated and thrown away in the
middle of an optimization pipeline. This change is partially
preparation for a future in which tuple lowering is performed as a
part of lowering to Stack IR or something similar. In that case, the
lowering would add locals and trying to throw away the Stack IR (or
similar construct) would become an error.
As an alternative to StackIR, adds a "stacky" mode to the normal
BinaryenIR in which normal instructions are completely flat and have
only pops as their children. This means that all instructions in
blocks may have arbitrary concrete types, not just the last
instructions.

The potential benefits of introducing a new mode for Binaryen IR are
that many passes will be agnostic to whether they run on the stacky or
unstacky code and stacky optimizations might be easier to write. This
will require further comparative exploration.

The next steps in this direction are:

 - Perform the actual tuple lowering in Stackify.cpp

 - Add a new validation mode that checks invariants for stacky code

 - Testing and fuzzing support

 - Reimplement the StackIR optimizations on the stacky BinaryenIR

 - Add checking to the pass runner to ensure passes get only code
   forms they can handle.

No more work will be done on this PR until tuples are made to work
with the current StackIR. Then maybe we can look more concretely at
the tradeoffs involved.
Base automatically changed from master to main January 19, 2021 21:59
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.

2 participants