Skip to content

Commit 47afcd4

Browse files
committed
Regenerate cache key after the valueenumeraor is invalidated. Exposed by another painful memory behavior cache bug
1 parent 51e7da9 commit 47afcd4

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

lib/SILOptimizer/Analysis/AliasAnalysis.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -537,6 +537,9 @@ AliasResult AliasAnalysis::alias(SILValue V1, SILValue V2,
537537
AliasValueBaseToIndex.clear();
538538
}
539539

540+
// Key is no longer valid as we cleared the AliasValueBaseToIndex.
541+
Key = toAliasKey(V1, V2, TBAAType1, TBAAType2);
542+
540543
// Calculate the aliasing result and store it in the cache.
541544
auto Result = aliasInner(V1, V2, TBAAType1, TBAAType2);
542545
AliasCache[Key] = Result;

lib/SILOptimizer/Analysis/MemoryBehavior.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,9 @@ AliasAnalysis::computeMemoryBehavior(SILInstruction *Inst, SILValue V,
317317
MemoryBehaviorValueBaseToIndex.clear();
318318
}
319319

320+
// Key no longer valid as we cleared the MemoryBehaviorValueBaseToIndex.
321+
Key = toMemoryBehaviorKey(SILValue(Inst), V, InspectionMode);
322+
320323
// Calculate the aliasing result and store it in the cache.
321324
auto Result = computeMemoryBehaviorInner(Inst, V, InspectionMode);
322325
MemoryBehaviorCache[Key] = Result;

0 commit comments

Comments
 (0)