[PATCH] D55944: [MemorySSA] Extend the clobber walker with the option to skip the starting access.

Alina Sbirlea via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 2 11:11:04 PST 2019


asbirlea updated this revision to Diff 179897.
asbirlea marked 5 inline comments as done.
asbirlea added a comment.

Address comments.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D55944

Files:
  lib/Analysis/MemorySSA.cpp


Index: lib/Analysis/MemorySSA.cpp
===================================================================
--- lib/Analysis/MemorySSA.cpp
+++ lib/Analysis/MemorySSA.cpp
@@ -332,6 +332,7 @@
   // The MemoryAccess we actually got called with, used to test local domination
   const MemoryAccess *OriginalAccess = nullptr;
   Optional<AliasResult> AR = MayAlias;
+  bool SkipSelfAccess = false;
 
   UpwardsMemoryQuery() = default;
 
@@ -619,9 +620,19 @@
       if (!VisitedPhis.insert({Node.Last, Node.Loc}).second)
         continue;
 
-      UpwardsWalkResult Res = walkToPhiOrClobber(Node, /*StopAt=*/StopWhere);
+      const MemoryAccess *RealStopWhere = StopWhere;
+      bool ReplacedStopWhere = false;
+      if (Query->SkipSelfAccess && Node.Loc == Query->StartingLoc &&
+          Node.Last->getBlock() == Query->OriginalAccess->getBlock()) {
+        assert(isa<MemoryDef>(Query->OriginalAccess));
+        RealStopWhere = Query->OriginalAccess;
+        ReplacedStopWhere = true;
+      }
+
+      UpwardsWalkResult Res =
+          walkToPhiOrClobber(Node, /*StopAt=*/RealStopWhere);
       if (Res.IsKnownClobber) {
-        assert(Res.Result != StopWhere);
+        assert(Res.Result != RealStopWhere);
         // If this wasn't a cache hit, we hit a clobber when walking. That's a
         // failure.
         TerminatedPath Term{Res.Result, PathIndex};
@@ -633,10 +644,13 @@
         continue;
       }
 
-      if (Res.Result == StopWhere) {
+      if (Res.Result == RealStopWhere) {
         // We've hit our target. Save this path off for if we want to continue
-        // walking.
-        NewPaused.push_back(PathIndex);
+        // walking. If we are in the mode of skipping the OriginalAccess, and we
+        // replaced the StopWhere access, then we've reached back to the
+        // OriginalAccess. Do not save path, we've just looped back to self.
+        if (!ReplacedStopWhere)
+          NewPaused.push_back(PathIndex);
         continue;
       }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D55944.179897.patch
Type: text/x-patch
Size: 1978 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190102/e55a576d/attachment.bin>


More information about the llvm-commits mailing list