Skip to content

Commit 59c484e

Browse files
committed
[sil] Teach the various address verifiers about ExplicitCopyAddrInst.
Just treating it the same as copy_addr as expected.
1 parent 22df096 commit 59c484e

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

lib/SIL/Utils/OwnershipUtils.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1033,7 +1033,8 @@ swift::findTransitiveUsesForAddress(SILValue projectedAddress,
10331033
isa<SwitchEnumAddrInst>(user) || isa<CheckedCastAddrBranchInst>(user) ||
10341034
isa<SelectEnumAddrInst>(user) || isa<InjectEnumAddrInst>(user) ||
10351035
isa<IsUniqueInst>(user) || isa<ValueMetatypeInst>(user) ||
1036-
isa<DebugValueInst>(user) || isa<EndBorrowInst>(user)) {
1036+
isa<DebugValueInst>(user) || isa<EndBorrowInst>(user) ||
1037+
isa<ExplicitCopyAddrInst>(user)) {
10371038
leafUse(op);
10381039
continue;
10391040
}

lib/SIL/Verifier/SILVerifier.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -505,6 +505,15 @@ struct ImmutableAddressUseVerifier {
505505
return false;
506506
}
507507

508+
bool isConsumingOrMutatingExplicitCopyAddrUse(Operand *use) {
509+
auto *copyAddr = cast<ExplicitCopyAddrInst>(use->getUser());
510+
if (copyAddr->getDest() == use->get())
511+
return true;
512+
if (copyAddr->getSrc() == use->get() && copyAddr->isTakeOfSrc() == IsTake)
513+
return true;
514+
return false;
515+
}
516+
508517
bool isAddrCastToNonConsuming(SingleValueInstruction *i) {
509518
// Check if any of our uses are consuming. If none of them are consuming, we
510519
// are good to go.
@@ -604,6 +613,11 @@ struct ImmutableAddressUseVerifier {
604613
// mutation can happen. The checker will prove eventually that we can
605614
// convert it to a copy_addr [take] [init].
606615
break;
616+
case SILInstructionKind::ExplicitCopyAddrInst:
617+
if (isConsumingOrMutatingExplicitCopyAddrUse(use))
618+
return true;
619+
else
620+
break;
607621
case SILInstructionKind::CopyAddrInst:
608622
if (isConsumingOrMutatingCopyAddrUse(use))
609623
return true;

0 commit comments

Comments
 (0)