Skip to content

Commit 66a8f91

Browse files
authored
Merge pull request #41558 from atrick/borrow-uses-assert
Add asserts to CanonicalizeBorrowScope::visitBorrowScopeUses
2 parents 9d1bf8f + 7e66bfb commit 66a8f91

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

lib/SILOptimizer/Utils/CanonicalizeBorrowScope.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,15 +269,18 @@ bool CanonicalizeBorrowScope::visitBorrowScopeUses(SILValue innerValue,
269269
return false;
270270
}
271271
if (!visitor.visitUse(use)) {
272+
assert(!isa<SILFunctionArgument>(borrowedValue.value));
272273
return false;
273274
}
274275
break;
275276

276277
case OperandOwnership::ForwardingBorrow:
277278
case OperandOwnership::ForwardingConsume:
278279
if (CanonicalizeBorrowScope::isRewritableOSSAForward(user)) {
279-
if (!visitor.visitForwardingUse(use))
280+
if (!visitor.visitForwardingUse(use)) {
281+
assert(!isa<SILFunctionArgument>(borrowedValue.value));
280282
return false;
283+
}
281284
break;
282285
}
283286
LLVM_FALLTHROUGH;
@@ -287,8 +290,10 @@ bool CanonicalizeBorrowScope::visitBorrowScopeUses(SILValue innerValue,
287290
case OperandOwnership::UnownedInstantaneousUse:
288291
case OperandOwnership::BitwiseEscape:
289292
case OperandOwnership::DestroyingConsume:
290-
if (!visitor.visitUse(use))
293+
if (!visitor.visitUse(use)) {
294+
assert(!isa<SILFunctionArgument>(borrowedValue.value));
291295
return false;
296+
}
292297
break;
293298
} // end switch OperandOwnership
294299
}

0 commit comments

Comments
 (0)