Skip to content

Commit 0836b6a

Browse files
committed
MemAccessUtils comments
1 parent 0325e29 commit 0836b6a

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

include/swift/SIL/MemAccessUtils.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1309,9 +1309,8 @@ struct AccessUseVisitor {
13091309
///
13101310
/// Return true if all uses were collected. This is always true as long the \p
13111311
/// visitor's visitUse method returns true.
1312-
bool visitAccessStorageUses(AccessUseVisitor &visitor,
1313-
AccessStorage storage,
1314-
SILFunction *function);
1312+
bool visitAccessStorageUses(AccessUseVisitor &visitor, AccessStorage storage,
1313+
SILFunction *function);
13151314

13161315
/// Visit the uses of \p accessPath.
13171316
///

lib/SIL/Utils/MemAccessUtils.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1449,7 +1449,7 @@ namespace {
14491449
// load %elt1 // non-use (unseen)
14501450
// %elt2 = struct_element_addr %base, #2 // outer projection (followed)
14511451
// load %elt2 // exact use
1452-
// %sub = struct_element_addr %elt2, #i // inner projection (followed)
1452+
// %sub = struct_element_addr %elt2, %i // inner projection (followed)
14531453
// load %sub // inner use
14541454
//
14551455
// A use may be a BranchInst if the corresponding phi does not have common
@@ -1467,8 +1467,12 @@ class AccessPathDefUseTraversal {
14671467
// The origin of the def-use traversal.
14681468
AccessStorage storage;
14691469

1470-
// Remaining access path indices from the most recently visited def to any
1471-
// exact use in def-use order.
1470+
// Indices of the path to match from inner to outer component.
1471+
// A cursor is used to represent the most recently visited def.
1472+
// During def-use traversal, the cursor starts at the end of pathIndicies and
1473+
// decrements with each projection.
1474+
// The first index represents an exact match.
1475+
// Index < 0 represents some subobject of the requested path.
14721476
SmallVector<AccessPath::Index, 4> pathIndices;
14731477

14741478
// A point in the def-use traversal. isRef() is true only for object access
@@ -1884,8 +1888,8 @@ bool swift::visitAccessPathUses(AccessUseVisitor &visitor,
18841888
}
18851889

18861890
bool swift::visitAccessStorageUses(AccessUseVisitor &visitor,
1887-
AccessStorage storage,
1888-
SILFunction *function) {
1891+
AccessStorage storage,
1892+
SILFunction *function) {
18891893
IndexTrieNode *emptyPath = function->getModule().getIndexTrieRoot();
18901894
return visitAccessPathUses(visitor, AccessPath(storage, emptyPath, 0),
18911895
function);

0 commit comments

Comments
 (0)