@@ -87,8 +87,6 @@ class OperandOwnershipKindClassifier
87
87
return visitForwardingInst (i, i->getAllOperands ());
88
88
}
89
89
90
- OperandOwnershipKindMap
91
- visitEnumArgument (ValueOwnershipKind requiredConvention);
92
90
OperandOwnershipKindMap
93
91
visitApplyParameter (ValueOwnershipKind requiredConvention,
94
92
UseLifetimeConstraint requirement);
@@ -409,17 +407,9 @@ OperandOwnershipKindClassifier::checkTerminatorArgumentMatchesDestBB(
409
407
// Grab the ownership kind of the destination block.
410
408
ValueOwnershipKind destBlockArgOwnershipKind =
411
409
destBB->getArgument (opIndex)->getOwnershipKind ();
412
-
413
- // Then if we do not have an enum, make sure that the conventions match.
414
- if (!getType ().getEnumOrBoundGenericEnum ()) {
415
- auto lifetimeConstraint =
416
- destBlockArgOwnershipKind.getForwardingLifetimeConstraint ();
417
- return Map::compatibilityMap (destBlockArgOwnershipKind, lifetimeConstraint);
418
- }
419
-
420
- // Otherwise, we need to properly handle the sum type nature of enum
421
- // arguments.
422
- return visitEnumArgument (destBlockArgOwnershipKind);
410
+ auto lifetimeConstraint =
411
+ destBlockArgOwnershipKind.getForwardingLifetimeConstraint ();
412
+ return Map::compatibilityMap (destBlockArgOwnershipKind, lifetimeConstraint);
423
413
}
424
414
425
415
OperandOwnershipKindMap
@@ -548,12 +538,6 @@ OperandOwnershipKindClassifier::visitReturnInst(ReturnInst *ri) {
548
538
return Map ();
549
539
550
540
auto base = *mergedBase;
551
-
552
- // TODO: This may not be needed once trivial is any.
553
- if (getType ().getEnumOrBoundGenericEnum ()) {
554
- return visitEnumArgument (base);
555
- }
556
-
557
541
return Map::compatibilityMap (base, base.getForwardingLifetimeConstraint ());
558
542
}
559
543
@@ -641,57 +625,20 @@ OperandOwnershipKindMap OperandOwnershipKindClassifier::visitCallee(
641
625
llvm_unreachable (" Unhandled ParameterConvention in switch." );
642
626
}
643
627
644
- // Visit an enum value that is passed at argument position, including block
645
- // arguments, apply arguments, and return values.
646
- //
647
- // The operand definition's ownership kind may be known to be "trivial",
648
- // but it is still valid to pass that enum to a argument nontrivial type.
649
- // For example:
650
- //
651
- // %val = enum $Optional<SomeClass>, #Optional.none // trivial ownership
652
- // apply %f(%val) : (@owned Optional<SomeClass>) // owned argument
653
- OperandOwnershipKindMap OperandOwnershipKindClassifier::visitEnumArgument (
654
- ValueOwnershipKind requiredKind) {
655
- // Begin with an empty map.
656
- OperandOwnershipKindMap map;
657
-
658
- // The operand has a non-trivial ownership kind. It must match the argument
659
- // convention.
660
- if (requiredKind != ValueOwnershipKind::Owned) {
661
- map.addCompatibilityConstraint (ValueOwnershipKind::Owned,
662
- UseLifetimeConstraint::MustBeLive);
663
- } else {
664
- map.addCompatibilityConstraint (ValueOwnershipKind::Owned,
665
- UseLifetimeConstraint::MustBeInvalidated);
666
- }
667
- map.addCompatibilityConstraint (ValueOwnershipKind::Guaranteed,
668
- UseLifetimeConstraint::MustBeLive);
669
- map.addCompatibilityConstraint (ValueOwnershipKind::Unowned,
670
- UseLifetimeConstraint::MustBeLive);
671
- return map;
672
- }
673
-
674
628
// We allow for trivial cases of enums with non-trivial cases to be passed in
675
629
// non-trivial argument positions. This fits with modeling of a
676
630
// SILFunctionArgument as a phi in a global program graph.
677
631
OperandOwnershipKindMap OperandOwnershipKindClassifier::visitApplyParameter (
678
632
ValueOwnershipKind kind, UseLifetimeConstraint requirement) {
679
633
680
- // Check if we have an enum. If not, then we just check against the passed in
681
- // convention.
682
- if (!getType ().getEnumOrBoundGenericEnum ()) {
683
- // We allow for owned to be passed to apply parameters.
684
- if (kind != ValueOwnershipKind::Owned) {
685
- return Map::compatibilityMap (
686
- {{kind, requirement},
687
- {ValueOwnershipKind::Owned, UseLifetimeConstraint::MustBeLive}});
688
- }
689
- return Map::compatibilityMap (kind, requirement);
634
+ // Check against the passed in convention. We allow for owned to be passed to
635
+ // apply parameters.
636
+ if (kind != ValueOwnershipKind::Owned) {
637
+ return Map::compatibilityMap (
638
+ {{kind, requirement},
639
+ {ValueOwnershipKind::Owned, UseLifetimeConstraint::MustBeLive}});
690
640
}
691
-
692
- // Otherwise consider that we may have a payload with a trivial case
693
- // that has other non-trivial cases.
694
- return visitEnumArgument (kind);
641
+ return Map::compatibilityMap (kind, requirement);
695
642
}
696
643
697
644
// Handle Apply and TryApply.
0 commit comments