File tree Expand file tree Collapse file tree 2 files changed +27
-0
lines changed Expand file tree Collapse file tree 2 files changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -169,6 +169,14 @@ bool findExtendedTransitiveGuaranteedUses(
169
169
SILValue guaranteedValue,
170
170
SmallVectorImpl<Operand *> &usePoints);
171
171
172
+ // / Find non-transitive uses of a simple (i.e. without looking through
173
+ // / reborrows) value.
174
+ // /
175
+ // / The scope-ending use of borrows of the value are included. If a borrow of
176
+ // / the value is reborrowed, returns false.
177
+ bool findUsesOfSimpleValue (SILValue value,
178
+ SmallVectorImpl<Operand *> *usePoints = nullptr );
179
+
172
180
// / An operand that forwards ownership to one or more results.
173
181
class ForwardingOperand {
174
182
Operand *use = nullptr ;
Original file line number Diff line number Diff line change @@ -305,6 +305,25 @@ bool swift::findExtendedUsesOfSimpleBorrowedValue(
305
305
return true ;
306
306
}
307
307
308
+ bool swift::findUsesOfSimpleValue (SILValue value,
309
+ SmallVectorImpl<Operand *> *usePoints) {
310
+ for (auto *use : value->getUses ()) {
311
+ if (use->getOperandOwnership () == OperandOwnership::Borrow) {
312
+ if (!BorrowingOperand (use).visitScopeEndingUses ([&](Operand *end) {
313
+ if (end->getOperandOwnership () == OperandOwnership::Reborrow) {
314
+ return false ;
315
+ }
316
+ usePoints->push_back (use);
317
+ return true ;
318
+ })) {
319
+ return false ;
320
+ }
321
+ }
322
+ usePoints->push_back (use);
323
+ }
324
+ return true ;
325
+ }
326
+
308
327
// Find all use points of \p guaranteedValue within its borrow scope. All use
309
328
// points will be dominated by \p guaranteedValue.
310
329
//
You can’t perform that action at this time.
0 commit comments