Skip to content

Commit 5ac273d

Browse files
committed
OwnershipOptUtils API comments. Document assumed preconditions.
1 parent 19c8cf1 commit 5ac273d

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

include/swift/SILOptimizer/Utils/OwnershipOptUtils.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,11 @@ class OwnershipRAUWHelper {
128128
///
129129
/// \p oldValue may be either a SingleValueInstruction or a terminator result.
130130
///
131+
/// Precondition: If \p oldValue is a BorrowedValue that introduces a local
132+
/// borrow scope, then \p newValue must either be defined in the same block as
133+
/// \p oldValue, or it must dominate \p oldValue (rather than merely
134+
/// dominating its uses).
135+
///
131136
/// DISCUSSION: We do not check that the types line up here so that we can
132137
/// allow for our users to transform our new value in ways that preserve
133138
/// ownership at \p oldValue before we perform the actual RAUW. If \p newValue
@@ -168,6 +173,9 @@ class OwnershipRAUWHelper {
168173
/// a single use of a value with another value with a different ownership. We
169174
/// allow for the values to have different types.
170175
///
176+
/// Precondition: if \p use ends a borrow scope, then \p newValue dominates the
177+
/// BorrowedValue that begins the scope.
178+
///
171179
/// NOTE: When not in OSSA, this just performs a normal set use, so this code is
172180
/// safe to use with all code.
173181
class OwnershipReplaceSingleUseHelper {

0 commit comments

Comments
 (0)