Skip to content

Commit ab42f75

Browse files
committed
Remove OperandOwnership::NestedBorrow.
Now that OperandOwnership determines the operand constraints, it doesn't make sense to distinguish between Borrow and NestedBorrow at this level. We want these uses to automatically convert between the nested/non-nested state as the operand's ownership changes. The use does not need to impose any constraint on the ownership of the incoming value. For algorithms that need to distinguish nested borrows, it's still trivial to do so.
1 parent f4e0eae commit ab42f75

File tree

3 files changed

+6
-15
lines changed

3 files changed

+6
-15
lines changed

include/swift/SIL/SILValue.h

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -675,11 +675,13 @@ struct OperandOwnership {
675675
/// (ref_to_unowned, unchecked_trivial_bitcast)
676676
BitwiseEscape,
677677

678-
/// MARK: Uses of Owned values:
679-
680-
/// Borrow. Propagates the owned value within a scope, without consuming it.
678+
/// Borrow. Propagates the owned or guaranteed value within a scope, without
679+
/// ending its lifetime.
681680
/// (begin_borrow, begin_apply with @guaranteed argument)
682681
Borrow,
682+
683+
/// MARK: Uses of Owned values:
684+
683685
/// Destroying Consume. Destroys the owned value immediately.
684686
/// (store, destroy, @owned destructure).
685687
DestroyingConsume,
@@ -689,11 +691,6 @@ struct OperandOwnership {
689691

690692
/// MARK: Uses of Guaranteed values:
691693

692-
/// Nested Borrow. Propagates the guaranteed value within a nested borrow
693-
/// scope, without ending the outer borrow scope, following stack
694-
/// discipline.
695-
/// (begin_borrow, begin_apply with @guaranteed).
696-
NestedBorrow,
697694
/// Interior Pointer. Propagates a trivial value (e.g. address, pointer, or
698695
/// no-escape closure) that depends on the guaranteed value within the
699696
/// base's borrow scope. The verifier checks that all uses of the trivial
@@ -750,13 +747,11 @@ inline OwnershipConstraint OperandOwnership::getOwnershipConstraint() {
750747
case OperandOwnership::ForwardingUnowned:
751748
case OperandOwnership::PointerEscape:
752749
case OperandOwnership::BitwiseEscape:
753-
return {OwnershipKind::Any, UseLifetimeConstraint::NonLifetimeEnding};
754750
case OperandOwnership::Borrow:
755-
return {OwnershipKind::Owned, UseLifetimeConstraint::NonLifetimeEnding};
751+
return {OwnershipKind::Any, UseLifetimeConstraint::NonLifetimeEnding};
756752
case OperandOwnership::DestroyingConsume:
757753
case OperandOwnership::ForwardingConsume:
758754
return {OwnershipKind::Owned, UseLifetimeConstraint::LifetimeEnding};
759-
case OperandOwnership::NestedBorrow:
760755
case OperandOwnership::InteriorPointer:
761756
case OperandOwnership::ForwardingBorrow:
762757
return {OwnershipKind::Guaranteed,

lib/SIL/IR/SILValue.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,6 @@ static bool canAcceptUnownedValue(OperandOwnership operandOwnership) {
333333
case OperandOwnership::Borrow:
334334
case OperandOwnership::DestroyingConsume:
335335
case OperandOwnership::ForwardingConsume:
336-
case OperandOwnership::NestedBorrow:
337336
case OperandOwnership::InteriorPointer:
338337
case OperandOwnership::ForwardingBorrow:
339338
case OperandOwnership::EndBorrow:
@@ -412,8 +411,6 @@ StringRef OperandOwnership::asString() const {
412411
return "destroying-consume";
413412
case OperandOwnership::ForwardingConsume:
414413
return "forwarding-consume";
415-
case OperandOwnership::NestedBorrow:
416-
return "nested-borrow";
417414
case OperandOwnership::InteriorPointer:
418415
return "interior-pointer";
419416
case OperandOwnership::ForwardingBorrow:

lib/SIL/Utils/OwnershipUtils.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -890,7 +890,6 @@ Optional<ForwardingOperand> ForwardingOperand::get(Operand *use) {
890890
case OperandOwnership::BitwiseEscape:
891891
case OperandOwnership::Borrow:
892892
case OperandOwnership::DestroyingConsume:
893-
case OperandOwnership::NestedBorrow:
894893
case OperandOwnership::InteriorPointer:
895894
case OperandOwnership::EndBorrow:
896895
case OperandOwnership::Reborrow:

0 commit comments

Comments
 (0)