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.
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
Fixes lost dependencies for pruning during monomorphization. #767
Fixes lost dependencies for pruning during monomorphization. #767
Changes from 6 commits
41d2e86
2f21837
89643d8
e059d8e
d50af6f
06e99f9
8ac0139
0024600
c6b2762
e4d5c99
b7c14eb
7b28f0e
d296215
9eb3ab9
1f14fac
9d8c497
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You want to hold on to the original axiom so that you can walk over it and calculate some state. I am wondering if you can do this calculation and stash the computed state somewhere before the original axiom is modified in-place. It seems this approach might be more intuitive to understand.
If you choose to retain the current approach, rename to
originalAxiomToUninstantiatedCopy
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about this:
We add something like the following to
Absy.Axiom
and update them during monomorphization. This is in line with instantiated
DeclWithFormals
in Absy.cs. We can fill inOriginalAxiomUninstantiatedCopy
at entry to monomorphization, and fill inOriginalAxiom
when splitting (instantiated and uninstantiated) axioms.We could also add to
Absy.Axiom
:which could return body functions & symbols for an axiom. Then we would no longer need the additional dictionaries. The function and constant collector could also be moved out somewhere, maybe to
Absy.cs
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I implemented the version I proposed above, but I am not sure if it ended up being any better. In the new implementation members of
Axiom
need to be initialized in the right places during monomorphization, as opposed to adding entries to the dictionaries. The dictionaries are no longer needed, but similar collections need to be computed again fromsplitAxioms
insideUpdateFunctionDependencies
. Maybe additional members inAxiom
, which are only used during monomorphization, are also undesirable. Overall I am tempted to just change the name for now. This can perhaps be considered again when addingused_by
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When I made the suggestion, I had something very simple in mind. You have the following lines of code in your PR:
If I understand this correctly, you retrieving the cloned axiom (prior to in-place updates) just so you can call the
originalFc.Visit
method. You could call this method up front and stash originalAxiomFc in the dictionary instead. Then you can look up the collected functions and constants later.If you don't like this suggestion, go ahead and land your PR as is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That makes sense, and axioms don't need to be cloned anymore. I just pushed a commit doing this, thanks for the suggestion!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you use
var
here? Does your IDE not suggest that?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated. My IDE was apparently suggesting that, which I didn't notice.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding the parameter
HashSet<Function> functions
seems unnecessary, since it's also available throughmonomorphizationVisitor.originalFunctions
I'm not always sure how much inner functions help read the code. Here I have to inspect the outer scope to understand the meaning of some of the variables used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed inner functions. I used inner functions initially because they were called twice in the original version of this PR, but after reducing its scope this changed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider renaming:
function
->oldFunction
,functions
->oldFunctions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed inner functions. I also changed
old
tooriginal
to match related dictionary names.