[PATCH] D105098: [DSE][NFC] Introduce "doesn't overwrite" return code for isOverwrite

Evgeniy via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 29 05:36:33 PDT 2021


ebrevnov updated this revision to Diff 355189.
ebrevnov added a comment.

Fixed comments + formatting


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105098/new/

https://reviews.llvm.org/D105098

Files:
  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
@@ -327,6 +327,7 @@
   OW_End,
   OW_PartialEarlierWithFullLater,
   OW_MaybePartial,
+  OW_None,
   OW_Unknown
 };
 
@@ -941,11 +942,13 @@
   /// Return OW_MaybePartial if \p Later does not completely overwrite
   /// \p Earlier, but they both write to the same underlying object. In that
   /// case, use isPartialOverwrite to check if \p Later partially overwrites
-  /// \p Earlier. Returns 'OW_Unknown' if nothing can be determined.
-  OverwriteResult
-  isOverwrite(const Instruction *LaterI, const Instruction *EarlierI,
-              const MemoryLocation &Later, const MemoryLocation &Earlier,
-              int64_t &EarlierOff, int64_t &LaterOff) {
+  /// \p Earlier. Returns 'OR_None' if later is known to not overwrite the
+  /// earlier. 'OW_Unknown' if nothing can be determined.
+  OverwriteResult isOverwrite(const Instruction *LaterI,
+                              const Instruction *EarlierI,
+                              const MemoryLocation &Later,
+                              const MemoryLocation &Earlier,
+                              int64_t &EarlierOff, int64_t &LaterOff) {
     // AliasAnalysis does not always account for loops. Limit overwrite checks
     // to dependencies for which we can guarantee they are independant of any
     // loops they are in.
@@ -1053,9 +1056,8 @@
       return OW_MaybePartial;
     }
 
-    // Can reach here only if accesses are known not to overlap. There is no
-    // dedicated code to indicate no overlap so signal "unknown".
-    return OW_Unknown;
+    // Can reach here only if accesses are known not to overlap.
+    return OW_None;
   }
 
   bool isInvisibleToCallerAfterRet(const Value *V) {
@@ -1450,12 +1452,13 @@
         if (!isMemTerminator(*CurrentLoc, CurrentI, KillingI))
           continue;
       } else {
-        int64_t InstWriteOffset, DepWriteOffset;
+        int64_t InstWriteOffset = 0;
+        int64_t DepWriteOffset = 0;
         auto OR = isOverwrite(KillingI, CurrentI, DefLoc, *CurrentLoc,
                               DepWriteOffset, InstWriteOffset);
         // If Current does not write to the same object as KillingDef, check
         // the next candidate.
-        if (OR == OW_Unknown)
+        if (OR == OW_Unknown || OR == OW_None)
           continue;
         else if (OR == OW_MaybePartial) {
           // If KillingDef only partially overwrites Current, check the next
@@ -1464,6 +1467,7 @@
           // which are less likely to be removable in the end.
           if (PartialLimit <= 1) {
             WalkerStepLimit -= 1;
+            LLVM_DEBUG(dbgs() << "   ... reached partial limit ... continue with next access\n");
             continue;
           }
           PartialLimit -= 1;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D105098.355189.patch
Type: text/x-patch
Size: 2952 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210629/e4390a40/attachment.bin>


More information about the llvm-commits mailing list