Skip to content

Commit d8e1fca

Browse files
committed
Add a comment to PrunedLiveness explaining use points.
1 parent 5d832bf commit d8e1fca

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

include/swift/SIL/PrunedLiveness.h

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,34 @@
8383
/// | Use | [LiveWithin]
8484
/// -----
8585
///
86+
/// ---------------------------------------------------------------------------
87+
///
88+
/// "Use points" are the instructions that "generate" liveness for a given
89+
/// operand. A generalized use point visitor would look like this:
90+
///
91+
/// Given an \p operand, visit the use points relevant for liveness. For most
92+
/// operands, this is simply the user instruction. For scoped operands, each
93+
/// scope-ending instruction is a separate use point.
94+
/// template<typename Operation>
95+
/// inline bool visitUsePoints(Operand *use, Operation visitUsePoint) {
96+
/// // Handle TrivialUse operands: begin_access & store_borrow address
97+
/// // Handle InteriorPointer operands: store_borrow source
98+
/// if (auto scopedAddress = ScopedAddressValue::forUse(use)) {
99+
/// return scopedAddress.visitScopeEndingUses(visitUsePoint);
100+
/// }
101+
/// // Handle Borrow operands...
102+
/// // Handles borrow scope introducers: begin_borrow & load_borrow.
103+
/// // Handles guaranteed return values: begin_apply.
104+
/// if (!BorrowingOperand(operand).visitScopeEndingUses([this](Operand *end) {
105+
/// if (!visitUsePoint(end))
106+
/// return false;
107+
/// return true;
108+
/// }
109+
/// return visitUsePoint(use);
110+
/// }
111+
///
112+
/// The visitors that switch on OperandOwnership use a specialized
113+
/// implementation because each case above is specific to an ownership case.
86114
//===----------------------------------------------------------------------===//
87115

88116
#ifndef SWIFT_SILOPTIMIZER_UTILS_PRUNEDLIVENESS_H

0 commit comments

Comments
 (0)