@@ -452,13 +452,14 @@ void BridgedPassContext::moveFunctionBody(BridgedFunction sourceFunc, BridgedFun
452
452
}
453
453
454
454
BridgedFunction BridgedPassContext::
455
- ClosureSpecializer_createEmptyFunctionWithSpecializedSignature (BridgedStringRef specializedName,
456
- const BridgedParameterInfo * _Nullable specializedBridgedParams,
457
- SwiftInt paramCount,
458
- BridgedFunction bridgedApplySiteCallee,
459
- bool isSerialized) const {
460
- auto *applySiteCallee = bridgedApplySiteCallee.getFunction ();
461
- auto applySiteCalleeType = applySiteCallee->getLoweredFunctionType ();
455
+ createSpecializedFunctionDeclaration (BridgedStringRef specializedName,
456
+ const BridgedParameterInfo * _Nullable specializedBridgedParams,
457
+ SwiftInt paramCount,
458
+ BridgedFunction bridgedOriginal,
459
+ bool makeThin,
460
+ bool makeBare) const {
461
+ auto *original = bridgedOriginal.getFunction ();
462
+ auto originalType = original->getLoweredFunctionType ();
462
463
463
464
llvm::SmallVector<SILParameterInfo> specializedParams;
464
465
for (unsigned idx = 0 ; idx < paramCount; ++idx) {
@@ -468,18 +469,19 @@ ClosureSpecializer_createEmptyFunctionWithSpecializedSignature(BridgedStringRef
468
469
// The specialized function is always a thin function. This is important
469
470
// because we may add additional parameters after the Self parameter of
470
471
// witness methods. In this case the new function is not a method anymore.
471
- auto extInfo = applySiteCalleeType->getExtInfo ();
472
- extInfo = extInfo.withRepresentation (SILFunctionTypeRepresentation::Thin);
472
+ auto extInfo = originalType->getExtInfo ();
473
+ if (makeThin)
474
+ extInfo = extInfo.withRepresentation (SILFunctionTypeRepresentation::Thin);
473
475
474
476
auto ClonedTy = SILFunctionType::get (
475
- applySiteCalleeType ->getInvocationGenericSignature (), extInfo,
476
- applySiteCalleeType ->getCoroutineKind (),
477
- applySiteCalleeType ->getCalleeConvention (), specializedParams,
478
- applySiteCalleeType ->getYields (), applySiteCalleeType ->getResults (),
479
- applySiteCalleeType ->getOptionalErrorResult (),
480
- applySiteCalleeType ->getPatternSubstitutions (),
481
- applySiteCalleeType ->getInvocationSubstitutions (),
482
- applySiteCallee ->getModule ().getASTContext ());
477
+ originalType ->getInvocationGenericSignature (), extInfo,
478
+ originalType ->getCoroutineKind (),
479
+ originalType ->getCalleeConvention (), specializedParams,
480
+ originalType ->getYields (), originalType ->getResults (),
481
+ originalType ->getOptionalErrorResult (),
482
+ originalType ->getPatternSubstitutions (),
483
+ originalType ->getInvocationSubstitutions (),
484
+ original ->getModule ().getASTContext ());
483
485
484
486
SILOptFunctionBuilder functionBuilder (*invocation->getTransform ());
485
487
@@ -493,23 +495,23 @@ ClosureSpecializer_createEmptyFunctionWithSpecializedSignature(BridgedStringRef
493
495
// It's also important to disconnect this specialized function from any
494
496
// classes (the classSubclassScope), because that may incorrectly
495
497
// influence the linkage.
496
- getSpecializedLinkage (applySiteCallee, applySiteCallee ->getLinkage ()), specializedName.unbridged (),
497
- ClonedTy, applySiteCallee ->getGenericEnvironment (),
498
- applySiteCallee ->getLocation (), IsBare, applySiteCallee ->isTransparent (),
499
- isSerialized ? IsSerialized : IsNotSerialized , IsNotDynamic, IsNotDistributed,
500
- IsNotRuntimeAccessible, applySiteCallee ->getEntryCount (),
501
- applySiteCallee ->isThunk (),
498
+ getSpecializedLinkage (original, original ->getLinkage ()), specializedName.unbridged (),
499
+ ClonedTy, original ->getGenericEnvironment (),
500
+ original ->getLocation (), makeBare ? IsBare : original-> isBare (), original ->isTransparent (),
501
+ original-> getSerializedKind () , IsNotDynamic, IsNotDistributed,
502
+ IsNotRuntimeAccessible, original ->getEntryCount (),
503
+ original ->isThunk (),
502
504
/* classSubclassScope=*/ SubclassScope::NotApplicable,
503
- applySiteCallee ->getInlineStrategy (), applySiteCallee ->getEffectsKind (),
504
- applySiteCallee, applySiteCallee ->getDebugScope ());
505
+ original ->getInlineStrategy (), original ->getEffectsKind (),
506
+ original, original ->getDebugScope ());
505
507
506
- if (!applySiteCallee ->hasOwnership ()) {
508
+ if (!original ->hasOwnership ()) {
507
509
specializedApplySiteCallee->setOwnershipEliminated ();
508
510
}
509
511
510
- for (auto &Attr : applySiteCallee ->getSemanticsAttrs ())
512
+ for (auto &Attr : original ->getSemanticsAttrs ())
511
513
specializedApplySiteCallee->addSemanticsAttr (Attr);
512
-
514
+
513
515
return {specializedApplySiteCallee};
514
516
}
515
517
0 commit comments