Fix code age relation so that unsimplified code is not sent to Expr_builder #133
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
At present,
Lambda_to_flambda
is not computing full free name information on terms, which means thatExpr_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:
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 asDeleted
). This in turn meant that earlier "let symbol" bindings whose bound code IDs were used in the body of the code associated withcode_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 aftercode_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