Skip to content
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

Preserve multivalue drops in IRBuilder #6150

Merged
merged 7 commits into from
Dec 13, 2023
Merged

Conversation

tlively
Copy link
Member

@tlively tlively commented Dec 7, 2023

In Binaryen IR, we allow single Drop expressions to drop multiple values
packaged up as a tuple. When using IRBuilder to rebuild IR containing such a
drop, it previously treated the drop as a normal WebAssembly drop that dropped
only a single value, producing invalid IR that had extra, undropped values. Fix
the problem by preserving the arity of Drop inputs in IRBuilder. To avoid
bloating the IR, thread the size of the desired value through IRBuilder's pop
implementation so that tuple values do not need to be split up and recombined.

@tlively
Copy link
Member Author

tlively commented Dec 7, 2023

@tlively tlively requested a review from ashleynh December 7, 2023 04:56
@tlively tlively marked this pull request as ready for review December 7, 2023 18:29
@tlively tlively force-pushed the irbuilder-multivalue-drop branch 3 times, most recently from 5e5eb7a to 265d280 Compare December 13, 2023 05:30
In Binaryen IR, we allow single `Drop` expressions to drop multiple values
packaged up as a tuple. When using IRBuilder to rebuild IR containing such a
drop, it previously treated the drop as a normal WebAssembly drop that dropped
only a single value, producing invalid IR that had extra, undropped values. Fix
the problem by preserving the arity of `Drop` inputs in IRBuilder. To avoid
bloating the IR, thread the size of the desired value through IRBuilder's pop
implementation so that tuple values do not need to be split up and recombined.
@tlively tlively force-pushed the irbuilder-multivalue-drop branch from 265d280 to 19a89ad Compare December 13, 2023 19:14
// hoistLastValue().
[[nodiscard]] Result<> packageHoistedValue(const HoistedVal&);
// hoistLastValue(). `sizeHint` is the size of the type we ultimately want to
// consume, so if the hoisted values has `sizeHint` elements, it is left
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// consume, so if the hoisted values has `sizeHint` elements, it is left
// consume, so if the hoisted value has `sizeHint` elements, it is left

@tlively tlively merged commit e9b012f into main Dec 13, 2023
28 checks passed
@tlively tlively deleted the irbuilder-multivalue-drop branch December 13, 2023 22:05
radekdoulik pushed a commit to dotnet/binaryen that referenced this pull request Jul 12, 2024
In Binaryen IR, we allow single `Drop` expressions to drop multiple values
packaged up as a tuple. When using IRBuilder to rebuild IR containing such a
drop, it previously treated the drop as a normal WebAssembly drop that dropped
only a single value, producing invalid IR that had extra, undropped values. Fix
the problem by preserving the arity of `Drop` inputs in IRBuilder. To avoid
bloating the IR, thread the size of the desired value through IRBuilder's pop
implementation so that tuple values do not need to be split up and recombined.
@gkdn gkdn mentioned this pull request Aug 31, 2024
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