@@ -147,21 +147,18 @@ bool swift::canOpcodeForwardOwnedValues(Operand *use) {
147
147
// Guaranteed Use-Point (Lifetime) Discovery
148
148
// ===----------------------------------------------------------------------===//
149
149
150
- // Find all use points of \p guaranteedValue within its borrow scope where \p
151
- // guaranteedValue is not itself a BorrowedValue (it does not introduce a borrow
152
- // scope). This means there is no need to consider reborrows, and all uses are
153
- // naturally dominated by \p guaranteedValue. On the other hand, if a
154
- // PointerEscape is found, then no assumption can be made about \p
155
- // guaranteedValue's lifetime. Therefore the use points are incomplete and this
156
- // returns false.
150
+ // Find all use points of \p guaranteedValue within its borrow scope. All uses
151
+ // are naturally dominated by \p guaranteedValue. If a PointerEscape is found,
152
+ // then no assumption can be made about \p guaranteedValue's lifetime. Therefore
153
+ // the use points are incomplete and this returns false.
157
154
//
158
155
// Accumulate results in \p usePoints, ignoring existing elements.
159
156
//
160
157
// Skip over nested borrow scopes. Their scope-ending instructions are their use
161
158
// points. Transitively find all nested scope-ending instructions by looking
162
159
// through nested reborrows. Nested reborrows are not use points and \p
163
160
// visitReborrow is not called for them.
164
- static bool
161
+ bool swift::
165
162
findInnerTransitiveGuaranteedUses (SILValue guaranteedValue,
166
163
SmallVectorImpl<Operand *> &usePoints) {
167
164
// Push the value's immediate uses.
@@ -195,7 +192,6 @@ findInnerTransitiveGuaranteedUses(SILValue guaranteedValue,
195
192
case OperandOwnership::TrivialUse:
196
193
case OperandOwnership::ForwardingConsume:
197
194
case OperandOwnership::DestroyingConsume:
198
- case OperandOwnership::Reborrow:
199
195
llvm_unreachable (" this operand cannot handle an inner guaranteed use" );
200
196
201
197
case OperandOwnership::ForwardingUnowned:
@@ -205,7 +201,12 @@ findInnerTransitiveGuaranteedUses(SILValue guaranteedValue,
205
201
case OperandOwnership::InstantaneousUse:
206
202
case OperandOwnership::UnownedInstantaneousUse:
207
203
case OperandOwnership::BitwiseEscape:
208
- // An end_borrow may be pushed as a use when processing a nested borrow.
204
+ // Reborrow only happens when this is called on a value that creates a
205
+ // borrow scope.
206
+ case OperandOwnership::Reborrow:
207
+ // EndBorrow either happens when this is called on a value that creates a
208
+ // borrow scope, or when it is pushed as a use when processing a nested
209
+ // borrow.
209
210
case OperandOwnership::EndBorrow:
210
211
break ;
211
212
0 commit comments