@@ -218,8 +218,6 @@ SILValue CanonicalizeBorrowScope::findDefInBorrowScope(SILValue value) {
218218// /
219219// / \p innerValue is either the initial begin_borrow, or a forwarding operation
220220// / within the borrow scope.
221- // /
222- // / Note: This must always return true when innerValue is a function argument.
223221template <typename Visitor>
224222bool CanonicalizeBorrowScope::visitBorrowScopeUses (SILValue innerValue,
225223 Visitor &visitor) {
@@ -277,14 +275,12 @@ bool CanonicalizeBorrowScope::visitBorrowScopeUses(SILValue innerValue,
277275 case OperandOwnership::PointerEscape:
278276 // Pointer escapes are only allowed if they use the guaranteed value,
279277 // which means that the escaped value must be confined to the current
280- // borrow scope. visitBorrowScopeUses must never return false when
281- // borrowedValue is a SILFunctionArgument.
278+ // borrow scope.
282279 if (use->get ()->getOwnershipKind () != OwnershipKind::Guaranteed &&
283280 !isa<SILFunctionArgument>(borrowedValue.value )) {
284281 return false ;
285282 }
286283 if (!visitor.visitUse (use)) {
287- assert (!isa<SILFunctionArgument>(borrowedValue.value ));
288284 return false ;
289285 }
290286 break ;
@@ -293,7 +289,6 @@ bool CanonicalizeBorrowScope::visitBorrowScopeUses(SILValue innerValue,
293289 case OperandOwnership::ForwardingConsume:
294290 if (CanonicalizeBorrowScope::isRewritableOSSAForward (user)) {
295291 if (!visitor.visitForwardingUse (use)) {
296- assert (!isa<SILFunctionArgument>(borrowedValue.value ));
297292 return false ;
298293 }
299294 break ;
@@ -306,7 +301,6 @@ bool CanonicalizeBorrowScope::visitBorrowScopeUses(SILValue innerValue,
306301 case OperandOwnership::BitwiseEscape:
307302 case OperandOwnership::DestroyingConsume:
308303 if (!visitor.visitUse (use)) {
309- assert (!isa<SILFunctionArgument>(borrowedValue.value ));
310304 return false ;
311305 }
312306 break ;
@@ -480,7 +474,9 @@ class RewriteInnerBorrowUses {
480474 if (!hasValueOwnership (result)) {
481475 continue ;
482476 }
483- scope.visitBorrowScopeUses (result, *this );
477+ if (!scope.visitBorrowScopeUses (result, *this )) {
478+ return false ;
479+ }
484480 }
485481 // Update this operand bypassing any copies.
486482 SILValue value = use->get ();
@@ -796,9 +792,7 @@ bool CanonicalizeBorrowScope::consolidateBorrowScope() {
796792 if (outerUseInsts.empty ()) {
797793 RewriteInnerBorrowUses innerRewriter (*this );
798794 beginVisitBorrowScopeUses (); // reset the def/use worklist
799- bool succeed = visitBorrowScopeUses (borrowedValue.value , innerRewriter);
800- assert (succeed && " should be filtered by FindBorrowScopeUses" );
801- return true ;
795+ return visitBorrowScopeUses (borrowedValue.value , innerRewriter);
802796 }
803797 LLVM_DEBUG (llvm::dbgs () << " Outer uses:\n " ;
804798 for (SILInstruction *inst
@@ -826,9 +820,7 @@ bool CanonicalizeBorrowScope::canonicalizeFunctionArgument(
826820 RewriteInnerBorrowUses innerRewriter (*this );
827821 beginVisitBorrowScopeUses (); // reset the def/use worklist
828822
829- bool succeed = visitBorrowScopeUses (borrowedValue.value , innerRewriter);
830- assert (succeed && " must always succeed for function arguments" );
831- return true ;
823+ return visitBorrowScopeUses (borrowedValue.value , innerRewriter);
832824}
833825
834826// / Canonicalize a worklist of extended lifetimes. This iterates after rewriting
0 commit comments