Skip to content

Commit 55d1e82

Browse files
committed
SIL ownership verifier: don't require scope-ending instructions for unchecked_ownership_conversion
The optimizer may convert unowned blocks to guaranteed blocks for a partial_apply. This does not require any scope-ending instructions.
1 parent 9de2419 commit 55d1e82

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

lib/SIL/Verifier/SILOwnershipVerifier.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -658,6 +658,15 @@ bool SILValueOwnershipChecker::checkValueWithoutLifetimeEndingUses(
658658
}
659659
}
660660

661+
if (auto *uoc = dyn_cast<UncheckedOwnershipConversionInst>(value)) {
662+
// When converting from `unowned`, which can happen for ObjectiveC blocks,
663+
// we don't require and scope-ending instruction. This falls in the category:
664+
// "trust me, I know what I'm doing".
665+
if (uoc->getOperand()->getOwnershipKind() == OwnershipKind::Unowned) {
666+
return true;
667+
}
668+
}
669+
661670
// If we have an unowned value, then again there is nothing left to do.
662671
if (value->getOwnershipKind() == OwnershipKind::Unowned)
663672
return true;

0 commit comments

Comments
 (0)