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

Better Continuation aliases #3210

Open
Gbury opened this issue Oct 31, 2024 · 0 comments · May be fixed by #3545
Open

Better Continuation aliases #3210

Gbury opened this issue Oct 31, 2024 · 0 comments · May be fixed by #3545
Assignees
Labels
flambda2 Prerequisite for, or part of, flambda2

Comments

@Gbury
Copy link
Contributor

Gbury commented Oct 31, 2024

Currently continuation aliases are quite restrictive: they only apply when a continuation [k]'s handler is exactly an apply_cont of another continuation [k'] with exactly the same arguments, of the form: let_cont k x_1 ... x_n = apply_cont k' x_1 .... x_n. In that case, the continuation alias mechanism replaces calls to [k] by calls to [k'] during the upwards pass.

This is quite restrictive, and actually, we could substitute any continuation [k] whose handler is only an apply_cont, after applying the required renaming and reordering of params/arguments (plus addition of constants arguments), so that we could do the substitution in the following case: let_cont k x y = apply_cont k' y 0 x.

@Gbury Gbury added the flambda2 Prerequisite for, or part of, flambda2 label Oct 31, 2024
bclement-ocp added a commit to bclement-ocp/flambda-backend that referenced this issue Feb 5, 2025
Replace the continuation alias mechanism with a more general
continuation shortcut mechanism.

A continuation shortcut is a let_cont whose body is an arbitrary
apply_cont. A continuation alias is a special case of continuation
shortcuts where the arguments of the apply_cont are exactly the
parameters of the let_cont.

Shortcuts are detected and resolved in the upwards pass after rewriting
the apply_cont, so that we should never output code containing
continuation shortcuts (except when used as return or exception
continuation).

This should help generate simpler control flow for later Simplify or
To_cmm passes, and make the output of `-dflambda` easier to follow.

Fixes ocaml-flambda#3210
@bclement-ocp bclement-ocp linked a pull request Feb 5, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
flambda2 Prerequisite for, or part of, flambda2
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants