[PATCH] D119877: [DSE,MSSA] Bail out early if there are no memory defs.

Florian Hahn via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 15 12:03:02 PST 2022


fhahn created this revision.
Herald added subscribers: asbirlea, george.burgess.iv, hiraditya.
fhahn requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D119877

Files:
  llvm/include/llvm/Analysis/MemorySSA.h
  llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp


Index: llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
===================================================================
--- llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
+++ llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
@@ -1876,6 +1876,9 @@
                                 const LoopInfo &LI) {
   bool MadeChange = false;
 
+  if (MSSA.empty_defs())
+    return false;
+
   DSEState State(F, AA, MSSA, DT, TLI, LI);
   // For each store:
   for (unsigned I = 0; I < State.MemDefs.size(); I++) {
Index: llvm/include/llvm/Analysis/MemorySSA.h
===================================================================
--- llvm/include/llvm/Analysis/MemorySSA.h
+++ llvm/include/llvm/Analysis/MemorySSA.h
@@ -784,6 +784,11 @@
   /// about the beginning or end of a block.
   enum InsertionPlace { Beginning, End, BeforeTerminator };
 
+  /// Returns true if there are no memory defs in the function.
+  bool empty_defs() const {
+    return PerBlockDefs.empty();
+  }
+
 protected:
   // Used by Memory SSA dumpers and wrapper pass
   friend class MemorySSAPrinterLegacyPass;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D119877.408993.patch
Type: text/x-patch
Size: 1088 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220215/403e1976/attachment.bin>


More information about the llvm-commits mailing list