@@ -280,31 +280,6 @@ static void convertOwnershipConventionsGivenParamInfos(
280280 });
281281}
282282
283- static bool shouldApplyBackDeploymentThunk (ValueDecl *decl, ASTContext &ctx,
284- ResilienceExpansion expansion) {
285- auto backDeployBeforeVersion = decl->getBackDeployedBeforeOSVersion (ctx);
286- if (!backDeployBeforeVersion)
287- return false ;
288-
289- // If the context of the application is inlinable then we must always call the
290- // back deployment thunk since we can't predict the deployment targets of
291- // other modules.
292- if (expansion != ResilienceExpansion::Maximal)
293- return true ;
294-
295- // In resilient function bodies skip calling the back deployment thunk when
296- // the deployment target is high enough that the ABI implementation of the
297- // back deployed function is guaranteed to be available.
298- auto deploymentAvailability = AvailabilityContext::forDeploymentTarget (ctx);
299- auto declAvailability =
300- AvailabilityContext (VersionRange::allGTE (*backDeployBeforeVersion));
301-
302- if (deploymentAvailability.isContainedIn (declAvailability))
303- return false ;
304-
305- return true ;
306- }
307-
308283// ===----------------------------------------------------------------------===//
309284// Callee
310285// ===----------------------------------------------------------------------===//
@@ -1155,7 +1130,6 @@ class SILGenApply : public Lowering::ExprVisitor<SILGenApply> {
11551130
11561131 SILDeclRef getDeclRefForStaticDispatchApply (DeclRefExpr *e) {
11571132 auto *afd = cast<AbstractFunctionDecl>(e->getDecl ());
1158- auto &ctx = SGF.getASTContext ();
11591133
11601134 // A call to a `distributed` function may need to go through a thunk.
11611135 if (callSite && callSite->shouldApplyDistributedThunk ()) {
@@ -1164,8 +1138,9 @@ class SILGenApply : public Lowering::ExprVisitor<SILGenApply> {
11641138 }
11651139
11661140 // A call to `@backDeployed` function may need to go through a thunk.
1167- if (shouldApplyBackDeploymentThunk (afd, ctx,
1168- SGF.F .getResilienceExpansion ())) {
1141+
1142+ if (SGF.SGM .requiresBackDeploymentThunk (afd,
1143+ SGF.F .getResilienceExpansion ())) {
11691144 return SILDeclRef (afd).asBackDeploymentKind (
11701145 SILDeclRef::BackDeploymentKind::Thunk);
11711146 }
@@ -6711,7 +6686,7 @@ SILDeclRef SILGenModule::getAccessorDeclRef(AccessorDecl *accessor,
67116686 ResilienceExpansion expansion) {
67126687 auto declRef = SILDeclRef (accessor, SILDeclRef::Kind::Func);
67136688
6714- if (shouldApplyBackDeploymentThunk (accessor, getASTContext () , expansion))
6689+ if (requiresBackDeploymentThunk (accessor, expansion))
67156690 return declRef.asBackDeploymentKind (SILDeclRef::BackDeploymentKind::Thunk);
67166691
67176692 return declRef.asForeign (requiresForeignEntryPoint (accessor));
0 commit comments