Skip to content

Commit 52f7578

Browse files
committed
[MSSA] Add comments describing optimized uses for MemoryDefs [nfc]
As clarified by a recent email chain with Alina.
1 parent 3231b6d commit 52f7578

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

llvm/include/llvm/Analysis/MemorySSA.h

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,19 @@
6666
/// MemoryDefs are not disambiguated because it would require multiple reaching
6767
/// definitions, which would require multiple phis, and multiple memoryaccesses
6868
/// per instruction.
69+
///
70+
/// In addition to the def/use graph described above, MemoryDefs also contain
71+
/// an "optimized" definition use. The "optimized" use points to some def
72+
/// reachable through the memory def chain. The optimized def *may* (but is
73+
/// not required to) alias the original MemoryDef, but no def *closer* to the
74+
/// source def may alias it. As the name implies, the purpose of the optimized
75+
/// use is to allow caching of clobber searches for memory defs. The optimized
76+
/// def may be nullptr, in which case clients must walk the defining access
77+
/// chain.
78+
///
79+
/// When iterating the uses of a MemoryDef, both defining uses and optimized
80+
/// uses will be encountered. If only one type is needed, the client must
81+
/// filter the use walk.
6982
//
7083
//===----------------------------------------------------------------------===//
7184

@@ -252,10 +265,11 @@ class MemoryUseOrDef : public MemoryAccess {
252265
return MA->getValueID() == MemoryUseVal || MA->getValueID() == MemoryDefVal;
253266
}
254267

255-
// Sadly, these have to be public because they are needed in some of the
256-
// iterators.
268+
/// Do we have an optimized use?
257269
inline bool isOptimized() const;
270+
/// Return the MemoryAccess associated with the optimized use, or nullptr.
258271
inline MemoryAccess *getOptimized() const;
272+
/// Sets the optimized use for a MemoryDef.
259273
inline void setOptimized(MemoryAccess *);
260274

261275
// Retrieve AliasResult type of the optimized access. Ideally this would be

0 commit comments

Comments
 (0)