SIL: Make drop_deinit a ForwardingInstruction.

drop_deinit forwards ownership while effectively stripping the deinitializer. It is similar to a type cast.

Fixes rdar://125590074 ([NonescapableTypes] Nonescapable types
cannot have deinits)
This commit is contained in:
Andrew Trick
2024-04-03 10:43:24 -07:00
parent bac1dc9699
commit 581010d00c
8 changed files with 102 additions and 8 deletions

View File

@@ -547,10 +547,13 @@ static SILBasicBlock::iterator
eliminateUnneededForwardingUnarySingleValueInst(SingleValueInstruction *inst,
CanonicalizeInstruction &pass) {
auto next = std::next(inst->getIterator());
for (auto *use : getNonDebugUses(inst))
if (!isa<DestroyValueInst>(use->getUser()))
return next;
for (auto *use : getNonDebugUses(inst)) {
if (auto *destroy = dyn_cast<DestroyValueInst>(use->getUser())) {
if (destroy->isFullDeinitialization())
continue;
}
return next;
}
deleteAllDebugUses(inst, pass.callbacks);
SILValue op = inst->getOperand(0);
inst->replaceAllUsesWith(op);