@@ -798,30 +798,9 @@ SILCombiner::buildConcreteOpenedExistentialInfoFromSoleConformingType(
798
798
// Prepare the code by adding UncheckedCast instructions that cast opened
799
799
// existentials to concrete types. Set the ConcreteValue of CEI.
800
800
if (auto *OER = dyn_cast<OpenExistentialRefInst>(OAI.OpenedArchetypeValue )) {
801
- // If we have an owned open_existential_ref, we only optimize for now if our
802
- // open_existential_ref has a single non-debug consuming use that is a
803
- // destroy_value.
804
- if (OER->getForwardingOwnershipKind () != OwnershipKind::Owned) {
805
- // We use OER as the insertion point so that
806
- SILBuilderWithScope b (std::next (OER->getIterator ()), Builder);
807
- auto loc = RegularLocation::getAutoGeneratedLocation ();
808
- SoleCEI.ConcreteValue =
809
- b.createUncheckedRefCast (loc, OER, concreteSILType);
810
- return COAI;
811
- }
812
-
813
- auto *consumingUse = OER->getSingleConsumingUse ();
814
- if (!consumingUse || !isa<DestroyValueInst>(consumingUse->getUser ())) {
815
- return std::nullopt;
816
- }
817
-
818
- // We use std::next(OER) as the insertion point so that we can reuse the
819
- // destroy_value of consumingUse.
820
801
SILBuilderWithScope b (std::next (OER->getIterator ()), Builder);
821
802
auto loc = RegularLocation::getAutoGeneratedLocation ();
822
- auto *uri = b.createUncheckedRefCast (loc, OER, concreteSILType);
823
- SoleCEI.ConcreteValue = uri;
824
- replaceInstUsesWith (*OER, uri);
803
+ SoleCEI.ConcreteValue = b.createUncheckedRefCast (loc, OER, concreteSILType);
825
804
return COAI;
826
805
}
827
806
0 commit comments