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

[NFC] Improve OnceReduction comment #6068

Merged
merged 5 commits into from
Oct 31, 2023
Merged

[NFC] Improve OnceReduction comment #6068

merged 5 commits into from
Oct 31, 2023

Conversation

kripken
Copy link
Member

@kripken kripken commented Oct 31, 2023

Followup to #6061 in which we only optimized the case of a "once" function immediately
calling another and doing nothing else. It is ok to do more things afterwards, so long as
we do nothing else before, by the same logic as already mentioned in the pass (but
clarified as to the meaning of "called" - all we need is for the function to have been
"entered" in the proof there, IIANM).

@gkdn am I missing something?

@gkdn
Copy link
Contributor

gkdn commented Oct 31, 2023

Are you proposing; "we can still remove the condition, if the once function does more than calling another once function"?

@kripken
Copy link
Member Author

kripken commented Oct 31, 2023

Yes, exactly. Concretely:

(func $once
  (if
    (global.get $once)
    (return)
  )
  (global.set $once (i32.const 1))
  ;; Call another once function. This lets us remove the if and global.set.
  (call $once.1)
  ;; Do other stuff. This does not stop us, since this PR.
  (call $anything)
)

@gkdn
Copy link
Contributor

gkdn commented Oct 31, 2023

if anything calls back $once, we would no longer have the guard so anything would be called again.

@kripken
Copy link
Member Author

kripken commented Oct 31, 2023

Oh right... how silly of me!

I'll update this PR to fix the proof text and remove the change.

This reverts commit 12aa794.
This reverts commit 2a4c278.
@kripken kripken requested a review from tlively October 31, 2023 21:07
@kripken kripken changed the title OnceReduction: Optimize "once" functions calling others even if they do other things later [NFC] Improve OnceReduction comment Oct 31, 2023
@kripken
Copy link
Member Author

kripken commented Oct 31, 2023

This PR now only adds a comment to explain why we can only optimize in the case that we do.

@kripken
Copy link
Member Author

kripken commented Oct 31, 2023

This weird ASan error seems like a random flake... it happens once every few PRs now. Very strange. I wish we had a way to ssh into the CI here to investigate...

@kripken kripken merged commit c82627e into main Oct 31, 2023
13 of 14 checks passed
@kripken kripken deleted the moar.three branch October 31, 2023 22:47
radekdoulik pushed a commit to dotnet/binaryen that referenced this pull request Jul 12, 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.

3 participants