Guards: Improve performance of forall in guardDeterminesPhiInput.#21408
Open
aschackmull wants to merge 2 commits intogithub:mainfrom
Open
Guards: Improve performance of forall in guardDeterminesPhiInput.#21408aschackmull wants to merge 2 commits intogithub:mainfrom
aschackmull wants to merge 2 commits intogithub:mainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves the performance of the guardDeterminesPhiInput predicate in Guards.qll by adding a strictcount restriction that acts as a cheap pre-filter before an expensive forall check, avoiding classic quadratic forall blowup. The PR description shows an evaluation time reduction for the main antijoin auxiliary predicate from ~1857ms to ~21ms.
Changes:
- Adds a
strictcountguard to ensure there is exactly oneSsaDefinitioncontrolled byguard == vbefore entering theforallcheck, exploiting the fact that theforallitself implies this uniqueness in valid cases - Includes an explanatory comment documenting why this pre-filter is semantically valid and why it improves performance
You can also share your feedback on Copilot code review. Take the survey.
hvitved
reviewed
Mar 5, 2026
hvitved
approved these changes
Mar 5, 2026
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
I noticed poor performance in this predicate for Java after merging the new CFG. It's a classic case of quadratic
forallblowup, but instead of fixing it via the usual ranking trick, I noticed the we can magic the forall with a strictcount restriction, which seems to work well.Before:
After: