Skip to content

Commit 273c357

Browse files
committed
Add the ability to customize AddressWalker to visit a transitive use as an end point use.
1 parent 2935090 commit 273c357

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

include/swift/SIL/AddressWalker.h

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,12 @@ class TransitiveAddressWalker {
6161
/// understand. These cause us to return AddressUseKind::Unknown.
6262
void onError(Operand *use) {}
6363

64+
/// Customization point that causes the walker to treat a specific transitive
65+
/// use as an end point use.
66+
///
67+
/// Example: Visiting a mutable or immutable open_existential_addr.
68+
bool visitTransitiveUseAsEndPointUse(Operand *use) { return false; }
69+
6470
void meet(AddressUseKind other) {
6571
assert(!didInvalidate);
6672
result = swift::meet(result, other);
@@ -103,11 +109,14 @@ TransitiveAddressWalker<Impl>::walk(SILValue projectedAddress) && {
103109
auto transitiveResultUses = [&](Operand *use) {
104110
auto *svi = cast<SingleValueInstruction>(use->getUser());
105111
if (svi->use_empty()) {
106-
callVisitUse(use);
107-
} else {
108-
for (auto *use : svi->getUses())
109-
addToWorklist(use);
112+
return callVisitUse(use);
110113
}
114+
115+
if (asImpl().visitTransitiveUseAsEndPointUse(use))
116+
return callVisitUse(use);
117+
118+
for (auto *use : svi->getUses())
119+
addToWorklist(use);
111120
};
112121

113122
while (!worklist.empty()) {

0 commit comments

Comments
 (0)