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

[compiler] simplify PruneDeadFields #14509

Merged
merged 1 commit into from May 17, 2024

Conversation

patrick-schultz
Copy link
Collaborator

@patrick-schultz patrick-schultz commented Apr 26, 2024

Makes some further progress on simplifying the PruneDeadFields pass, with the primary goal of decoupling it from the details of the binding structure.

The primary change is to memoizeValueIR. Before, it passed in only the requested type of the node, and returned and environment containing all free variables and their requested types. Any bound variables would then need to be removed, and the environments of all children then merged. This low-level manipulation of environments made it closely tied to the binding structure, essentially redundantly encoding everything in Binds.scala.

Now we pass an environment down into the children, which maps variables to a mutable state tracking the requested type. Each Ref node unions the requested type at the reference with the state in the environment. This lets us use the general environment infrastructure.

I didn't do an assertion directly comparing the old and new implementations, as I've done with some other pass rewrites. But PruneDeadFields has pretty good test coverage.

Copy link
Collaborator Author

patrick-schultz commented Apr 26, 2024

@patrick-schultz patrick-schultz changed the title simplify PruneDeadFields [compiler] simplify PruneDeadFields Apr 26, 2024
@patrick-schultz patrick-schultz changed the base branch from ps-04-22-push_through_declarative_bindings to main April 26, 2024 19:57
@patrick-schultz patrick-schultz force-pushed the ps-04-26-simplify_PruneDeadFields branch from bf520b0 to b6f50d6 Compare April 26, 2024 20:24
@patrick-schultz patrick-schultz changed the base branch from main to ps-04-22-push_through_declarative_bindings April 26, 2024 20:24
@patrick-schultz patrick-schultz changed the base branch from ps-04-22-push_through_declarative_bindings to main April 26, 2024 20:25
@patrick-schultz patrick-schultz changed the base branch from main to ps-04-22-push_through_declarative_bindings April 26, 2024 21:06
@patrick-schultz patrick-schultz force-pushed the ps-04-26-simplify_PruneDeadFields branch from b6f50d6 to cd3e539 Compare April 26, 2024 21:06
@patrick-schultz patrick-schultz changed the base branch from ps-04-22-push_through_declarative_bindings to main April 26, 2024 21:06
@patrick-schultz patrick-schultz changed the base branch from main to ps-04-22-push_through_declarative_bindings April 27, 2024 11:21
@patrick-schultz patrick-schultz force-pushed the ps-04-26-simplify_PruneDeadFields branch from cd3e539 to 7b26b14 Compare April 27, 2024 11:21
@patrick-schultz patrick-schultz changed the base branch from ps-04-22-push_through_declarative_bindings to main April 27, 2024 11:21
@patrick-schultz patrick-schultz changed the base branch from main to ps-04-22-push_through_declarative_bindings April 29, 2024 13:22
@patrick-schultz patrick-schultz force-pushed the ps-04-26-simplify_PruneDeadFields branch from 7b26b14 to 00f9063 Compare April 29, 2024 13:22
@patrick-schultz patrick-schultz changed the base branch from ps-04-22-push_through_declarative_bindings to main April 29, 2024 13:23
@patrick-schultz patrick-schultz force-pushed the ps-04-26-simplify_PruneDeadFields branch from 00f9063 to 4a018f5 Compare April 29, 2024 16:22
@patrick-schultz patrick-schultz changed the base branch from main to ps-04-22-push_through_declarative_bindings April 29, 2024 16:22
@patrick-schultz patrick-schultz changed the base branch from ps-04-22-push_through_declarative_bindings to main April 29, 2024 16:23
@patrick-schultz patrick-schultz force-pushed the ps-04-26-simplify_PruneDeadFields branch from 4a018f5 to cf8e1e5 Compare April 29, 2024 18:27
@patrick-schultz patrick-schultz changed the base branch from main to ps-04-22-push_through_declarative_bindings April 29, 2024 18:27
@patrick-schultz patrick-schultz changed the base branch from ps-04-22-push_through_declarative_bindings to main April 29, 2024 18:27
@patrick-schultz patrick-schultz changed the base branch from main to ps-04-22-push_through_declarative_bindings May 1, 2024 19:59
@patrick-schultz patrick-schultz force-pushed the ps-04-26-simplify_PruneDeadFields branch from cf8e1e5 to 5611ec9 Compare May 1, 2024 19:59
Base automatically changed from ps-04-22-push_through_declarative_bindings to main May 2, 2024 12:14
@patrick-schultz patrick-schultz force-pushed the ps-04-26-simplify_PruneDeadFields branch from 5611ec9 to 9ecd8ab Compare May 2, 2024 12:48
@patrick-schultz patrick-schultz changed the base branch from main to ps-05-02-refactor_types_in_bindings May 2, 2024 20:31
@patrick-schultz patrick-schultz force-pushed the ps-04-26-simplify_PruneDeadFields branch from 9acf643 to 578e1c7 Compare May 9, 2024 18:22
@patrick-schultz patrick-schultz marked this pull request as ready for review May 9, 2024 18:32
Copy link
Collaborator

@ehigham ehigham left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rebase plz

@patrick-schultz patrick-schultz force-pushed the ps-04-24-simplify_NormalizeNames branch from c8b6f3b to 0cd012c Compare May 14, 2024 20:31
@patrick-schultz patrick-schultz force-pushed the ps-04-26-simplify_PruneDeadFields branch from cde4d74 to 4a4616c Compare May 14, 2024 20:32
@patrick-schultz patrick-schultz force-pushed the ps-04-24-simplify_NormalizeNames branch from 0cd012c to 1aead6f Compare May 15, 2024 18:39
Copy link
Collaborator

@ehigham ehigham left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

brilliant

@patrick-schultz patrick-schultz force-pushed the ps-04-24-simplify_NormalizeNames branch from 1aead6f to 804a488 Compare May 16, 2024 12:58
@patrick-schultz patrick-schultz force-pushed the ps-04-26-simplify_PruneDeadFields branch from 4a4616c to c743e5a Compare May 16, 2024 12:58
@patrick-schultz patrick-schultz changed the base branch from ps-04-24-simplify_NormalizeNames to main May 16, 2024 12:59
@patrick-schultz patrick-schultz force-pushed the ps-04-26-simplify_PruneDeadFields branch from c743e5a to e706b0e Compare May 16, 2024 16:58
@patrick-schultz patrick-schultz changed the base branch from main to ps-04-24-simplify_NormalizeNames May 16, 2024 16:58
@patrick-schultz patrick-schultz force-pushed the ps-04-24-simplify_NormalizeNames branch from 7fc916b to fcffa37 Compare May 16, 2024 17:39
@patrick-schultz patrick-schultz force-pushed the ps-04-26-simplify_PruneDeadFields branch from e706b0e to 4ea526f Compare May 16, 2024 17:39
Base automatically changed from ps-04-24-simplify_NormalizeNames to main May 16, 2024 18:25
@patrick-schultz patrick-schultz force-pushed the ps-04-26-simplify_PruneDeadFields branch 2 times, most recently from cb112bb to 60955f0 Compare May 16, 2024 19:05
@patrick-schultz patrick-schultz force-pushed the ps-04-26-simplify_PruneDeadFields branch from 60955f0 to edf40c1 Compare May 16, 2024 19:22
@hail-ci-robot hail-ci-robot merged commit 9822e7d into main May 17, 2024
2 checks passed
@hail-ci-robot hail-ci-robot deleted the ps-04-26-simplify_PruneDeadFields branch May 17, 2024 11:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants