@@ -298,6 +298,11 @@ SILFunction *SILPerformanceInliner::getEligibleFunction(FullApplySite AI) {
298
298
return nullptr ;
299
299
}
300
300
301
+ if (!EnableSILInliningOfGenerics && AI.hasSubstitutions ()) {
302
+ // Inlining of generics is not allowed.
303
+ return nullptr ;
304
+ }
305
+
301
306
// IRGen cannot handle partial_applies containing opened_extistentials
302
307
// in its substitutions list.
303
308
if (calleeHasPartialApplyWithOpenedExistentials (AI)) {
@@ -322,6 +327,8 @@ bool SILPerformanceInliner::isProfitableToInline(FullApplySite AI,
322
327
SILFunction *Callee = AI.getReferencedFunction ();
323
328
bool IsGeneric = !AI.getSubstitutions ().empty ();
324
329
330
+ assert (EnableSILInliningOfGenerics || !IsGeneric);
331
+
325
332
// Bail out if this generic call can be optimized by means of
326
333
// the generic specialization, because we prefer generic specialization
327
334
// to inlining of generics.
@@ -381,8 +388,8 @@ bool SILPerformanceInliner::isProfitableToInline(FullApplySite AI,
381
388
382
389
auto Subs = FAI.getSubstitutions ();
383
390
384
- // Bail if it is not a generic call.
385
- if (Subs.empty ())
391
+ // Bail if it is not a generic call or inlining of generics is forbidden .
392
+ if (!EnableSILInliningOfGenerics || Subs.empty ())
386
393
continue ;
387
394
388
395
if (!isa<FunctionRefInst>(def) && !isa<ClassMethodInst>(def) &&
@@ -539,6 +546,9 @@ static Optional<bool> shouldInlineGeneric(FullApplySite AI) {
539
546
assert (!AI.getSubstitutions ().empty () &&
540
547
" Expected a generic apply" );
541
548
549
+ if (!EnableSILInliningOfGenerics)
550
+ return false ;
551
+
542
552
// If all substitutions are concrete, then there is no need to perform the
543
553
// generic inlining. Let the generic specializer create a specialized
544
554
// function and then decide if it is beneficial to inline it.
@@ -560,9 +570,6 @@ static Optional<bool> shouldInlineGeneric(FullApplySite AI) {
560
570
if (Callee->getInlineStrategy () == AlwaysInline || Callee->isTransparent ())
561
571
return true ;
562
572
563
- if (!EnableSILInliningOfGenerics)
564
- return false ;
565
-
566
573
// It is not clear yet if this function should be decided or not.
567
574
return None;
568
575
}
0 commit comments