@@ -1407,6 +1407,11 @@ deleteAndReenqueueForEmissionValuesDependentOnCanonicalPrespecializedMetadataRec
1407
1407
emitLazyTypeContextDescriptor (IGM, &decl, RequireMetadata);
1408
1408
}
1409
1409
1410
+ static bool loweredFunctionHasGenericArguments (SILFunction *f) {
1411
+ auto s = f->getLoweredFunctionType ()->getInvocationGenericSignature ();
1412
+ return s && !s->areAllParamsConcrete ();
1413
+ }
1414
+
1410
1415
// / Emit any lazy definitions (of globals or functions or whatever
1411
1416
// / else) that we require.
1412
1417
void IRGenerator::emitLazyDefinitions () {
@@ -1419,7 +1424,7 @@ void IRGenerator::emitLazyDefinitions() {
1419
1424
assert (LazyFieldDescriptors.empty ());
1420
1425
// LazyFunctionDefinitions are allowed, but they must not be generic
1421
1426
for (SILFunction *f : LazyFunctionDefinitions) {
1422
- assert (!f-> getLoweredFunctionType ()-> getSubstGenericSignature ( ));
1427
+ assert (!loweredFunctionHasGenericArguments (f ));
1423
1428
}
1424
1429
assert (LazyWitnessTables.empty ());
1425
1430
assert (LazyCanonicalSpecializedMetadataAccessors.empty ());
@@ -1499,8 +1504,13 @@ void IRGenerator::emitLazyDefinitions() {
1499
1504
while (!LazyFunctionDefinitions.empty ()) {
1500
1505
SILFunction *f = LazyFunctionDefinitions.pop_back_val ();
1501
1506
CurrentIGMPtr IGM = getGenModule (f);
1502
- assert (!f->isPossiblyUsedExternally ()
1503
- && " function with externally-visible linkage emitted lazily?" );
1507
+ // In embedded Swift, we can gain public / externally-visible functions
1508
+ // by deserializing them from imported modules, or by the CMO pass making
1509
+ // local functions public. TODO: We should internalize as a separate pass.
1510
+ if (!SIL.getASTContext ().LangOpts .hasFeature (Feature::Embedded)) {
1511
+ assert (!f->isPossiblyUsedExternally ()
1512
+ && " function with externally-visible linkage emitted lazily?" );
1513
+ }
1504
1514
IGM->emitSILFunction (f);
1505
1515
}
1506
1516
@@ -1541,9 +1551,10 @@ void IRGenerator::addLazyFunction(SILFunction *f) {
1541
1551
// Add it to the queue if it hasn't already been put there.
1542
1552
if (!LazilyEmittedFunctions.insert (f).second )
1543
1553
return ;
1544
-
1554
+
1555
+ // Embedded Swift doesn't expect any generic functions to be referenced.
1545
1556
if (SIL.getASTContext ().LangOpts .hasFeature (Feature::Embedded)) {
1546
- assert (!f-> getLoweredFunctionType ()-> getSubstGenericSignature ( ));
1557
+ assert (!loweredFunctionHasGenericArguments (f ));
1547
1558
}
1548
1559
1549
1560
assert (!FinishedEmittingLazyDefinitions);
0 commit comments