Flambda2: Store kind on variables #4243
Open
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.
This PR updates the data associated to each Flambda2 variable to also include the kind (but not the subkind).
The rationale for this PR is that several parts of Flambda2 need to know the kinds of the variables (or simples), and tracking this independently requires some work (typically, the typing env stores the kind for every variable).
This is particularly problematic in the case where a cmx might be missing: currently we can load a cmx containing occurrences of a variable coming from another compilation unit, whose cmx is now unavailable, and in this case we cannot know the kind of the variable (at least not directly). This happens in practice with the new n-way join, and #4212 is a workaround for this issue.
With this PR, the variable would have its kind stored in all cmx files where it occurs, so even with a missing cmx we would be able to access the kind.
Currently the PR doesn't change the existing code to make use of the stored kinds, but a follow-up PR could clean the typing environment to avoid storing kinds completely.