@@ -218,8 +218,6 @@ SILValue CanonicalizeBorrowScope::findDefInBorrowScope(SILValue value) {
218
218
// /
219
219
// / \p innerValue is either the initial begin_borrow, or a forwarding operation
220
220
// / within the borrow scope.
221
- // /
222
- // / Note: This must always return true when innerValue is a function argument.
223
221
template <typename Visitor>
224
222
bool CanonicalizeBorrowScope::visitBorrowScopeUses (SILValue innerValue,
225
223
Visitor &visitor) {
@@ -277,14 +275,12 @@ bool CanonicalizeBorrowScope::visitBorrowScopeUses(SILValue innerValue,
277
275
case OperandOwnership::PointerEscape:
278
276
// Pointer escapes are only allowed if they use the guaranteed value,
279
277
// 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.
282
279
if (use->get ()->getOwnershipKind () != OwnershipKind::Guaranteed &&
283
280
!isa<SILFunctionArgument>(borrowedValue.value )) {
284
281
return false ;
285
282
}
286
283
if (!visitor.visitUse (use)) {
287
- assert (!isa<SILFunctionArgument>(borrowedValue.value ));
288
284
return false ;
289
285
}
290
286
break ;
@@ -293,7 +289,6 @@ bool CanonicalizeBorrowScope::visitBorrowScopeUses(SILValue innerValue,
293
289
case OperandOwnership::ForwardingConsume:
294
290
if (CanonicalizeBorrowScope::isRewritableOSSAForward (user)) {
295
291
if (!visitor.visitForwardingUse (use)) {
296
- assert (!isa<SILFunctionArgument>(borrowedValue.value ));
297
292
return false ;
298
293
}
299
294
break ;
@@ -306,7 +301,6 @@ bool CanonicalizeBorrowScope::visitBorrowScopeUses(SILValue innerValue,
306
301
case OperandOwnership::BitwiseEscape:
307
302
case OperandOwnership::DestroyingConsume:
308
303
if (!visitor.visitUse (use)) {
309
- assert (!isa<SILFunctionArgument>(borrowedValue.value ));
310
304
return false ;
311
305
}
312
306
break ;
@@ -480,7 +474,9 @@ class RewriteInnerBorrowUses {
480
474
if (!hasValueOwnership (result)) {
481
475
continue ;
482
476
}
483
- scope.visitBorrowScopeUses (result, *this );
477
+ if (!scope.visitBorrowScopeUses (result, *this )) {
478
+ return false ;
479
+ }
484
480
}
485
481
// Update this operand bypassing any copies.
486
482
SILValue value = use->get ();
@@ -796,9 +792,7 @@ bool CanonicalizeBorrowScope::consolidateBorrowScope() {
796
792
if (outerUseInsts.empty ()) {
797
793
RewriteInnerBorrowUses innerRewriter (*this );
798
794
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);
802
796
}
803
797
LLVM_DEBUG (llvm::dbgs () << " Outer uses:\n " ;
804
798
for (SILInstruction *inst
@@ -826,9 +820,7 @@ bool CanonicalizeBorrowScope::canonicalizeFunctionArgument(
826
820
RewriteInnerBorrowUses innerRewriter (*this );
827
821
beginVisitBorrowScopeUses (); // reset the def/use worklist
828
822
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);
832
824
}
833
825
834
826
// / Canonicalize a worklist of extended lifetimes. This iterates after rewriting
0 commit comments