@@ -73,12 +73,6 @@ class OperandOwnershipKindClassifier
73
73
return getOwnershipKind () == ValueOwnershipKind::None;
74
74
}
75
75
76
- OperandOwnershipKindMap visitForwardingInst (SILInstruction *i,
77
- ArrayRef<Operand> ops);
78
- OperandOwnershipKindMap visitForwardingInst (SILInstruction *i) {
79
- return visitForwardingInst (i, i->getAllOperands ());
80
- }
81
-
82
76
OperandOwnershipKindMap
83
77
visitApplyParameter (ValueOwnershipKind requiredConvention,
84
78
UseLifetimeConstraint requirement);
@@ -299,38 +293,12 @@ ACCEPTS_ANY_OWNERSHIP_INST(ConvertEscapeToNoEscape)
299
293
#include " swift/AST/ReferenceStorage.def"
300
294
#undef ACCEPTS_ANY_OWNERSHIP_INST
301
295
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
-
330
296
#define FORWARD_ANY_OWNERSHIP_INST (INST ) \
331
297
OperandOwnershipKindMap OperandOwnershipKindClassifier::visit##INST##Inst( \
332
298
INST##Inst *i) { \
333
- return visitForwardingInst (i); \
299
+ auto kind = i->getOwnershipKind (); \
300
+ auto lifetimeConstraint = kind.getForwardingLifetimeConstraint (); \
301
+ return Map::compatibilityMap (kind, lifetimeConstraint); \
334
302
}
335
303
FORWARD_ANY_OWNERSHIP_INST (Tuple)
336
304
FORWARD_ANY_OWNERSHIP_INST(Struct)
@@ -348,25 +316,10 @@ FORWARD_ANY_OWNERSHIP_INST(InitExistentialRef)
348
316
FORWARD_ANY_OWNERSHIP_INST(DifferentiableFunction)
349
317
FORWARD_ANY_OWNERSHIP_INST(LinearFunction)
350
318
FORWARD_ANY_OWNERSHIP_INST(UncheckedValueCast)
319
+ FORWARD_ANY_OWNERSHIP_INST(DestructureStruct)
320
+ FORWARD_ANY_OWNERSHIP_INST(DestructureTuple)
351
321
#undef FORWARD_ANY_OWNERSHIP_INST
352
322
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
-
370
323
// An instruction that forwards a constant ownership or trivial ownership.
371
324
#define FORWARD_CONSTANT_OR_NONE_OWNERSHIP_INST (OWNERSHIP, \
372
325
USE_LIFETIME_CONSTRAINT, INST) \
@@ -410,7 +363,9 @@ OperandOwnershipKindClassifier::visitSelectEnumInst(SelectEnumInst *i) {
410
363
return Map::allLive ();
411
364
}
412
365
413
- return visitForwardingInst (i, i->getAllOperands ().drop_front ());
366
+ auto kind = i->getOwnershipKind ();
367
+ auto lifetimeConstraint = kind.getForwardingLifetimeConstraint ();
368
+ return Map::compatibilityMap (kind, lifetimeConstraint);
414
369
}
415
370
416
371
OperandOwnershipKindMap
0 commit comments