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

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 21 04:19:28 PDT 2024


================
@@ -2132,182 +2171,188 @@ 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 that access `KillingLocWrapper.MemLoc` and are
+  // killed by `KillingLocWrapper.MemDef`. Return whether
+  // any changes were made, and whether `KillingLocWrapper.DefInst` was deleted.
+  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);
----------------
fhahn wrote:

Can KillingLocWrapper be modified? If so, document, if not make const?

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


More information about the llvm-commits mailing list