@@ -959,8 +959,13 @@ namespace {
959959
960960// / Return true if the witness table requires runtime instantiation to
961961// / handle resiliently-added requirements with default implementations.
962+ // /
963+ // / If disableOptimizations is true, skip optimizations that treat
964+ // / formally-resilient conformances as non-resilient.
962965bool IRGenModule::isResilientConformance (
963- const NormalProtocolConformance *conformance) {
966+ const NormalProtocolConformance *conformance,
967+ bool disableOptimizations
968+ ) {
964969 // If the protocol is not resilient, the conformance is not resilient
965970 // either.
966971 bool shouldTreatProtocolNonResilient =
@@ -992,16 +997,18 @@ bool IRGenModule::isResilientConformance(
992997 // This is an optimization -- a conformance of a non-generic type cannot
993998 // resiliently become dependent.
994999 if (!conformance->getDeclContext ()->isGenericContext () &&
995- conformanceModule == conformance->getProtocol ()->getParentModule ())
1000+ conformanceModule == conformance->getProtocol ()->getParentModule () &&
1001+ !disableOptimizations)
9961002 return false ;
9971003
9981004 // We have a resilient conformance.
9991005 return true ;
10001006}
10011007
1002- bool IRGenModule::isResilientConformance (const RootProtocolConformance *root) {
1008+ bool IRGenModule::isResilientConformance (const RootProtocolConformance *root,
1009+ bool disableOptimizations) {
10031010 if (auto normal = dyn_cast<NormalProtocolConformance>(root))
1004- return isResilientConformance (normal);
1011+ return isResilientConformance (normal, disableOptimizations );
10051012 // Self-conformances never require this.
10061013 return false ;
10071014}
@@ -1185,7 +1192,9 @@ bool IRGenModule::isDependentConformance(
11851192 const RootProtocolConformance *conformance) {
11861193 llvm::SmallPtrSet<const NormalProtocolConformance *, 4 > visited;
11871194 return ::isDependentConformance (
1188- *this , conformance, conformance->getProtocol ()->isResilient (), visited);
1195+ *this , conformance,
1196+ isResilientConformance (conformance, /* disableOptimizations=*/ true ),
1197+ visited);
11891198}
11901199
11911200static llvm::Value *
0 commit comments