-
Notifications
You must be signed in to change notification settings - Fork 1.9k
C#: Get rid of negative parameter/argument data-flow positions #7658
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
C#: Get rid of negative parameter/argument data-flow positions #7658
Conversation
b61ea63 to
f178132
Compare
f178132 to
128682b
Compare
michaelnebel
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.
Looks good!
| newtype TArgumentPosition = | ||
| TPositionalArgumentPosition(int i) { i = any(Parameter p).getPosition() } or | ||
| TQualifierArgumentPosition() or | ||
| TImplicitCapturedArgumentPosition(SsaCapturedEntryDefinition def) |
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 looks risky! This might introduce virtual-dispatch-sized blowups in any part of the dataflow lib that work with an argument without having joined that to a call target.
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.
Or is this a case where the call-callee relation is 1-1?
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.
Performance-wise this should be no different from before, where we translated each SsaCapturedEntryDefinition into a magic number (using equivalenceRelation), and used that magic number as both parameter and argument positions.
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.
But now that I think about it, this can probably be made a bit nicer (and smaller) by simply using the variable that is captured as the positions.
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 guess the bad case requires some sort of convoluted setup where a single call might dispatch to many different lambdas (or other kinds of closures) that each capture some variable, and that this single call somehow provides a value in the corresponding argument-position(s). I don't know if such a construction is even possible - it depends on how these arguments are recognised.
michaelnebel
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.
LGTM!
This PR makes use of #7260 to get rid of negative parameter/argument positions. Negative indices were used in two places:
-1: representing qualifiers/thisparameters.-2 ..: used to model flow through captured variables.The former are used in flow summaries, which means that
Argument[Qualifier]replacesArgument[-1]. The latter are only used internally, but getting rid of those as well means that we can remove some hackyequivalenceRelation-based ranking.