@@ -959,8 +959,13 @@ namespace {
959
959
960
960
// / Return true if the witness table requires runtime instantiation to
961
961
// / handle resiliently-added requirements with default implementations.
962
+ // /
963
+ // / If disableOptimizations is true, skip optimizations that treat
964
+ // / formally-resilient conformances as non-resilient.
962
965
bool IRGenModule::isResilientConformance (
963
- const NormalProtocolConformance *conformance) {
966
+ const NormalProtocolConformance *conformance,
967
+ bool disableOptimizations
968
+ ) {
964
969
// If the protocol is not resilient, the conformance is not resilient
965
970
// either.
966
971
bool shouldTreatProtocolNonResilient =
@@ -992,16 +997,18 @@ bool IRGenModule::isResilientConformance(
992
997
// This is an optimization -- a conformance of a non-generic type cannot
993
998
// resiliently become dependent.
994
999
if (!conformance->getDeclContext ()->isGenericContext () &&
995
- conformanceModule == conformance->getProtocol ()->getParentModule ())
1000
+ conformanceModule == conformance->getProtocol ()->getParentModule () &&
1001
+ !disableOptimizations)
996
1002
return false ;
997
1003
998
1004
// We have a resilient conformance.
999
1005
return true ;
1000
1006
}
1001
1007
1002
- bool IRGenModule::isResilientConformance (const RootProtocolConformance *root) {
1008
+ bool IRGenModule::isResilientConformance (const RootProtocolConformance *root,
1009
+ bool disableOptimizations) {
1003
1010
if (auto normal = dyn_cast<NormalProtocolConformance>(root))
1004
- return isResilientConformance (normal);
1011
+ return isResilientConformance (normal, disableOptimizations );
1005
1012
// Self-conformances never require this.
1006
1013
return false ;
1007
1014
}
@@ -1185,7 +1192,9 @@ bool IRGenModule::isDependentConformance(
1185
1192
const RootProtocolConformance *conformance) {
1186
1193
llvm::SmallPtrSet<const NormalProtocolConformance *, 4 > visited;
1187
1194
return ::isDependentConformance (
1188
- *this , conformance, conformance->getProtocol ()->isResilient (), visited);
1195
+ *this , conformance,
1196
+ isResilientConformance (conformance, /* disableOptimizations=*/ true ),
1197
+ visited);
1189
1198
}
1190
1199
1191
1200
static llvm::Value *
0 commit comments