Skip to content

Commit 1151516

Browse files
committed
Add back the Deleted and SkipStores that were missed iduring refactoring
1 parent adaf8c4 commit 1151516

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2191,13 +2191,18 @@ DSEState::eliminateDeadDefs(const MemoryLocationWrapper &KillingLocWrapper) {
21912191
// Worklist of MemoryAccesses that may be killed by
21922192
// "KillingLocWrapper.MemDef".
21932193
SmallSetVector<MemoryAccess *, 8> ToCheck;
2194+
// Track MemoryAccesses that have been deleted in the loop below, so we can
2195+
// skip them. Don't use SkipStores for this, which may contain reused
2196+
// MemoryAccess addresses.
2197+
SmallPtrSet<MemoryAccess *, 8> Deleted;
2198+
[[maybe_unused]] unsigned OrigNumSkipStores = SkipStores.size();
21942199
ToCheck.insert(KillingLocWrapper.MemDef->getDefiningAccess());
21952200

21962201
// Check if MemoryAccesses in the worklist are killed by
21972202
// "KillingLocWrapper.MemDef".
21982203
for (unsigned I = 0; I < ToCheck.size(); I++) {
21992204
MemoryAccess *Current = ToCheck[I];
2200-
if (SkipStores.count(Current))
2205+
if (Deleted.contains(Current))
22012206
continue;
22022207
std::optional<MemoryAccess *> MaybeDeadAccess = getDomMemoryDef(
22032208
KillingLocWrapper.MemDef, Current, KillingLocWrapper.MemLoc,
@@ -2242,7 +2247,7 @@ DSEState::eliminateDeadDefs(const MemoryLocationWrapper &KillingLocWrapper) {
22422247
LLVM_DEBUG(dbgs() << "DSE: Remove Dead Store:\n DEAD: "
22432248
<< *DeadLocWrapper.DefInst << "\n KILLER: "
22442249
<< *KillingLocWrapper.DefInst << '\n');
2245-
deleteDeadInstruction(DeadLocWrapper.DefInst);
2250+
deleteDeadInstruction(DeadLocWrapper.DefInst, &Deleted);
22462251
++NumFastStores;
22472252
Changed = true;
22482253
} else {
@@ -2281,7 +2286,7 @@ DSEState::eliminateDeadDefs(const MemoryLocationWrapper &KillingLocWrapper) {
22812286

22822287
// Remove killing store and remove any outstanding overlap
22832288
// intervals for the updated store.
2284-
deleteDeadInstruction(KillingSI);
2289+
deleteDeadInstruction(KillingSI, &Deleted);
22852290
auto I = IOLs.find(DeadSI->getParent());
22862291
if (I != IOLs.end())
22872292
I->second.erase(DeadSI);
@@ -2293,12 +2298,16 @@ DSEState::eliminateDeadDefs(const MemoryLocationWrapper &KillingLocWrapper) {
22932298
LLVM_DEBUG(dbgs() << "DSE: Remove Dead Store:\n DEAD: "
22942299
<< *DeadLocWrapper.DefInst << "\n KILLER: "
22952300
<< *KillingLocWrapper.DefInst << '\n');
2296-
deleteDeadInstruction(DeadLocWrapper.DefInst);
2301+
deleteDeadInstruction(DeadLocWrapper.DefInst, &Deleted);
22972302
++NumFastStores;
22982303
Changed = true;
22992304
}
23002305
}
23012306
}
2307+
2308+
assert(SkipStores.size() - OrigNumSkipStores == Deleted.size() &&
2309+
"SkipStores and Deleted out of sync?");
2310+
23022311
return {Changed, DeletedKillingLoc};
23032312
}
23042313

0 commit comments

Comments
 (0)