@@ -73,12 +73,6 @@ class OperandOwnershipKindClassifier
7373 return getOwnershipKind () == ValueOwnershipKind::None;
7474 }
7575
76- OperandOwnershipKindMap visitForwardingInst (SILInstruction *i,
77- ArrayRef<Operand> ops);
78- OperandOwnershipKindMap visitForwardingInst (SILInstruction *i) {
79- return visitForwardingInst (i, i->getAllOperands ());
80- }
81-
8276 OperandOwnershipKindMap
8377 visitApplyParameter (ValueOwnershipKind requiredConvention,
8478 UseLifetimeConstraint requirement);
@@ -299,38 +293,12 @@ ACCEPTS_ANY_OWNERSHIP_INST(ConvertEscapeToNoEscape)
299293#include " swift/AST/ReferenceStorage.def"
300294#undef ACCEPTS_ANY_OWNERSHIP_INST
301295
302- OperandOwnershipKindMap
303- OperandOwnershipKindClassifier::visitForwardingInst (SILInstruction *i,
304- ArrayRef<Operand> ops) {
305- assert (i->getNumOperands () && " Expected to have non-zero operands" );
306- assert (isOwnershipForwardingInst (i) &&
307- " Expected to have an ownership forwarding inst" );
308-
309- // Merge all of the ownership of our operands. If we get back a .none from the
310- // merge, then we return an empty compatibility map. This ensures that we will
311- // not be compatible with /any/ input triggering a special error in the
312- // ownership verifier.
313- Optional<ValueOwnershipKind> optionalKind =
314- ValueOwnershipKind::merge (makeOptionalTransformRange (
315- ops, [&i](const Operand &op) -> Optional<ValueOwnershipKind> {
316- if (i->isTypeDependentOperand (op))
317- return None;
318- return op.get ().getOwnershipKind ();
319- }));
320- if (!optionalKind)
321- return Map ();
322-
323- auto kind = optionalKind.getValue ();
324- if (kind == ValueOwnershipKind::None)
325- return Map::allLive ();
326- auto lifetimeConstraint = kind.getForwardingLifetimeConstraint ();
327- return Map::compatibilityMap (kind, lifetimeConstraint);
328- }
329-
330296#define FORWARD_ANY_OWNERSHIP_INST (INST ) \
331297 OperandOwnershipKindMap OperandOwnershipKindClassifier::visit##INST##Inst( \
332298 INST##Inst *i) { \
333- return visitForwardingInst (i); \
299+ auto kind = i->getOwnershipKind (); \
300+ auto lifetimeConstraint = kind.getForwardingLifetimeConstraint (); \
301+ return Map::compatibilityMap (kind, lifetimeConstraint); \
334302 }
335303FORWARD_ANY_OWNERSHIP_INST (Tuple)
336304FORWARD_ANY_OWNERSHIP_INST(Struct)
@@ -348,25 +316,10 @@ FORWARD_ANY_OWNERSHIP_INST(InitExistentialRef)
348316FORWARD_ANY_OWNERSHIP_INST(DifferentiableFunction)
349317FORWARD_ANY_OWNERSHIP_INST(LinearFunction)
350318FORWARD_ANY_OWNERSHIP_INST(UncheckedValueCast)
319+ FORWARD_ANY_OWNERSHIP_INST(DestructureStruct)
320+ FORWARD_ANY_OWNERSHIP_INST(DestructureTuple)
351321#undef FORWARD_ANY_OWNERSHIP_INST
352322
353- // Temporary implementation for staging purposes.
354- OperandOwnershipKindMap
355- OperandOwnershipKindClassifier::visitDestructureStructInst (
356- DestructureStructInst *dsi) {
357- auto kind = dsi->getOwnershipKind ();
358- auto constraint = kind.getForwardingLifetimeConstraint ();
359- return {kind, constraint};
360- }
361-
362- OperandOwnershipKindMap
363- OperandOwnershipKindClassifier::visitDestructureTupleInst (
364- DestructureTupleInst *dsi) {
365- auto kind = dsi->getOwnershipKind ();
366- auto constraint = kind.getForwardingLifetimeConstraint ();
367- return {kind, constraint};
368- }
369-
370323// An instruction that forwards a constant ownership or trivial ownership.
371324#define FORWARD_CONSTANT_OR_NONE_OWNERSHIP_INST (OWNERSHIP, \
372325 USE_LIFETIME_CONSTRAINT, INST) \
@@ -410,7 +363,9 @@ OperandOwnershipKindClassifier::visitSelectEnumInst(SelectEnumInst *i) {
410363 return Map::allLive ();
411364 }
412365
413- return visitForwardingInst (i, i->getAllOperands ().drop_front ());
366+ auto kind = i->getOwnershipKind ();
367+ auto lifetimeConstraint = kind.getForwardingLifetimeConstraint ();
368+ return Map::compatibilityMap (kind, lifetimeConstraint);
414369}
415370
416371OperandOwnershipKindMap
0 commit comments