@@ -1011,7 +1011,6 @@ static bool hasDependentTypeWitness(
10111011static bool isDependentConformance (
10121012 IRGenModule &IGM,
10131013 const RootProtocolConformance *rootConformance,
1014- bool considerResilience,
10151014 llvm::SmallPtrSet<const NormalProtocolConformance *, 4 > &visited){
10161015 // Self-conformances are never dependent.
10171016 auto conformance = dyn_cast<NormalProtocolConformance>(rootConformance);
@@ -1024,7 +1023,7 @@ static bool isDependentConformance(
10241023 return false ;
10251024
10261025 // If the conformance is resilient, this is always true.
1027- if (considerResilience && IGM.isResilientConformance (conformance))
1026+ if (IGM.isResilientConformance (conformance))
10281027 return true ;
10291028
10301029 // Check whether any of the conformances are dependent.
@@ -1043,7 +1042,6 @@ static bool isDependentConformance(
10431042 isDependentConformance (IGM,
10441043 assocConformance.getConcrete ()
10451044 ->getRootConformance (),
1046- considerResilience,
10471045 visited))
10481046 return true ;
10491047 }
@@ -1060,11 +1058,9 @@ static bool isDependentConformance(
10601058// / Is there anything about the given conformance that requires witness
10611059// / tables to be dependently-generated?
10621060bool IRGenModule::isDependentConformance (
1063- const RootProtocolConformance *conformance,
1064- bool considerResilience) {
1061+ const RootProtocolConformance *conformance) {
10651062 llvm::SmallPtrSet<const NormalProtocolConformance *, 4 > visited;
1066- return ::isDependentConformance (*this , conformance, considerResilience,
1067- visited);
1063+ return ::isDependentConformance (*this , conformance, visited);
10681064}
10691065
10701066static bool isSynthesizedNonUnique (const RootProtocolConformance *conformance) {
@@ -2194,13 +2190,12 @@ IRGenModule::getConformanceInfo(const ProtocolDecl *protocol,
21942190
21952191 const ConformanceInfo *info;
21962192 // 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+ //
21992194 // FIXME: Both implementations of ConformanceInfo are trivially-destructible,
22002195 // so in theory we could allocate them on a BumpPtrAllocator. But there's not
22012196 // a good one for us to use. (The ASTContext's outlives the IRGenModule in
22022197 // batch mode.)
2203- if (isDependentConformance (rootConformance, /* considerResilience= */ true ) ||
2198+ if (isDependentConformance (rootConformance) ||
22042199 // Foreign types need to go through the accessor to unique the witness
22052200 // table.
22062201 isSynthesizedNonUnique (rootConformance)) {
@@ -2272,13 +2267,13 @@ void IRGenModule::emitSILWitnessTable(SILWitnessTable *wt) {
22722267 // Produce the initializer value.
22732268 auto initializer = wtableContents.finishAndCreateFuture ();
22742269
2270+ bool isDependent = isDependentConformance (conf);
2271+
22752272 llvm::GlobalVariable *global = nullptr ;
22762273 unsigned tableSize;
22772274 if (!isResilientConformance (conf)) {
2278- bool isDependent =
2279- isDependentConformance (conf, /* considerResilience=*/ false );
22802275 global = cast<llvm::GlobalVariable>(
2281- isDependent
2276+ ( isDependent && conf-> getDeclContext ()-> isGenericContext ())
22822277 ? getAddrOfWitnessTablePattern (cast<NormalProtocolConformance>(conf),
22832278 initializer)
22842279 : getAddrOfWitnessTable (conf, initializer));
@@ -2294,9 +2289,7 @@ void IRGenModule::emitSILWitnessTable(SILWitnessTable *wt) {
22942289 // descriptor.
22952290 ConformanceDescription description (conf, wt, global, tableSize,
22962291 wtableBuilder.getTablePrivateSize (),
2297- isDependentConformance (
2298- conf,
2299- /* considerResilience=*/ true ));
2292+ isDependent);
23002293
23012294 // Build the instantiation function, we if need one.
23022295 description.instantiationFn = wtableBuilder.buildInstantiationFunction ();
0 commit comments