@@ -411,7 +411,7 @@ class DSEContext {
411
411
void processInstruction (SILInstruction *I, DSEComputeKind Kind);
412
412
413
413
// / Entry point for global dead store elimination.
414
- void run ();
414
+ bool run ();
415
415
};
416
416
417
417
} // end anonymous namespace
@@ -822,7 +822,7 @@ void DSEContext::processInstruction(SILInstruction *I, DSEComputeKind Kind) {
822
822
invalidateLSLocationBase (I, Kind);
823
823
}
824
824
825
- void DSEContext::run () {
825
+ bool DSEContext::run () {
826
826
// Walk over the function and find all the locations accessed by
827
827
// this function.
828
828
LSLocation::enumerateLSLocations (*F, LSLocationVault, LocToBitIndex, TE);
@@ -874,6 +874,7 @@ void DSEContext::run() {
874
874
}
875
875
876
876
// Finally, delete the dead stores and create the live stores.
877
+ bool Changed = false ;
877
878
for (SILBasicBlock &BB : *F) {
878
879
// Create the stores that are alive due to partial dead stores.
879
880
for (auto &I : getBlockState (&BB)->LiveStores ) {
@@ -883,11 +884,13 @@ void DSEContext::run() {
883
884
}
884
885
// Delete the dead stores.
885
886
for (auto &I : getBlockState (&BB)->DeadStores ) {
887
+ Changed = true ;
886
888
DEBUG (llvm::dbgs () << " *** Removing: " << *I << " ***\n " );
887
889
// This way, we get rid of pass dependence on DCE.
888
890
recursivelyDeleteTriviallyDeadInstructions (I, true );
889
891
}
890
892
}
893
+ return Changed;
891
894
}
892
895
893
896
// ===----------------------------------------------------------------------===//
@@ -908,7 +911,9 @@ class DeadStoreElimination : public SILFunctionTransform {
908
911
DEBUG (llvm::dbgs () << " *** DSE on function: " << F->getName () << " ***\n " );
909
912
910
913
DSEContext DSE (F, &F->getModule (), PM, AA, TE);
911
- DSE.run ();
914
+ if (DSE.run ()) {
915
+ invalidateAnalysis (SILAnalysis::InvalidationKind::Instructions);
916
+ }
912
917
}
913
918
};
914
919
0 commit comments