-
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
Java: IPA the CFG (second try) #17970
base: main
Are you sure you want to change the base?
Conversation
private ControlFlowNode mainBranchSucc(ControlFlowNode n, boolean b) { | ||
result = succ(n, BooleanCompletion(_, b)) | ||
} | ||
private Node mainBranchSucc(Node n, boolean b) { result = succ(n, BooleanCompletion(_, b)) } |
Check warning
Code scanning / CodeQL
Missing QLDoc for parameter Warning
@@ -1487,8 +1555,8 @@ | |||
* In the latter case, when `n` occurs as the last node in a finally block, there might be | |||
* multiple different such successors. | |||
*/ | |||
private ControlFlowNode otherBranchSucc(ControlFlowNode n, boolean b) { | |||
exists(ControlFlowNode main | main = mainBranchSucc(n, b.booleanNot()) | | |||
private Node otherBranchSucc(Node n, boolean b) { |
Check warning
Code scanning / CodeQL
Missing QLDoc for parameter Warning
Only one in Dominance required thinking.
now we need to sort out range analysis
The equivalence relation needed for range analysis is now on underlying `ExprParent`s, as `BasicBlock` is now an IPA type and ids are opaque.
Java: some mechanical transformations
result = this.(Expr).getEnclosingStmt() | ||
module ControlFlow { | ||
private predicate hasControlFlow(Expr e) { | ||
not e.getEnclosingStmt() instanceof ConstCase 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.
This is interesting..
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.
In a line like case "a" -> null;
I think this is trying to exclude the "a"
but is accidentally excluding the null
as well. I guess this wasn't an issue until switch expressions got added.
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 maybe it's the arrow syntax that caused the problem, as extra expressions are now part of this statement.
Fix is taken from https://github.com/github/codeql/pull/711/files#diff-24d21bcfe63e29a6ef28151d9bd8eeaa610565c3ed7b846de1eb5fb0be661ae5 It is not clear why anotations are left out.
Java: fix UnreachabaleBasicBlock
The language test failure can only be fixed with an internal PR to update a .expected file. I will prepare one when this PR has been approved. |
DCA has finished and it shows a mild analysis time increase (1.6% median, 1.8% mean). I ran some queries on apache/flink using before and after commits and looked at the tuple counts and predicate timings and didn't see anything obviously taking much longer. I don't think it's a bad join order or anything like that. But I guess that adding another layer will make analysis take a little longer. |
This is unrelated to the main purpose of this PR. I have made a separate PR to do it here: github#17988
* | ||
* This is needed for the equivalence relation on basic blocks in range | ||
* analysis. |
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's not its only use. Also, it seems reasonable to have predicate like this without such a specific-sounding constraint.
* | |
* This is needed for the equivalence relation on basic blocks in range | |
* analysis. |
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.
Did you mean to suggest a different wording?
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.
Ah no, I meant to simply delete it. Edited.
Co-authored-by: Anders Schack-Mulligen <[email protected]>
This converts the control flow graph to an IPA type to give us some more options in how we model control flow. There should be no change in any query results.
This resurrects this PR from almost six years ago. The CFG code hasn't changed much in the interim, thankfully.
The commit history is pretty garbled, so it's probably best not to review commit-by-commit.