-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Rangeanalysis: Simplify Guards integration. #19571
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
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -145,7 +145,7 @@ private predicate isNonFallThroughPredecessor(SwitchCase sc, ControlFlowNode pre | |
* Evaluating a switch case to true corresponds to taking that switch case, and | ||
* evaluating it to false corresponds to taking some other branch. | ||
*/ | ||
class Guard extends ExprParent { | ||
final class Guard extends ExprParent { | ||
Guard() { | ||
this.(Expr).getType() instanceof BooleanType and not this instanceof BooleanLiteral | ||
or | ||
|
@@ -360,6 +360,18 @@ private predicate guardControls_v3(Guard guard, BasicBlock controlled, boolean b | |
) | ||
} | ||
|
||
pragma[nomagic] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [nitpick] Consider removing the unused Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback |
||
private predicate guardControlsBranchEdge_v2( | ||
Guard guard, BasicBlock bb1, BasicBlock bb2, boolean branch | ||
) { | ||
guard.hasBranchEdge(bb1, bb2, branch) | ||
or | ||
exists(Guard g, boolean b | | ||
guardControlsBranchEdge_v2(g, bb1, bb2, b) and | ||
implies_v2(g, b, guard, branch) | ||
) | ||
} | ||
|
||
pragma[nomagic] | ||
private predicate guardControlsBranchEdge_v3( | ||
Guard guard, BasicBlock bb1, BasicBlock bb2, boolean branch | ||
|
@@ -372,6 +384,27 @@ private predicate guardControlsBranchEdge_v3( | |
) | ||
} | ||
|
||
/** INTERNAL: Use `Guard` instead. */ | ||
final class Guard_v2 extends Guard { | ||
/** | ||
* Holds if this guard evaluating to `branch` controls the control-flow | ||
* branch edge from `bb1` to `bb2`. That is, following the edge from | ||
* `bb1` to `bb2` implies that this guard evaluated to `branch`. | ||
*/ | ||
predicate controlsBranchEdge(BasicBlock bb1, BasicBlock bb2, boolean branch) { | ||
guardControlsBranchEdge_v2(this, bb1, bb2, branch) | ||
} | ||
|
||
/** | ||
* Holds if this guard evaluating to `branch` directly or indirectly controls | ||
* the block `controlled`. That is, the evaluation of `controlled` is | ||
* dominated by this guard evaluating to `branch`. | ||
*/ | ||
predicate controls(BasicBlock controlled, boolean branch) { | ||
guardControls_v2(this, controlled, branch) | ||
} | ||
} | ||
|
||
private predicate equalityGuard(Guard g, Expr e1, Expr e2, boolean polarity) { | ||
exists(EqualityTest eqtest | | ||
eqtest = g and | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
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.
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.
[nitpick] Add a brief doc comment explaining
controls
to match the JavaGuard_v2
documentation and improve clarity for future maintainers.Copilot uses AI. Check for mistakes.