@@ -1011,7 +1011,6 @@ static bool hasDependentTypeWitness(
1011
1011
static bool isDependentConformance (
1012
1012
IRGenModule &IGM,
1013
1013
const RootProtocolConformance *rootConformance,
1014
- bool considerResilience,
1015
1014
llvm::SmallPtrSet<const NormalProtocolConformance *, 4 > &visited){
1016
1015
// Self-conformances are never dependent.
1017
1016
auto conformance = dyn_cast<NormalProtocolConformance>(rootConformance);
@@ -1024,7 +1023,7 @@ static bool isDependentConformance(
1024
1023
return false ;
1025
1024
1026
1025
// If the conformance is resilient, this is always true.
1027
- if (considerResilience && IGM.isResilientConformance (conformance))
1026
+ if (IGM.isResilientConformance (conformance))
1028
1027
return true ;
1029
1028
1030
1029
// Check whether any of the conformances are dependent.
@@ -1043,7 +1042,6 @@ static bool isDependentConformance(
1043
1042
isDependentConformance (IGM,
1044
1043
assocConformance.getConcrete ()
1045
1044
->getRootConformance (),
1046
- considerResilience,
1047
1045
visited))
1048
1046
return true ;
1049
1047
}
@@ -1060,11 +1058,9 @@ static bool isDependentConformance(
1060
1058
// / Is there anything about the given conformance that requires witness
1061
1059
// / tables to be dependently-generated?
1062
1060
bool IRGenModule::isDependentConformance (
1063
- const RootProtocolConformance *conformance,
1064
- bool considerResilience) {
1061
+ const RootProtocolConformance *conformance) {
1065
1062
llvm::SmallPtrSet<const NormalProtocolConformance *, 4 > visited;
1066
- return ::isDependentConformance (*this , conformance, considerResilience,
1067
- visited);
1063
+ return ::isDependentConformance (*this , conformance, visited);
1068
1064
}
1069
1065
1070
1066
static bool isSynthesizedNonUnique (const RootProtocolConformance *conformance) {
@@ -2194,13 +2190,12 @@ IRGenModule::getConformanceInfo(const ProtocolDecl *protocol,
2194
2190
2195
2191
const ConformanceInfo *info;
2196
2192
// If the conformance is dependent in any way, we need to unique it.
2197
- // TODO: maybe this should apply whenever it's out of the module?
2198
- // TODO: actually enable this
2193
+ //
2199
2194
// FIXME: Both implementations of ConformanceInfo are trivially-destructible,
2200
2195
// so in theory we could allocate them on a BumpPtrAllocator. But there's not
2201
2196
// a good one for us to use. (The ASTContext's outlives the IRGenModule in
2202
2197
// batch mode.)
2203
- if (isDependentConformance (rootConformance, /* considerResilience= */ true ) ||
2198
+ if (isDependentConformance (rootConformance) ||
2204
2199
// Foreign types need to go through the accessor to unique the witness
2205
2200
// table.
2206
2201
isSynthesizedNonUnique (rootConformance)) {
@@ -2272,13 +2267,13 @@ void IRGenModule::emitSILWitnessTable(SILWitnessTable *wt) {
2272
2267
// Produce the initializer value.
2273
2268
auto initializer = wtableContents.finishAndCreateFuture ();
2274
2269
2270
+ bool isDependent = isDependentConformance (conf);
2271
+
2275
2272
llvm::GlobalVariable *global = nullptr ;
2276
2273
unsigned tableSize;
2277
2274
if (!isResilientConformance (conf)) {
2278
- bool isDependent =
2279
- isDependentConformance (conf, /* considerResilience=*/ false );
2280
2275
global = cast<llvm::GlobalVariable>(
2281
- isDependent
2276
+ ( isDependent && conf-> getDeclContext ()-> isGenericContext ())
2282
2277
? getAddrOfWitnessTablePattern (cast<NormalProtocolConformance>(conf),
2283
2278
initializer)
2284
2279
: getAddrOfWitnessTable (conf, initializer));
@@ -2294,9 +2289,7 @@ void IRGenModule::emitSILWitnessTable(SILWitnessTable *wt) {
2294
2289
// descriptor.
2295
2290
ConformanceDescription description (conf, wt, global, tableSize,
2296
2291
wtableBuilder.getTablePrivateSize (),
2297
- isDependentConformance (
2298
- conf,
2299
- /* considerResilience=*/ true ));
2292
+ isDependent);
2300
2293
2301
2294
// Build the instantiation function, we if need one.
2302
2295
description.instantiationFn = wtableBuilder.buildInstantiationFunction ();
0 commit comments