Back-deploy creation of global-actor-qualified function type metadata.

When back-deploying, create global-actor-qualified function types via a
separate entrypoint
(`swift_getFunctionTypeMetadataGlobalActorBackDeploy`) in the
compatibility library, which checks whether it is running with a
new-enough runtime to use `swift_getFunctionTypeMetadataGlobalActor`.
Failing that, it calls into a separate copy of the implementation that
exists only in the back-deployed concurrency library.

Fixes rdar://79153988.
This commit is contained in:
Doug Gregor
2021-09-12 21:53:44 -07:00
parent 8cd8ca01ad
commit 5b027ca456
7 changed files with 376 additions and 3 deletions

View File

@@ -1230,6 +1230,13 @@ static MetadataResponse emitTupleTypeMetadataRef(IRGenFunction &IGF,
}
}
/// Determine whether concurrency support is available in the runtime.
static bool isConcurrencyAvailable(ASTContext &ctx) {
auto deploymentAvailability =
AvailabilityContext::forDeploymentTarget(ctx);
return deploymentAvailability.isContainedIn(ctx.getConcurrencyAvailability());
}
namespace {
/// A visitor class for emitting a reference to a metatype object.
/// This implements a "raw" access, useful for implementing cache
@@ -1591,7 +1598,9 @@ namespace {
}
auto *getMetadataFn = type->getGlobalActor()
? IGF.IGM.getGetFunctionMetadataGlobalActorFn()
? (isConcurrencyAvailable(IGF.getSwiftModule()->getASTContext())
? IGF.IGM.getGetFunctionMetadataGlobalActorFn()
: IGF.IGM.getGetFunctionMetadataGlobalActorBackDeployFn())
: type->isDifferentiable()
? IGF.IGM.getGetFunctionMetadataDifferentiableFn()
: IGF.IGM.getGetFunctionMetadataFn();