Skip to content

Commit 35488ed

Browse files
committed
SIL: Use getDefinedOpenedArchetype() to simplify SILCloner
1 parent 3f317a1 commit 35488ed

File tree

1 file changed

+6
-13
lines changed

1 file changed

+6
-13
lines changed

include/swift/SIL/SILCloner.h

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2675,7 +2675,7 @@ template<typename ImplClass>
26752675
void
26762676
SILCloner<ImplClass>::visitOpenExistentialAddrInst(OpenExistentialAddrInst *Inst) {
26772677
// Create a new archetype for this opened existential type.
2678-
remapRootOpenedType(Inst->getType().castTo<OpenedArchetypeType>());
2678+
remapRootOpenedType(Inst->getDefinedOpenedArchetype());
26792679

26802680
getBuilder().setCurrentDebugScope(getOpScope(Inst->getDebugScope()));
26812681
recordClonedInstruction(
@@ -2688,7 +2688,7 @@ template <typename ImplClass>
26882688
void SILCloner<ImplClass>::visitOpenExistentialValueInst(
26892689
OpenExistentialValueInst *Inst) {
26902690
// Create a new archetype for this opened existential type.
2691-
remapRootOpenedType(Inst->getType().castTo<OpenedArchetypeType>());
2691+
remapRootOpenedType(Inst->getDefinedOpenedArchetype());
26922692

26932693
getBuilder().setCurrentDebugScope(getOpScope(Inst->getDebugScope()));
26942694
recordClonedInstruction(
@@ -2704,14 +2704,7 @@ template<typename ImplClass>
27042704
void
27052705
SILCloner<ImplClass>::
27062706
visitOpenExistentialMetatypeInst(OpenExistentialMetatypeInst *Inst) {
2707-
// Create a new archetype for this opened existential type.
2708-
auto openedType = Inst->getType().getASTType();
2709-
auto exType = Inst->getOperand()->getType().getASTType();
2710-
while (auto exMetatype = dyn_cast<ExistentialMetatypeType>(exType)) {
2711-
exType = exMetatype->getExistentialInstanceType()->getCanonicalType();
2712-
openedType = cast<MetatypeType>(openedType).getInstanceType();
2713-
}
2714-
remapRootOpenedType(cast<OpenedArchetypeType>(openedType));
2707+
remapRootOpenedType(Inst->getDefinedOpenedArchetype());
27152708

27162709
if (!Inst->getOperand()->getType().canUseExistentialRepresentation(
27172710
ExistentialRepresentation::Class)) {
@@ -2735,7 +2728,7 @@ void
27352728
SILCloner<ImplClass>::
27362729
visitOpenExistentialRefInst(OpenExistentialRefInst *Inst) {
27372730
// Create a new archetype for this opened existential type.
2738-
remapRootOpenedType(Inst->getType().castTo<OpenedArchetypeType>());
2731+
remapRootOpenedType(Inst->getDefinedOpenedArchetype());
27392732

27402733
getBuilder().setCurrentDebugScope(getOpScope(Inst->getDebugScope()));
27412734
recordClonedInstruction(
@@ -2752,7 +2745,7 @@ void
27522745
SILCloner<ImplClass>::
27532746
visitOpenExistentialBoxInst(OpenExistentialBoxInst *Inst) {
27542747
// Create a new archetype for this opened existential type.
2755-
remapRootOpenedType(Inst->getType().castTo<OpenedArchetypeType>());
2748+
remapRootOpenedType(Inst->getDefinedOpenedArchetype());
27562749

27572750
getBuilder().setCurrentDebugScope(getOpScope(Inst->getDebugScope()));
27582751
recordClonedInstruction(Inst, getBuilder().createOpenExistentialBox(
@@ -2766,7 +2759,7 @@ void
27662759
SILCloner<ImplClass>::
27672760
visitOpenExistentialBoxValueInst(OpenExistentialBoxValueInst *Inst) {
27682761
// Create a new archetype for this opened existential type.
2769-
remapRootOpenedType(Inst->getType().castTo<OpenedArchetypeType>());
2762+
remapRootOpenedType(Inst->getDefinedOpenedArchetype());
27702763

27712764
getBuilder().setCurrentDebugScope(getOpScope(Inst->getDebugScope()));
27722765
recordClonedInstruction(

0 commit comments

Comments
 (0)