Skip to content

Fix code age relation so that unsimplified code is not sent to Expr_builder #133

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

Conversation

mshinwell
Copy link
Collaborator

At present, Lambda_to_flambda is not computing full free name information on terms, which means that Expr_builder will not operate correctly if passed unsimplified code for a new "let symbol" binding. (For example it won't see uses of code IDs in function bodies, leading to code bindings being erroneously deleted.)

The reason this was happening turned out to be a non-trivial code age relation, resulting from significant inlining, looking like:

    code_id1  [earliest, output from Lambda_to_flambda]
       |
    code_id2  [first piece of simplified code]
      /  \
     /    \
code_id3  code_id4

The check that the code age relation remained linear was being too conservative: it was saying that the relation branched after code_id1, which corresponded to unsimplified code, and thus such unsimplified code had new "let symbol" bindings created for it (not marked as Deleted). This in turn meant that earlier "let symbol" bindings whose bound code IDs were used in the body of the code associated with code_id1 were deleted, since not all of the free names in that code were visible to the earlier bindings. It should in fact suffice to say that the relation only branched after code_id2, which was the first piece of simplified code; that is what this PR does.

This will be superceded by ocaml-flambda/ocaml#556 which eliminates this check on the shape of the code age relation in favour of a different analysis.

However we need to have a discussion about the free name information computed by Lambda_to_flambda. If we're not going to compute full free name information there, we may need to change the types so that "free names unknown" can be represented, to make this more robust. cc @lthls @chambart

@mshinwell mshinwell added the flambda2 Prerequisite for, or part of, flambda2 label Aug 3, 2021
@mshinwell mshinwell merged commit a54fd72 into ocaml-flambda:main Aug 3, 2021
mshinwell added a commit to mshinwell/flambda-backend that referenced this pull request Aug 4, 2021
ccasin added a commit to ccasin/flambda-backend that referenced this pull request Mar 12, 2023
5e7dfce331 Merge flambda-backend changes
9f7f2d24a7 Edit script for test merge
1ae71ce59d Review comments (ocaml-flambda#6)
1845365bd0 Layouts version 1
aba6294 Immediacy rework (ocaml-flambda#122)
cf4eeef Add no-stack-allocation variant of some tests that print lambda (ocaml-flambda#133)
8f22438 Fully switch over Jane Street Merlin support to `.local-*` (ocaml-flambda#136)
5482a8d Remove `Lev_module_definition` from lambda (ocaml-flambda#135)
261e016 Change modular extensions to produce `AST_desc` types (ocaml-flambda#132)
0760c82 Disable module patterns in comprehensions (ocaml-flambda#131)
6acac80 Add Ctype global state debug printers (ocaml-flambda#130)
bc32037 Enable support for Jane Street's internal Merlin configuration (ocaml-flambda#64)
d1a8d03 Split out `Clflags.Extension` into a new file, `Language_extension` (ocaml-flambda#125)
435de6d Fix bootstrap and add legacy CI (ocaml-flambda#126)
7e5a626 Improve the API of language extensions to better support upstream compatibility (and also tooling) (ocaml-flambda#13)
c4e17b0 Replace var with local for faster mode checking (ocaml-flambda#53)
6d477d8 Merge pull request ocaml-flambda#124 from riaqn/merge-backend
d737533 minor fixes after merge
f1710d6 Merge flambda-backend changes
cc18534 Just run make boostrap (ocaml-flambda#123)

git-subtree-dir: ocaml
git-subtree-split: 5e7dfce331d0e39c695fab9b00e3d2cda7d9ebb4
ccasin added a commit that referenced this pull request Mar 24, 2023
ea89813 Merge pull request #154 from ocaml-flambda/merge-flambda-backend
23cf5a5 Merge flambda-backend changes
b3af0c4 Unboxed types version 3 tests (#82)
1282d16 Functions with no clauses aren't local-returning (#149)
15d38c0 `make install` puts ocamlc at workspace root (#152)
b4928ee Remove -absname to improve build errors (#151)
f5b5e49 Remove `type_unpacks` (#150)
50d54db Remove arity-interrupting elaboration of module patterns (#146)
4382869 Remove the need to manually update the `tools/debug_printers` file (#148)
06a1d91 Add `promote-failed` targets to the Makefiles (#144)
d04eb58 Cleanup of comprehensions and immutable arrays (#127)
a45df79 Add a Module_strengthening extension (#142)
163c4b9 Add support for extensions in module types (#141)
74aa974 Some small patch-ups around matching on extensions (#140)
07127fe Remove raw_body from modular extensions setup (#137)
3f9bd64 Don't copy when resolving aliases in try_modtypes (#143)
aba6294 Immediacy rework (#122)
cf4eeef Add no-stack-allocation variant of some tests that print lambda (#133)
8f22438 Fully switch over Jane Street Merlin support to `.local-*` (#136)
5482a8d Remove `Lev_module_definition` from lambda (#135)
261e016 Change modular extensions to produce `AST_desc` types (#132)
0760c82 Disable module patterns in comprehensions (#131)
6acac80 Add Ctype global state debug printers (#130)
bc32037 Enable support for Jane Street's internal Merlin configuration (#64)
d1a8d03 Split out `Clflags.Extension` into a new file, `Language_extension` (#125)
435de6d Fix bootstrap and add legacy CI (#126)
7e5a626 Improve the API of language extensions to better support upstream compatibility (and also tooling) (#13)
c4e17b0 Replace var with local for faster mode checking (#53)
6d477d8 Merge pull request #124 from riaqn/merge-backend
d737533 minor fixes after merge
f1710d6 Merge flambda-backend changes
cc18534 Just run make boostrap (#123)

git-subtree-dir: ocaml
git-subtree-split: ea89813
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 this pull request may close these issues.

1 participant