Skip to content

Commit 1254eaa

Browse files
committed
Add the invalidated analysis in DSE
1 parent da5ef15 commit 1254eaa

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

lib/SILOptimizer/Transforms/DeadStoreElimination.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ class DSEContext {
411411
void processInstruction(SILInstruction *I, DSEComputeKind Kind);
412412

413413
/// Entry point for global dead store elimination.
414-
void run();
414+
bool run();
415415
};
416416

417417
} // end anonymous namespace
@@ -822,7 +822,7 @@ void DSEContext::processInstruction(SILInstruction *I, DSEComputeKind Kind) {
822822
invalidateLSLocationBase(I, Kind);
823823
}
824824

825-
void DSEContext::run() {
825+
bool DSEContext::run() {
826826
// Walk over the function and find all the locations accessed by
827827
// this function.
828828
LSLocation::enumerateLSLocations(*F, LSLocationVault, LocToBitIndex, TE);
@@ -874,6 +874,7 @@ void DSEContext::run() {
874874
}
875875

876876
// Finally, delete the dead stores and create the live stores.
877+
bool Changed = false;
877878
for (SILBasicBlock &BB : *F) {
878879
// Create the stores that are alive due to partial dead stores.
879880
for (auto &I : getBlockState(&BB)->LiveStores) {
@@ -883,11 +884,13 @@ void DSEContext::run() {
883884
}
884885
// Delete the dead stores.
885886
for (auto &I : getBlockState(&BB)->DeadStores) {
887+
Changed = true;
886888
DEBUG(llvm::dbgs() << "*** Removing: " << *I << " ***\n");
887889
// This way, we get rid of pass dependence on DCE.
888890
recursivelyDeleteTriviallyDeadInstructions(I, true);
889891
}
890892
}
893+
return Changed;
891894
}
892895

893896
//===----------------------------------------------------------------------===//
@@ -908,7 +911,9 @@ class DeadStoreElimination : public SILFunctionTransform {
908911
DEBUG(llvm::dbgs() << "*** DSE on function: " << F->getName() << " ***\n");
909912

910913
DSEContext DSE(F, &F->getModule(), PM, AA, TE);
911-
DSE.run();
914+
if (DSE.run()) {
915+
invalidateAnalysis(SILAnalysis::InvalidationKind::Instructions);
916+
}
912917
}
913918
};
914919

0 commit comments

Comments
 (0)