Skip to content

Commit 23e7f5f

Browse files
committed
Add comment and assertion
1 parent 665649d commit 23e7f5f

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2172,7 +2172,11 @@ static bool eliminateDeadStores(Function &F, AliasAnalysis &AA, MemorySSA &MSSA,
21722172
unsigned PartialLimit = MemorySSAPartialStoreLimit;
21732173
// Worklist of MemoryAccesses that may be killed by KillingDef.
21742174
SmallSetVector<MemoryAccess *, 8> ToCheck;
2175+
// Track MemoryAccesses that have been deleted in the loop below, so we can
2176+
// skip them. Don't use SkipStores for this, which may contain reused
2177+
// MemoryAccess addresses.
21752178
SmallPtrSet<MemoryAccess *, 8> Deleted;
2179+
[[maybe_unused]] unsigned OrigNumSkipStores = State.SkipStores.size();
21762180
ToCheck.insert(KillingDef->getDefiningAccess());
21772181

21782182
bool Shortend = false;
@@ -2283,6 +2287,9 @@ static bool eliminateDeadStores(Function &F, AliasAnalysis &AA, MemorySSA &MSSA,
22832287
}
22842288
}
22852289

2290+
assert(State.SkipStores.size() - OrigNumSkipStores == Deleted.size() &&
2291+
"SkipStores and Deleted out of sync?");
2292+
22862293
// Check if the store is a no-op.
22872294
if (!Shortend && State.storeIsNoop(KillingDef, KillingUndObj)) {
22882295
LLVM_DEBUG(dbgs() << "DSE: Remove No-Op Store:\n DEAD: " << *KillingI

0 commit comments

Comments
 (0)