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

Heap2Local: Fix an ordering issue with children having different interactions with a parent #6089

Merged
merged 2 commits into from
Nov 9, 2023

Conversation

kripken
Copy link
Member

@kripken kripken commented Nov 8, 2023

We had a simple rule that if we reach an expression twice then we give up, which makes
sense for say a block: if one allocation flows out of it, then another can't - it would get
mixed in with the other one, which is a case we don't optimize. However, there are
cases where a parent has multiple children and different interactions with them, like
a struct.set: the reference child does not escape, but the value child does. Before this
PR if we reached the value child first, we'd mark the parent as seen, and then the reference
child would see it isn't the first to get here, and not optimize.

To fix this, reorder the code to handle this case. The manner of interaction between the
child and the parent decides whether we mark the parent as seen and to be further
avoided.

Noticed by the determinism fuzzer, since the order of analysis mattered here.

@kripken kripken requested a review from tlively November 8, 2023 23:04
@kripken kripken merged commit c37fc09 into main Nov 9, 2023
14 checks passed
@kripken kripken deleted the heap2local.det branch November 9, 2023 16:41
radekdoulik pushed a commit to dotnet/binaryen that referenced this pull request Jul 12, 2024
…ractions with a parent (WebAssembly#6089)

We had a simple rule that if we reach an expression twice then we give up, which makes
sense for say a block: if one allocation flows out of it, then another can't - it would get
mixed in with the other one, which is a case we don't optimize. However, there are
cases where a parent has multiple children and different interactions with them, like
a struct.set: the reference child does not escape, but the value child does. Before this
PR if we reached the value child first, we'd mark the parent as seen, and then the reference
child would see it isn't the first to get here, and not optimize.

To fix this, reorder the code to handle this case. The manner of interaction between the
child and the parent decides whether we mark the parent as seen and to be further
avoided.

Noticed by the determinism fuzzer, since the order of analysis mattered here.
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