-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Ssa: Refactor shared SSA in preparation for eliminating phi-read definitions #18819
Conversation
This yields a tiny bit of additional tuples consistent with the prior Java implementation.
This is a result of the bugfix in the commit named "C#/Ruby/Rust: Fix bug in adjacentReadPairSameVar"
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 a lot for making this PR reviewable in individual commits. I have just two questions. Also, remember DCA.
shared/ssa/codeql/ssa/Ssa.qll
Outdated
* Holds if we should synthesize a pseudo-read of `v` at the beginning of `bb`. | ||
* | ||
* These reads are named phi-reads, since they are constructed in the same | ||
* way as ordinary phi nodes except all all reads are treated as potential |
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.
remove the extra all
.
shared/ssa/codeql/ssa/Ssa.qll
Outdated
variableWrite(bb, i, v, false) and | ||
k = SsaActualRead() |
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.
Why is it that we have "pseudo-reads associated with uncertain writes"?
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 it much simpler to calculate uncertainWriteDefinitionInput
.
BasicBlock bb1, int i1, BasicBlock bb2, int i2, SourceVariable v, boolean samevar | ||
) { | ||
adjacentRefs(bb1, i1, bb2, i2, v) and | ||
variableRead(bb2, i2, v, _) and |
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.
The QL doc mentions certain read, so should _
be true
?
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 should be implied and hence an unnecessary join due to the restriction in ssaRef
to only include certain reads.
variableWrite(bb, i, v, false) and | ||
k = Read() |
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 understand now, per your comment, why this case is needed for uncertainWriteDefinitionInput
in SsaDefReachesNew
. Why is it needed here?
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.
Once we've added phi-read nodes, the use-use calculation can be done in exactly the same way as def-use: Any non-phi reference will be dominated by the prior reference. So for actual reads and uncertain writes there exist a unique previous reference, which we calculate in adjacentRefRead
, and including k = Read()
for uncertain writes make it easy to include those cases that way in adjacentRefRead
. And note that we subsequently need those when we calculate the samevar=false
flavour of use-use pairs in firstUseAfterRef
, which exactly skips forward over references that aren't actual certain reads.
I want to reinterpret phi-reads as reads rather than definitions and hide them from the exposed interface of the SSA library. For normal SSA usage they should be irrelevant: they're only useful for getting an optimised use-use step relation, in particular for use in data-flow.
This PR leaves most of the existing implementation intact, but adds alternative predicates and switches the internal implementation of several others in preparation for this change.
The PR is structured as a long sequence of individually simple commits, so commit-by-commit review is very much encouraged.
There's more work to come, but each of the commits should make sense on their own, and I'd gathered so many that I wanted to merge them to main before adding too many more.