[llvm] 52f7578 - [MSSA] Add comments describing optimized uses for MemoryDefs [nfc]

Philip Reames via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 8 09:39:19 PST 2022


Author: Philip Reames
Date: 2022-03-08T09:39:11-08:00
New Revision: 52f75784897484c326a971d26a23a16e99b128e6

URL: https://github.com/llvm/llvm-project/commit/52f75784897484c326a971d26a23a16e99b128e6
DIFF: https://github.com/llvm/llvm-project/commit/52f75784897484c326a971d26a23a16e99b128e6.diff

LOG: [MSSA] Add comments describing optimized uses for MemoryDefs [nfc]

As clarified by a recent email chain with Alina.

Added: 
    

Modified: 
    llvm/include/llvm/Analysis/MemorySSA.h

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/Analysis/MemorySSA.h b/llvm/include/llvm/Analysis/MemorySSA.h
index 457fb058e0f86..f119316129b32 100644
--- a/llvm/include/llvm/Analysis/MemorySSA.h
+++ b/llvm/include/llvm/Analysis/MemorySSA.h
@@ -66,6 +66,19 @@
 /// MemoryDefs are not disambiguated because it would require multiple reaching
 /// definitions, which would require multiple phis, and multiple memoryaccesses
 /// per instruction.
+///
+/// In addition to the def/use graph described above, MemoryDefs also contain
+/// an "optimized" definition use.  The "optimized" use points to some def
+/// reachable through the memory def chain.  The optimized def *may* (but is
+/// not required to) alias the original MemoryDef, but no def *closer* to the
+/// source def may alias it.  As the name implies, the purpose of the optimized
+/// use is to allow caching of clobber searches for memory defs.  The optimized
+/// def may be nullptr, in which case clients must walk the defining access
+/// chain.
+///
+/// When iterating the uses of a MemoryDef, both defining uses and optimized
+/// uses will be encountered.  If only one type is needed, the client must
+/// filter the use walk.
 //
 //===----------------------------------------------------------------------===//
 
@@ -252,10 +265,11 @@ class MemoryUseOrDef : public MemoryAccess {
     return MA->getValueID() == MemoryUseVal || MA->getValueID() == MemoryDefVal;
   }
 
-  // Sadly, these have to be public because they are needed in some of the
-  // iterators.
+  /// Do we have an optimized use?
   inline bool isOptimized() const;
+  /// Return the MemoryAccess associated with the optimized use, or nullptr.
   inline MemoryAccess *getOptimized() const;
+  /// Sets the optimized use for a MemoryDef.
   inline void setOptimized(MemoryAccess *);
 
   // Retrieve AliasResult type of the optimized access. Ideally this would be


        


More information about the llvm-commits mailing list