mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[OwnershipUtils] Added find for simple value.
This commit is contained in:
@@ -169,6 +169,14 @@ bool findExtendedTransitiveGuaranteedUses(
|
|||||||
SILValue guaranteedValue,
|
SILValue guaranteedValue,
|
||||||
SmallVectorImpl<Operand *> &usePoints);
|
SmallVectorImpl<Operand *> &usePoints);
|
||||||
|
|
||||||
|
/// Find non-transitive uses of a simple (i.e. without looking through
|
||||||
|
/// reborrows) value.
|
||||||
|
///
|
||||||
|
/// The scope-ending use of borrows of the value are included. If a borrow of
|
||||||
|
/// the value is reborrowed, returns false.
|
||||||
|
bool findUsesOfSimpleValue(SILValue value,
|
||||||
|
SmallVectorImpl<Operand *> *usePoints = nullptr);
|
||||||
|
|
||||||
/// An operand that forwards ownership to one or more results.
|
/// An operand that forwards ownership to one or more results.
|
||||||
class ForwardingOperand {
|
class ForwardingOperand {
|
||||||
Operand *use = nullptr;
|
Operand *use = nullptr;
|
||||||
|
|||||||
@@ -305,6 +305,25 @@ bool swift::findExtendedUsesOfSimpleBorrowedValue(
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool swift::findUsesOfSimpleValue(SILValue value,
|
||||||
|
SmallVectorImpl<Operand *> *usePoints) {
|
||||||
|
for (auto *use : value->getUses()) {
|
||||||
|
if (use->getOperandOwnership() == OperandOwnership::Borrow) {
|
||||||
|
if (!BorrowingOperand(use).visitScopeEndingUses([&](Operand *end) {
|
||||||
|
if (end->getOperandOwnership() == OperandOwnership::Reborrow) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
usePoints->push_back(use);
|
||||||
|
return true;
|
||||||
|
})) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
usePoints->push_back(use);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
// Find all use points of \p guaranteedValue within its borrow scope. All use
|
// Find all use points of \p guaranteedValue within its borrow scope. All use
|
||||||
// points will be dominated by \p guaranteedValue.
|
// points will be dominated by \p guaranteedValue.
|
||||||
//
|
//
|
||||||
|
|||||||
Reference in New Issue
Block a user