Skip to content

Support for phantom bindings #3937

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

lthls
Copy link
Contributor

@lthls lthls commented Apr 29, 2025

This PR restores support for generating phantom bindings.

I wrote it by enabling phantom lets, and fixing errors as I find them. Given the number of bugs I had to fix, it is likely that some remain in some less-tested corner cases.

Here is a summary of the changes:

  • The Name_mode lattice is now a straight line. The typing env requires all the variables in it to have a name mode at least In_types, so I made Phantom greater than In_types instead of not comparable. It would also be possible to prevent the typing env from handling variables in Phantom mode, and that should make the environments smaller, but I think it should be a separate PR.
  • The logic in Expr_builder to decide whether to keep a binding, delete it or phantomise it has been moved to Simplify_let_expr.rebuild_let. This makes decisions more consistent (now even bindings removed by mutable unboxing get phantomised if needed)
  • Slot offset computations now ignore slots not in normal mode, not only in projections. Phantom closures also get Deleted code IDs to avoid keeping old code around.
  • No CSE equations are created for phantom bindings

It is possible that this PR still contains changes that were made redundant by a more general fix. Do not hesitate to point these out during review.

@mshinwell mshinwell added flambda2 Prerequisite for, or part of, flambda2 dwarf and debugging labels Apr 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dwarf and debugging flambda2 Prerequisite for, or part of, flambda2
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants