Skip to content

Commit dc77e65

Browse files
committed
Remove complex bailouts and fix replacing open_existential_ref
This code was previously creating illegal unchecked_ref_cast with same source and destination.
1 parent 0b6ab9a commit dc77e65

File tree

1 file changed

+1
-22
lines changed

1 file changed

+1
-22
lines changed

lib/SILOptimizer/SILCombiner/SILCombinerApplyVisitors.cpp

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -798,30 +798,9 @@ SILCombiner::buildConcreteOpenedExistentialInfoFromSoleConformingType(
798798
// Prepare the code by adding UncheckedCast instructions that cast opened
799799
// existentials to concrete types. Set the ConcreteValue of CEI.
800800
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.
820801
SILBuilderWithScope b(std::next(OER->getIterator()), Builder);
821802
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);
825804
return COAI;
826805
}
827806

0 commit comments

Comments
 (0)