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

Cranelift: Consider taking trapnz and trapz all the way to the backends rather than legalizing them #6055

Closed
fitzgen opened this issue Mar 17, 2023 · 2 comments
Labels
cranelift:mid-end clif-to-clif related passes, legalizations, etc... isle Related to the ISLE domain-specific language

Comments

@fitzgen
Copy link
Member

fitzgen commented Mar 17, 2023

Right now we legalize them into a conditional jump to a cold block with a trap intruction early on in the pipeline.

But every backend already has some variant of MInst.TrapIf, which is the same as trapnz, so it would be easy to support in lowering if we wanted to move it there.

Benefits:

  • Not introducing a bunch of extra blocks makes compilation faster for everyone.

  • It is also the only legalization that currently introduces new blocks, which is something ISLE can't do right now, and therefore is preventing us from porting legalization to ISLE.

  • Finally it makes it so we could mark trapnz as having idempotent side effects which would allow us to GVN them. This would further improve bounds checks on multiple loads of the same dynamic index with differing static offsets for the non-Spectre case (e.g. what is talked about as next steps in cranelift-wasm: Add a bounds-checking optimization for dynamic memories and guard pages #6031)

@fitzgen fitzgen added isle Related to the ISLE domain-specific language cranelift:mid-end clif-to-clif related passes, legalizations, etc... labels Mar 17, 2023
@github-actions
Copy link

Subscribe to Label Action

cc @cfallin, @fitzgen

This issue or pull request has been labeled: "isle"

Thus the following users have been cc'd because of the following labels:

  • cfallin: isle
  • fitzgen: isle

To subscribe or unsubscribe from this label, edit the .github/subscribe-to-label.json configuration file.

Learn more.

@fitzgen
Copy link
Member Author

fitzgen commented Sep 28, 2024

Fixed in #972

@fitzgen fitzgen closed this as completed Sep 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cranelift:mid-end clif-to-clif related passes, legalizations, etc... isle Related to the ISLE domain-specific language
Projects
None yet
Development

No branches or pull requests

1 participant