@@ -693,42 +693,12 @@ bool BorrowingOperand::visitExtendedScopeEndingUses(
693
693
function_ref<bool (Operand *)> visitor) const {
694
694
695
695
if (hasBorrowIntroducingUser ()) {
696
- return visitBorrowIntroducingUserResults (
697
- [visitor](BorrowedValue borrowedValue) {
698
- return borrowedValue.visitExtendedScopeEndingUses (visitor);
699
- });
696
+ auto borrowedValue = getBorrowIntroducingUserResult ();
697
+ return borrowedValue.visitExtendedScopeEndingUses (visitor);
700
698
}
701
699
return visitScopeEndingUses (visitor);
702
700
}
703
701
704
- bool BorrowingOperand::visitBorrowIntroducingUserResults (
705
- function_ref<bool (BorrowedValue)> visitor) const {
706
- switch (kind) {
707
- case BorrowingOperandKind::Invalid:
708
- llvm_unreachable (" Using invalid case" );
709
- case BorrowingOperandKind::Apply:
710
- case BorrowingOperandKind::TryApply:
711
- case BorrowingOperandKind::BeginApply:
712
- case BorrowingOperandKind::Yield:
713
- case BorrowingOperandKind::PartialApplyStack:
714
- case BorrowingOperandKind::BeginAsyncLet:
715
- llvm_unreachable (" Never has borrow introducer results!" );
716
- case BorrowingOperandKind::BeginBorrow: {
717
- auto value = BorrowedValue (cast<BeginBorrowInst>(op->getUser ()));
718
- assert (value);
719
- return visitor (value);
720
- }
721
- case BorrowingOperandKind::Branch: {
722
- auto *bi = cast<BranchInst>(op->getUser ());
723
- auto value = BorrowedValue (
724
- bi->getDestBB ()->getArgument (op->getOperandNumber ()));
725
- assert (value && " guaranteed-to-unowned conversion not allowed on branches" );
726
- return visitor (value);
727
- }
728
- }
729
- llvm_unreachable (" Covered switch isn't covered?!" );
730
- }
731
-
732
702
BorrowedValue BorrowingOperand::getBorrowIntroducingUserResult () const {
733
703
switch (kind) {
734
704
case BorrowingOperandKind::Invalid:
@@ -900,11 +870,9 @@ bool BorrowedValue::visitExtendedScopeEndingUses(
900
870
901
871
auto visitEnd = [&](Operand *scopeEndingUse) {
902
872
if (scopeEndingUse->getOperandOwnership () == OperandOwnership::Reborrow) {
903
- BorrowingOperand (scopeEndingUse).visitBorrowIntroducingUserResults (
904
- [&](BorrowedValue borrowedValue) {
905
- reborrows.insert (borrowedValue.value );
906
- return true ;
907
- });
873
+ auto borrowedValue =
874
+ BorrowingOperand (scopeEndingUse).getBorrowIntroducingUserResult ();
875
+ reborrows.insert (borrowedValue.value );
908
876
return true ;
909
877
}
910
878
return visitor (scopeEndingUse);
@@ -929,11 +897,9 @@ bool BorrowedValue::visitTransitiveLifetimeEndingUses(
929
897
930
898
auto visitEnd = [&](Operand *scopeEndingUse) {
931
899
if (scopeEndingUse->getOperandOwnership () == OperandOwnership::Reborrow) {
932
- BorrowingOperand (scopeEndingUse)
933
- .visitBorrowIntroducingUserResults ([&](BorrowedValue borrowedValue) {
934
- reborrows.insert (borrowedValue.value );
935
- return true ;
936
- });
900
+ auto borrowedValue =
901
+ BorrowingOperand (scopeEndingUse).getBorrowIntroducingUserResult ();
902
+ reborrows.insert (borrowedValue.value );
937
903
// visitor on the reborrow
938
904
return visitor (scopeEndingUse);
939
905
}
@@ -984,16 +950,14 @@ bool BorrowedValue::visitInteriorPointerOperandHelper(
984
950
break ;
985
951
}
986
952
987
- borrowingOperand.visitBorrowIntroducingUserResults ([&](auto bv) {
988
- for (auto *use : bv->getUses ()) {
989
- if (auto intPtrOperand = InteriorPointerOperand (use)) {
990
- func (intPtrOperand);
991
- continue ;
992
- }
993
- worklist.push_back (use);
953
+ auto bv = borrowingOperand.getBorrowIntroducingUserResult ();
954
+ for (auto *use : bv->getUses ()) {
955
+ if (auto intPtrOperand = InteriorPointerOperand (use)) {
956
+ func (intPtrOperand);
957
+ continue ;
994
958
}
995
- return true ;
996
- });
959
+ worklist. push_back (use) ;
960
+ }
997
961
continue ;
998
962
}
999
963
0 commit comments