@@ -79,6 +79,8 @@ class CrossModuleOptimization {
79
79
80
80
bool canSerializeType (SILType type);
81
81
82
+ bool canUseFromInline (DeclContext *declCtxt);
83
+
82
84
bool canUseFromInline (SILFunction *func);
83
85
84
86
bool shouldSerialize (SILFunction *F);
@@ -184,8 +186,7 @@ bool CrossModuleOptimization::canSerializeFunction(
184
186
return iter->second ;
185
187
186
188
if (DeclContext *funcCtxt = function->getDeclContext ()) {
187
- ModuleDecl *module = function->getModule ().getSwiftModule ();
188
- if (!module ->canBeUsedForCrossModuleOptimization (funcCtxt))
189
+ if (!canUseFromInline (funcCtxt))
189
190
return false ;
190
191
}
191
192
@@ -335,7 +336,7 @@ bool CrossModuleOptimization::canSerializeType(SILType type) {
335
336
336
337
// Exclude types which are defined in an @_implementationOnly imported
337
338
// module. Such modules are not transitively available.
338
- if (!M. getSwiftModule ()-> canBeUsedForCrossModuleOptimization (subNT)) {
339
+ if (!canUseFromInline (subNT)) {
339
340
return true ;
340
341
}
341
342
}
@@ -364,10 +365,9 @@ static bool couldBeLinkedStatically(DeclContext *funcCtxt, SILModule &module) {
364
365
return true ;
365
366
}
366
367
367
- // / Returns true if the function \p func can be used from a serialized function.
368
- bool CrossModuleOptimization::canUseFromInline (SILFunction *function) {
369
- DeclContext *funcCtxt = function->getDeclContext ();
370
- if (funcCtxt && !M.getSwiftModule ()->canBeUsedForCrossModuleOptimization (funcCtxt))
368
+ // / Returns true if the \p declCtxt can be used from a serialized function.
369
+ bool CrossModuleOptimization::canUseFromInline (DeclContext *declCtxt) {
370
+ if (!M.getSwiftModule ()->canBeUsedForCrossModuleOptimization (declCtxt))
371
371
return false ;
372
372
373
373
// / If we are emitting a TBD file, the TBD file only contains public symbols
@@ -377,8 +377,18 @@ bool CrossModuleOptimization::canUseFromInline(SILFunction *function) {
377
377
// / (potentially) linked statically. Unfortunately there is no way to find out
378
378
// / if another module is linked statically or dynamically, so we have to be
379
379
// / conservative here.
380
- if (conservative && M.getOptions ().emitTBD && couldBeLinkedStatically (funcCtxt , M))
380
+ if (conservative && M.getOptions ().emitTBD && couldBeLinkedStatically (declCtxt , M))
381
381
return false ;
382
+
383
+ return true ;
384
+ }
385
+
386
+ // / Returns true if the function \p func can be used from a serialized function.
387
+ bool CrossModuleOptimization::canUseFromInline (SILFunction *function) {
388
+ if (DeclContext *funcCtxt = function->getDeclContext ()) {
389
+ if (!canUseFromInline (funcCtxt))
390
+ return false ;
391
+ }
382
392
383
393
switch (function->getLinkage ()) {
384
394
case SILLinkage::PublicNonABI:
0 commit comments