BorrowToDestructureUtils: handle borrowing switches.

Instead of trying to convert all switches into consumes, allow a switch of a borrow
to remain as such.
This commit is contained in:
Joe Groff
2024-01-31 16:09:53 -08:00
parent 6706feaf5e
commit 03e2e8f476
4 changed files with 120 additions and 47 deletions

View File

@@ -488,10 +488,10 @@ void MoveOnlyObjectCheckerPImpl::check(DominanceInfo *domTree,
// Handle:
//
// bb0(%0 : @guaranteed $Type):
// %1 = copy_value %0
// %2 = mark_unresolved_non_copyable_value [no_consume_or_assign] %1
if (auto *arg = dyn_cast<SILFunctionArgument>(i->getOperand(0))) {
// bb(%arg : @guaranteed $Type):
// %copy = copy_value %arg
// %mark = mark_unresolved_non_copyable_value [no_consume_or_assign] %copy
if (auto *arg = dyn_cast<SILArgument>(i->getOperand(0))) {
if (arg->getOwnershipKind() == OwnershipKind::Guaranteed) {
for (auto *use : markedInst->getConsumingUses()) {
destroys.push_back(cast<DestroyValueInst>(use->getUser()));