Delete unused local allocation regions in Flambda 2#809
Merged
mshinwell merged 14 commits intooxcaml:mainfrom Sep 22, 2022
Merged
Delete unused local allocation regions in Flambda 2#809mshinwell merged 14 commits intooxcaml:mainfrom
mshinwell merged 14 commits intooxcaml:mainfrom
Conversation
67e107b to
df3bd9a
Compare
Collaborator
Author
|
As a note I'm not planning on implementing full support for these enhancements in |
ce96d72 to
e51b319
Compare
Collaborator
Author
|
This PR also now aims to ensure that we don't end up with |
0d177ce to
d54b424
Compare
Gbury
reviewed
Sep 12, 2022
lthls
reviewed
Sep 14, 2022
lthls
reviewed
Sep 21, 2022
Contributor
lthls
left a comment
There was a problem hiding this comment.
I've left a number of comments, some of them applying to code that wasn't modified by this PR.
The only one that I think is serious is the one in to_cmm_env.ml about the extra binding for my_region.
4749264 to
bd807d5
Compare
lthls
approved these changes
Sep 21, 2022
This was referenced Oct 10, 2022
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Flambda 2 can't currently delete unused
Begin_regionandEnd_regionconstructs (unlike the equivalent in Flambda 1), which I suspect is leaving some amount of unnecessary code around, together with inhibiting code motion inTo_cmm.This patch aims to rectify this. It equips the primitives that allocate (and
Set_of_closures) with region variables identifying which region is to be allocated in (this will always be the most recent by construction, and will remain that way throughout the pipeline). Functions now take amy_regionparameter which is substituted for the current region upon inlining.Begin_regionis now marked as having only generative effects rather than arbitrary effects, which still inhibits code motion inTo_cmm(until such time as we figure out how to do that safely for these constructs), but allows deletion when the region variable it returns is unused.End_regionremains as having arbitrary effects but a special case is added (inSimplify_let_exprandExpr_builder) to do two things. Firstly for the purposes ofData_flowthe region variable inEnd_regionis not counted as a use. Secondly when rebuilding aLetbinding anEnd_regionwe consultData_flowto see if the region variable (the argument toEnd_region) was actually used. If it was unused, then theEnd_regionis dropped, which will in turn cause theBegin_regionto be cleaned up without further ado.There is one outstanding problem relating to the region stack during CPS conversion (
Lambda_to_flambda) not containing thetry_regionvariable. Currently there is a hack in place so I can try some examples but this needs to be fixed properly. There are also a few things to fix inFexpr.