Skip to content

Commit 5499734

Browse files
committed
[rbi] Fix an iterator invalidation issue.
Due to compile time issues, I added a cache into getUnderlyingTrackedValue(). This caused an iterator invalidation issue when we recursed in the case when we had an underlying object since we would recurse into getUnderlyingTrackedValue() instead of getUnderlyingTrackedValueHelper() potentially causing us to cache another value and thus causing the underlying DenseMap to expand. Now we instead just call getUnderlyingTrackedValueHelper() so that we avoid the invalidation issue. This may cause us to use slightly more compile time but we are still only ever going to compute the underlying value once for any specific value.
1 parent 98984a2 commit 5499734

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

lib/SILOptimizer/Analysis/RegionAnalysis.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -874,11 +874,13 @@ RegionAnalysisValueMap::getUnderlyingTrackedValueHelper(SILValue value) const {
874874

875875
// If we have an object base...
876876
if (base->getType().isObject()) {
877-
// ... we purposely recurse into the cached version of our computation
878-
// rather than recurse into getUnderlyingTrackedObjectValueHelper. This is
879-
// safe since we know that value was previously an address so if our base is
880-
// an object, it cannot be the same object.
881-
return UnderlyingTrackedValueInfo(getUnderlyingTrackedValue(base).value);
877+
// Recurse.
878+
//
879+
// NOTE: We purposely recurse into getUnderlyingTrackedValueHelper instead
880+
// of getUnderlyingTrackedValue since we could cause an invalidation to
881+
// occur in the underlying DenseMap that backs getUnderlyingTrackedValue()
882+
// if we insert another entry into the DenseMap.
883+
return UnderlyingTrackedValueInfo(getUnderlyingTrackedValueHelper(base));
882884
}
883885

884886
// Otherwise, we return the actorIsolation that our visitor found.

0 commit comments

Comments
 (0)