@@ -208,9 +208,9 @@ void *SILModule::allocateInst(unsigned Size, unsigned Align) const {
208208
209209void SILModule::willDeleteInstruction (SILInstruction *I) {
210210 // Update RootLocalArchetypeDefs.
211- I->forEachDefinedLocalArchetype ([&](CanLocalArchetypeType archeTy ,
212- SILValue dependency) {
213- LocalArchetypeKey key = {archeTy , I->getFunction ()};
211+ I->forEachDefinedLocalEnvironment ([&](GenericEnvironment *genericEnv ,
212+ SILValue dependency) {
213+ LocalArchetypeKey key = {genericEnv , I->getFunction ()};
214214 // In case `willDeleteInstruction` is called twice for the
215215 // same instruction, we need to check if the archetype is really
216216 // still in the map for this instruction.
@@ -674,20 +674,25 @@ void SILModule::registerDeserializationNotificationHandler(
674674 deserializationNotificationHandlers.add (std::move (handler));
675675}
676676
677- SILValue SILModule::getRootLocalArchetypeDef (CanLocalArchetypeType archetype,
678- SILFunction *inFunction) {
679- assert (archetype->isRoot ());
680-
681- SILValue &def = RootLocalArchetypeDefs[{archetype, inFunction}];
677+ SILValue SILModule::getLocalGenericEnvironmentDef (GenericEnvironment *genericEnv,
678+ SILFunction *inFunction) {
679+ SILValue &def = RootLocalArchetypeDefs[{genericEnv, inFunction}];
682680 if (!def) {
683681 numUnresolvedLocalArchetypes++;
684682 def = ::new PlaceholderValue (inFunction,
685- SILType::getPrimitiveAddressType (archetype));
683+ SILType::getPrimitiveAddressType (
684+ inFunction->getASTContext ().TheEmptyTupleType ));
686685 }
687686
688687 return def;
689688}
690689
690+ SILValue SILModule::getRootLocalArchetypeDef (CanLocalArchetypeType archetype,
691+ SILFunction *inFunction) {
692+ return getLocalGenericEnvironmentDef (archetype->getGenericEnvironment (),
693+ inFunction);
694+ }
695+
691696void SILModule::reclaimUnresolvedLocalArchetypeDefinitions () {
692697 llvm::DenseMap<LocalArchetypeKey, SILValue> newLocalArchetypeDefs;
693698
@@ -757,21 +762,21 @@ unsigned SILModule::getCaseIndex(EnumElementDecl *enumElement) {
757762}
758763
759764void SILModule::notifyAddedInstruction (SILInstruction *inst) {
760- inst->forEachDefinedLocalArchetype ([&](CanLocalArchetypeType archeTy ,
761- SILValue dependency) {
762- SILValue &val = RootLocalArchetypeDefs[{archeTy , inst->getFunction ()}];
765+ inst->forEachDefinedLocalEnvironment ([&](GenericEnvironment *genericEnv ,
766+ SILValue dependency) {
767+ SILValue &val = RootLocalArchetypeDefs[{genericEnv , inst->getFunction ()}];
763768 if (val) {
764769 if (!isa<PlaceholderValue>(val)) {
765770 // Print a useful error message (and not just abort with an assert).
766- llvm::errs () << " re-definition of root local archetype in function "
771+ llvm::errs () << " re-definition of local environment in function "
767772 << inst->getFunction ()->getName () << " :\n " ;
768773 inst->print (llvm::errs ());
769774 llvm::errs () << " previously defined in function "
770775 << val->getFunction ()->getName () << " :\n " ;
771776 val->print (llvm::errs ());
772777 abort ();
773778 }
774- // The local archetype was unresolved so far. Replace the placeholder
779+ // The local environment was unresolved so far. Replace the placeholder
775780 // by inst.
776781 auto *placeholder = cast<PlaceholderValue>(val);
777782 placeholder->replaceAllUsesWith (dependency);
@@ -792,13 +797,13 @@ void SILModule::notifyMovedInstruction(SILInstruction *inst,
792797 }
793798 }
794799
795- inst->forEachDefinedLocalArchetype ([&](CanLocalArchetypeType archeTy ,
796- SILValue dependency) {
797- LocalArchetypeKey key = {archeTy , fromFunction};
800+ inst->forEachDefinedLocalEnvironment ([&](GenericEnvironment *genericEnv ,
801+ SILValue dependency) {
802+ LocalArchetypeKey key = {genericEnv , fromFunction};
798803 assert (RootLocalArchetypeDefs.lookup (key) == dependency &&
799804 " archetype def was not registered" );
800805 RootLocalArchetypeDefs.erase (key);
801- RootLocalArchetypeDefs[{archeTy , inst->getFunction ()}] = dependency;
806+ RootLocalArchetypeDefs[{genericEnv , inst->getFunction ()}] = dependency;
802807 });
803808}
804809
0 commit comments