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(
169169 SILValue guaranteedValue,
170170 SmallVectorImpl<Operand *> &usePoints);
171171
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+
172180// / An operand that forwards ownership to one or more results.
173181class ForwardingOperand {
174182 Operand *use = nullptr ;
Original file line number Diff line number Diff line change @@ -305,6 +305,25 @@ bool swift::findExtendedUsesOfSimpleBorrowedValue(
305305 return true ;
306306}
307307
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+
308327// Find all use points of \p guaranteedValue within its borrow scope. All use
309328// points will be dominated by \p guaranteedValue.
310329//
You can’t perform that action at this time.
0 commit comments