-
Notifications
You must be signed in to change notification settings - Fork 470
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
Improve handling of indexed array access in flow analysis #6776
Conversation
Fixes dotnet#6616 We now ensure that setting an abstract value for an indexed access entity with any non-constant index clears out the existing value for entities that can overlap the indexed location
@@ -159,6 +163,46 @@ public PredicateValueKind ApplyPredicatedDataForEntity(AnalysisEntity predicated | |||
|
|||
public void AddTrackedEntities(HashSet<AnalysisEntity> builder) => builder.UnionWith(CoreAnalysisData.Keys); | |||
|
|||
private void ClearOverlappingAnalysisDataForIndexedEntity(AnalysisEntity analysisEntity, TValue value) |
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 the core fix
return false; | ||
} | ||
|
||
// Now perform slow check that compares individual hash code parts sequences. |
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 are we comparing hash codes?
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.
@Youssef1313 We were seeing extremely large allocations and CPU stacks for dictionary operations keyed on AnalysisEntity
during flow analysis, hence we had switched to using a CacheBasedEquatable approach. It's possible that this is no longer required in the current state of the flow analysis framework, but we would need to invest a few cycles in cleanup and performance measurements on real world code to confirm.
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #6776 +/- ##
========================================
Coverage 96.34% 96.34%
========================================
Files 1388 1386 -2
Lines 325732 325934 +202
Branches 10735 10722 -13
========================================
+ Hits 313811 314008 +197
- Misses 9210 9215 +5
Partials 2711 2711 |
@CollinAlpert I am seeing intermittent test failures for CA1001 in CI after #6741 Test:
|
Improve handling of indexed array access in flow analysis
Fixes #6616
We now ensure that setting an abstract value for an indexed access entity with any non-constant index clears out the existing value for entities that can overlap the indexed location