[llvm] [NFC] [DSE] Refactor DSE (PR #100956)

Haopeng Liu via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 19 10:17:12 PDT 2024


================
@@ -2132,182 +2177,182 @@ struct DSEState {
     }
     return MadeChange;
   }
-};
 
-static bool eliminateDeadStores(Function &F, AliasAnalysis &AA, MemorySSA &MSSA,
-                                DominatorTree &DT, PostDominatorTree &PDT,
-                                const TargetLibraryInfo &TLI,
-                                const LoopInfo &LI) {
-  bool MadeChange = false;
+  // Try to eliminate dead defs killed by `KillingLocWrapper` and return the
+  // change state: whether make any change, and whether make a partial delete
+  // by a non memory-terminator instruction.
+  std::pair<bool, bool>
+  eliminateDeadDefs(MemoryLocationWrapper &KillingLocWrapper);
 
-  DSEState State(F, AA, MSSA, DT, PDT, TLI, LI);
-  // For each store:
-  for (unsigned I = 0; I < State.MemDefs.size(); I++) {
-    MemoryDef *KillingDef = State.MemDefs[I];
-    if (State.SkipStores.count(KillingDef))
+  // Try to eliminate dead defs killed by `KillingDefWrapper` and return the
+  // change state: whether make any change.
+  bool eliminateDeadDefs(MemoryDefWrapper &KillingDefWrapper);
+};
+
+std::pair<bool, bool>
+DSEState::eliminateDeadDefs(MemoryLocationWrapper &KillingLocWrapper) {
+  bool Changed = false;
+  bool Shortened = false;
+  unsigned ScanLimit = MemorySSAScanLimit;
+  unsigned WalkerStepLimit = MemorySSAUpwardsStepLimit;
+  unsigned PartialLimit = MemorySSAPartialStoreLimit;
+  // Worklist of MemoryAccesses that may be killed by KillingDef.
----------------
haopliu wrote:

Done.

https://github.com/llvm/llvm-project/pull/100956


More information about the llvm-commits mailing list