@@ -518,10 +518,6 @@ RuntimeEffect swift::getRuntimeEffect(SILInstruction *inst, SILType &impactType)
518518 case SILInstructionKind::UncheckedTakeEnumDataAddrInst:
519519 case SILInstructionKind::SelectEnumInst:
520520 case SILInstructionKind::SelectEnumAddrInst:
521- case SILInstructionKind::OpenExistentialMetatypeInst:
522- case SILInstructionKind::OpenExistentialBoxInst:
523- case SILInstructionKind::OpenExistentialValueInst:
524- case SILInstructionKind::OpenExistentialBoxValueInst:
525521 case SILInstructionKind::ProjectBlockStorageInst:
526522 case SILInstructionKind::UnreachableInst:
527523 case SILInstructionKind::ReturnInst:
@@ -569,6 +565,12 @@ RuntimeEffect swift::getRuntimeEffect(SILInstruction *inst, SILType &impactType)
569565 case SILInstructionKind::PackLengthInst:
570566 case SILInstructionKind::DebugStepInst:
571567 return RuntimeEffect::NoEffect;
568+
569+ case SILInstructionKind::OpenExistentialMetatypeInst:
570+ case SILInstructionKind::OpenExistentialBoxInst:
571+ case SILInstructionKind::OpenExistentialValueInst:
572+ case SILInstructionKind::OpenExistentialBoxValueInst:
573+ return RuntimeEffect::Existential;
572574
573575 case SILInstructionKind::DebugValueInst:
574576 // Ignore runtime calls of debug_value
@@ -636,10 +638,12 @@ RuntimeEffect swift::getRuntimeEffect(SILInstruction *inst, SILType &impactType)
636638 case SILInstructionKind::InitExistentialValueInst:
637639 impactType = inst->getOperand (0 )->getType ();
638640 return RuntimeEffect::Allocating | RuntimeEffect::Releasing |
639- RuntimeEffect::MetaData;
641+ RuntimeEffect::MetaData | RuntimeEffect::Existential ;
640642
641643 case SILInstructionKind::InitExistentialRefInst:
642644 case SILInstructionKind::InitExistentialMetatypeInst:
645+ impactType = inst->getOperand (0 )->getType ();
646+ return RuntimeEffect::MetaData | RuntimeEffect::Existential;
643647 case SILInstructionKind::ObjCToThickMetatypeInst:
644648 impactType = inst->getOperand (0 )->getType ();
645649 return RuntimeEffect::MetaData;
@@ -655,18 +659,18 @@ RuntimeEffect swift::getRuntimeEffect(SILInstruction *inst, SILType &impactType)
655659 case SILInstructionKind::OpenExistentialAddrInst:
656660 if (cast<OpenExistentialAddrInst>(inst)->getAccessKind () ==
657661 OpenedExistentialAccess::Mutable)
658- return RuntimeEffect::Allocating;
659- return RuntimeEffect::NoEffect ;
662+ return RuntimeEffect::Allocating | RuntimeEffect::Existential ;
663+ return RuntimeEffect::Existential ;
660664
661665 case SILInstructionKind::OpenExistentialRefInst: {
662666 SILType opType = cast<OpenExistentialRefInst>(inst)->getOperand ()->getType ();
663667 impactType = opType;
664668 if (opType.getASTType ()->isObjCExistentialType ()) {
665- return RuntimeEffect::MetaData;
669+ return RuntimeEffect::MetaData | RuntimeEffect::Existential ;
666670 }
667- return RuntimeEffect::MetaData;
668- // TODO: should be NoEffect
669- // return RuntimeEffect::NoEffect ;
671+ return RuntimeEffect::MetaData | RuntimeEffect::Existential ;
672+ // TODO: should be Existential
673+ // return RuntimeEffect::Existential ;
670674 }
671675
672676 case SILInstructionKind::UnconditionalCheckedCastInst:
@@ -712,8 +716,11 @@ RuntimeEffect swift::getRuntimeEffect(SILInstruction *inst, SILType &impactType)
712716 }
713717 return RuntimeEffect::Allocating;
714718 }
715- case SILInstructionKind::AllocBoxInst:
716719 case SILInstructionKind::AllocExistentialBoxInst:
720+ impactType = cast<SingleValueInstruction>(inst)->getType ();
721+ return RuntimeEffect::Allocating | RuntimeEffect::MetaData |
722+ RuntimeEffect::Releasing | RuntimeEffect::Existential;
723+ case SILInstructionKind::AllocBoxInst:
717724 case SILInstructionKind::AllocRefInst:
718725 case SILInstructionKind::AllocRefDynamicInst:
719726 impactType = cast<SingleValueInstruction>(inst)->getType ();
@@ -890,7 +897,7 @@ RuntimeEffect swift::getRuntimeEffect(SILInstruction *inst, SILType &impactType)
890897 rt |= RuntimeEffect::ObjectiveC | RuntimeEffect::MetaData;
891898 break ;
892899 case SILFunctionTypeRepresentation::WitnessMethod:
893- rt |= RuntimeEffect::MetaData;
900+ rt |= RuntimeEffect::MetaData | RuntimeEffect::Existential ;
894901 break ;
895902 case SILFunctionTypeRepresentation::CFunctionPointer:
896903 case SILFunctionTypeRepresentation::CXXMethod:
0 commit comments