[llvm] 2ceabf6 - [MachineSink] Reduce the number of unnecessary invalidations of StoreInstrCache (NFC) (#68676)

via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 12 02:06:24 PDT 2023


Author: Momchil Velikov
Date: 2023-10-12T10:06:19+01:00
New Revision: 2ceabf6bdc649f06a316f917a0f508fe10ea7faa

URL: https://github.com/llvm/llvm-project/commit/2ceabf6bdc649f06a316f917a0f508fe10ea7faa
DIFF: https://github.com/llvm/llvm-project/commit/2ceabf6bdc649f06a316f917a0f508fe10ea7faa.diff

LOG: [MachineSink] Reduce the number of unnecessary invalidations of StoreInstrCache (NFC) (#68676)

Don't invalidate the cache when erasing instructions which cannot ever
appear in the cache.

Added: 
    

Modified: 
    llvm/lib/CodeGen/MachineSink.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/CodeGen/MachineSink.cpp b/llvm/lib/CodeGen/MachineSink.cpp
index 9a0d1cc94d24b3a..d0e119cb7470632 100644
--- a/llvm/lib/CodeGen/MachineSink.cpp
+++ b/llvm/lib/CodeGen/MachineSink.cpp
@@ -539,9 +539,10 @@ bool MachineSinking::PerformSinkAndFold(MachineInstr &MI,
       New = TII->emitLdStWithAddr(*SinkDst, MaybeAM);
     }
     LLVM_DEBUG(dbgs() << "yielding"; New->dump());
+    // Clear the StoreInstrCache, since we may invalidate it by erasing.
+    if (SinkDst->mayStore() && !SinkDst->hasOrderedMemoryRef())
+      StoreInstrCache.clear();
     SinkDst->eraseFromParent();
-    // Clear the StoreInstrCache, since we may have invalidated it by erasing.
-    StoreInstrCache.clear();
   }
 
   // Collect operands that need to be cleaned up because the registers no longer


        


More information about the llvm-commits mailing list