Draft
Conversation
Member
|
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. |
Member
Author
|
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. |
Member
|
I see, thanks. Interesting! |
1117764 to
1b84cfc
Compare
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.