@@ -452,13 +452,14 @@ void BridgedPassContext::moveFunctionBody(BridgedFunction sourceFunc, BridgedFun
452452}
453453
454454BridgedFunction 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 ();
462463
463464 llvm::SmallVector<SILParameterInfo> specializedParams;
464465 for (unsigned idx = 0 ; idx < paramCount; ++idx) {
@@ -468,18 +469,19 @@ ClosureSpecializer_createEmptyFunctionWithSpecializedSignature(BridgedStringRef
468469 // The specialized function is always a thin function. This is important
469470 // because we may add additional parameters after the Self parameter of
470471 // 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);
473475
474476 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 ());
483485
484486 SILOptFunctionBuilder functionBuilder (*invocation->getTransform ());
485487
@@ -493,23 +495,23 @@ ClosureSpecializer_createEmptyFunctionWithSpecializedSignature(BridgedStringRef
493495 // It's also important to disconnect this specialized function from any
494496 // classes (the classSubclassScope), because that may incorrectly
495497 // 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 (),
502504 /* classSubclassScope=*/ SubclassScope::NotApplicable,
503- applySiteCallee ->getInlineStrategy (), applySiteCallee ->getEffectsKind (),
504- applySiteCallee, applySiteCallee ->getDebugScope ());
505+ original ->getInlineStrategy (), original ->getEffectsKind (),
506+ original, original ->getDebugScope ());
505507
506- if (!applySiteCallee ->hasOwnership ()) {
508+ if (!original ->hasOwnership ()) {
507509 specializedApplySiteCallee->setOwnershipEliminated ();
508510 }
509511
510- for (auto &Attr : applySiteCallee ->getSemanticsAttrs ())
512+ for (auto &Attr : original ->getSemanticsAttrs ())
511513 specializedApplySiteCallee->addSemanticsAttr (Attr);
512-
514+
513515 return {specializedApplySiteCallee};
514516}
515517
0 commit comments