@@ -60,8 +60,8 @@ bool swift::findPointerEscape(SILValue original) {
60
60
}
61
61
case OperandOwnership::Borrow: {
62
62
auto borrowOp = BorrowingOperand (use);
63
- if (auto borrowValue = borrowOp.getBorrowIntroducingUserResult ()) {
64
- worklist.pushIfNotVisited (borrowValue. value );
63
+ if (auto result = borrowOp.getBorrowIntroducingUserResult ()) {
64
+ worklist.pushIfNotVisited (result );
65
65
}
66
66
break ;
67
67
}
@@ -548,7 +548,7 @@ findExtendedTransitiveGuaranteedUses(SILValue guaranteedValue,
548
548
usePoints.pop_back ();
549
549
auto borrowedPhi =
550
550
BorrowingOperand (reborrow).getBorrowIntroducingUserResult ();
551
- reborrows.insert (borrowedPhi. value );
551
+ reborrows.insert (borrowedPhi);
552
552
};
553
553
if (!findTransitiveGuaranteedUses (guaranteedValue, usePoints, visitReborrow))
554
554
return false ;
@@ -768,13 +768,15 @@ bool BorrowingOperand::visitExtendedScopeEndingUses(
768
768
function_ref<bool(Operand *)> visitUnknownUse) const {
769
769
770
770
if (hasBorrowIntroducingUser ()) {
771
- auto borrowedValue = getBorrowIntroducingUserResult ();
772
- return borrowedValue.visitExtendedScopeEndingUses (visitor);
771
+ auto result = getBorrowIntroducingUserResult ();
772
+ if (auto borrowedValue = BorrowedValue (result)) {
773
+ return borrowedValue.visitExtendedScopeEndingUses (visitor);
774
+ }
773
775
}
774
776
return visitScopeEndingUses (visitor, visitUnknownUse);
775
777
}
776
778
777
- BorrowedValue BorrowingOperand::getBorrowIntroducingUserResult () const {
779
+ SILValue BorrowingOperand::getBorrowIntroducingUserResult () const {
778
780
switch (kind) {
779
781
case BorrowingOperandKind::Invalid:
780
782
case BorrowingOperandKind::Apply:
@@ -785,20 +787,15 @@ BorrowedValue BorrowingOperand::getBorrowIntroducingUserResult() const {
785
787
case BorrowingOperandKind::MarkDependenceNonEscaping:
786
788
case BorrowingOperandKind::BeginAsyncLet:
787
789
case BorrowingOperandKind::StoreBorrow:
788
- return BorrowedValue ();
790
+ return SILValue ();
789
791
790
792
case BorrowingOperandKind::BeginBorrow:
791
793
case BorrowingOperandKind::BorrowedFrom: {
792
- auto value = BorrowedValue (cast<SingleValueInstruction>(op->getUser ()));
793
- assert (value);
794
- return value;
794
+ return cast<SingleValueInstruction>(op->getUser ());
795
795
}
796
796
case BorrowingOperandKind::Branch: {
797
797
auto *bi = cast<BranchInst>(op->getUser ());
798
- auto value =
799
- BorrowedValue (bi->getDestBB ()->getArgument (op->getOperandNumber ()));
800
- assert (value && " guaranteed-to-unowned conversion not allowed on branches" );
801
- return value;
798
+ return bi->getDestBB ()->getArgument (op->getOperandNumber ());
802
799
}
803
800
}
804
801
llvm_unreachable (" covered switch" );
@@ -970,9 +967,9 @@ bool BorrowedValue::visitExtendedScopeEndingUses(
970
967
971
968
auto visitEnd = [&](Operand *scopeEndingUse) {
972
969
if (scopeEndingUse->getOperandOwnership () == OperandOwnership::Reborrow) {
973
- auto borrowedValue =
970
+ auto result =
974
971
BorrowingOperand (scopeEndingUse).getBorrowIntroducingUserResult ();
975
- reborrows.insert (borrowedValue. value );
972
+ reborrows.insert (result );
976
973
return true ;
977
974
}
978
975
return visitor (scopeEndingUse);
@@ -997,9 +994,9 @@ bool BorrowedValue::visitTransitiveLifetimeEndingUses(
997
994
998
995
auto visitEnd = [&](Operand *scopeEndingUse) {
999
996
if (scopeEndingUse->getOperandOwnership () == OperandOwnership::Reborrow) {
1000
- auto borrowedValue =
997
+ auto result =
1001
998
BorrowingOperand (scopeEndingUse).getBorrowIntroducingUserResult ();
1002
- reborrows.insert (borrowedValue. value );
999
+ reborrows.insert (result );
1003
1000
// visitor on the reborrow
1004
1001
return visitor (scopeEndingUse);
1005
1002
}
@@ -1050,8 +1047,8 @@ bool BorrowedValue::visitInteriorPointerOperandHelper(
1050
1047
break ;
1051
1048
}
1052
1049
1053
- auto bv = borrowingOperand.getBorrowIntroducingUserResult ();
1054
- for (auto *use : bv ->getUses ()) {
1050
+ auto result = borrowingOperand.getBorrowIntroducingUserResult ();
1051
+ for (auto *use : result ->getUses ()) {
1055
1052
if (auto intPtrOperand = InteriorPointerOperand (use)) {
1056
1053
func (intPtrOperand);
1057
1054
continue ;
0 commit comments