-
Notifications
You must be signed in to change notification settings - Fork 3.7k
[Relax] Improve CanonicalizeBindings in DataflowVar edge case #16783
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
[Relax] Improve CanonicalizeBindings in DataflowVar edge case #16783
Conversation
If there is a trivial binding of `Var = DataflowVar`, but the non-dataflow variable is never used outside the dataflow block in which is is declared, then we should keep the name of the upstream `DataflowVar`, as it is more likely to be the human-readable name (e.g. a function parameter).
slyubomirsky
left a comment
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.
This is a nice improvement, though there's a significant typo that should be fixed before we merge 😅 Thank you!
| // Case 3: DataflowVar = DataflowVar | ||
| // Case 4a: Var = DataflowVar, but used outside this DataflowBlock | ||
| // | ||
| // For these three cases, the trivial binding can be |
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.
| // For these three cases, the trivial binding can be | |
| // For these four cases, the trivial binding can be |
😉
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.
Off by one errors, my two one nemesis! (Thank you, and fixed.)
| // Case 1: Var = Var | ||
| // Case 2: DataflowVar = Var | ||
| // Case 3: DataflowVar = DataflowVar | ||
| // Case 4a: Var = DataflowVar, but used outside this DataflowBlock |
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.
| // Case 4a: Var = DataflowVar, but used outside this DataflowBlock | |
| // Case 4a: Var = DataflowVar, but not used outside this DataflowBlock |
It appears the text was copied from case 4b. I also think it would be clearer to write out that it is the var that is not used outside the DF block
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.
Thank you, and updated the comment to be more explicit. I've also changed "this DataflowBlock" to "the DataflowBlock containing the binding", since this function is called after the entire function is visited, not during the visit of any specific dataflow block.
slyubomirsky
left a comment
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.
Thanks for the correction.
…#16783) * [Relax] Improve CanonicalizeBindings in DataflowVar edge case If there is a trivial binding of `Var = DataflowVar`, but the non-dataflow variable is never used outside the dataflow block in which is is declared, then we should keep the name of the upstream `DataflowVar`, as it is more likely to be the human-readable name (e.g. a function parameter). * Update comment for used/not used Var * ci bump
If there is a trivial binding of
Var = DataflowVar, but the non-dataflow variable is never used outside the dataflow block in which is is declared, then we should keep the name of the upstreamDataflowVar, as it is more likely to be the human-readable name (e.g. a function parameter).