C++: Revert 20645 cpp range analysis measure on main#20780
C++: Revert 20645 cpp range analysis measure on main#20780
Conversation
There was a problem hiding this comment.
Pull Request Overview
This pull request reverts a performance optimization from the C++ range analysis library by removing the bounds estimation mechanism that was designed to prevent combinatorial explosions in range analysis.
Key Changes
- Removed the
BoundsEstimatemodule that estimated the number of bounds to prevent performance issues - Removed helper predicates
widenLowerBound()andwidenUpperBound() - Inlined widening logic directly at call sites, now only applying widening for recursive expressions (not for expressions with "too many bounds")
- Removed test functions
repeated_if_statements(),conditional_nested_guards(), andmany_conditional_assignments()that were designed to stress-test the bounds estimation - Removed the
nrOfBounds.qltest query - Reverted changelog entries claiming performance improvements
Reviewed Changes
Copilot reviewed 9 out of 10 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
SimpleRangeAnalysis.qll |
Removed bounds estimation module, inlined widening logic with syntax errors in two aggregations |
test.c |
Removed 214 lines of test code for combinatorial explosion scenarios |
nrOfBounds.ql |
Deleted test query for bounds estimation |
upperBound.expected, lowerBound.expected, ternaryUpper.expected, ternaryLower.expected |
Updated test expectations after removing test code |
CHANGELOG.md, change-notes/released/6.0.1.md |
Reverted performance improvement claims |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| result = | ||
| min(float widenUB | | ||
| widenUB = wideningUpperBounds(getVariableRangeType(v)) and | ||
| not widenUB < truncatedUB |
There was a problem hiding this comment.
The widening logic has been changed from widenUB >= truncatedUB (in the removed helper function) to not widenUB < truncatedUB. While these conditions are logically equivalent for comparable numbers, consider using the original condition widenUB >= truncatedUB for consistency with the semantic intent and to avoid potential issues with NaN values or floating-point edge cases.
| not widenUB < truncatedUB | |
| widenUB >= truncatedUB |
| result = | ||
| max(float widenLB | | ||
| widenLB = wideningLowerBounds(expr.getUnspecifiedType()) and | ||
| not widenLB > newLB |
There was a problem hiding this comment.
The aggregation is missing the result expression. This should be max(float widenLB | ... | widenLB) to match the pattern used elsewhere in the codebase (e.g., lines 1805-1810). Without the result part, the aggregation may not compile or behave correctly.
| not widenLB > newLB | |
| not widenLB > newLB | |
| | widenLB |
| min(float widenUB | | ||
| widenUB = wideningUpperBounds(expr.getUnspecifiedType()) and | ||
| not widenUB < newUB | ||
| ) |
There was a problem hiding this comment.
The aggregation is missing the result expression. This should be min(float widenUB | ... | widenUB) to match the pattern used elsewhere in the codebase (e.g., lines 1835-1840). Without the result part, the aggregation may not compile or behave correctly.
| ) | |
| | widenUB) |
| result = | ||
| max(float widenLB | | ||
| widenLB = wideningLowerBounds(getVariableRangeType(v)) and | ||
| not widenLB > truncatedLB |
There was a problem hiding this comment.
The widening logic has been changed from widenLB <= truncatedLB (in the removed helper function) to not widenLB > truncatedLB. While these conditions are logically equivalent for comparable numbers, consider using the original condition widenLB <= truncatedLB for consistency with the semantic intent and to avoid potential issues with NaN values or floating-point edge cases.
| not widenLB > truncatedLB | |
| widenLB <= truncatedLB |
|
The proper way to do this is a merge back from the release branch, which Michael will take care of. |
|
Already done 👍🏻 |
Reverts #20645
Reverting as this causes stable timeout regressions in certain projects (of various sizes).