Skip to content

Commit 12b7758

Browse files
aschwaighoferDougGregor
authored andcommitted
Use AvailabilityContext to check for concurrency availability
(cherry picked from commit 4d7854f)
1 parent 24638e1 commit 12b7758

File tree

3 files changed

+10
-31
lines changed

3 files changed

+10
-31
lines changed

lib/IRGen/IRGenModule.cpp

Lines changed: 8 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1744,36 +1744,14 @@ const TypeLayoutEntry &IRGenModule::getTypeLayoutEntry(SILType T) {
17441744
return Types.getTypeLayoutEntry(T);
17451745
}
17461746

1747-
/// Return whether FrameLowering should always set the "extended frame
1748-
/// present" bit in FP, or set it based on a symbol in the runtime.
1749-
static bool isSwiftAsyncContextIsDynamicallySet(llvm::Triple TT) {
1750-
// Older OS versions (particularly system unwinders) are confused by the
1751-
// Swift extended frame, so when building code that might be run on them we
1752-
// must dynamically query the concurrency library to determine whether
1753-
// extended frames should be flagged as present.
1754-
unsigned Major, Minor, Micro;
1755-
TT.getOSVersion(Major, Minor, Micro);
1756-
switch(TT.getOS()) {
1757-
default:
1758-
return false;
1759-
case llvm::Triple::IOS:
1760-
case llvm::Triple::TvOS:
1761-
return Major < 15;
1762-
case llvm::Triple::WatchOS:
1763-
return Major < 8;
1764-
case llvm::Triple::MacOSX:
1765-
case llvm::Triple::Darwin:
1766-
return Major < 12;
1767-
}
1768-
}
17691747

17701748
void IRGenModule::emitSwiftAsyncExtendedFrameInfoWeakRef() {
17711749
if (!hasSwiftAsyncFunctionDef || extendedFramePointerFlagsWeakRef)
17721750
return;
17731751
if (IRGen.Opts.SwiftAsyncFramePointer !=
17741752
SwiftAsyncFramePointerKind::Auto)
17751753
return;
1776-
if (!isSwiftAsyncContextIsDynamicallySet(Triple))
1754+
if (isConcurrencyAvailable())
17771755
return;
17781756

17791757
// Emit a weak reference to the `swift_async_extendedFramePointerFlags` symbol
@@ -1785,3 +1763,10 @@ void IRGenModule::emitSwiftAsyncExtendedFrameInfoWeakRef() {
17851763
llvm::GlobalValue::ExternalWeakLinkage, nullptr,
17861764
symbolName);
17871765
}
1766+
1767+
bool IRGenModule::isConcurrencyAvailable() {
1768+
auto &ctx = getSwiftModule()->getASTContext();
1769+
auto deploymentAvailability =
1770+
AvailabilityContext::forDeploymentTarget(ctx);
1771+
return deploymentAvailability.isContainedIn(ctx.getConcurrencyAvailability());
1772+
}

lib/IRGen/IRGenModule.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1698,6 +1698,7 @@ private: \
16981698
/// symbol needed by Swift async functions.
16991699
void emitSwiftAsyncExtendedFrameInfoWeakRef();
17001700
public:
1701+
bool isConcurrencyAvailable();
17011702
void noteSwiftAsyncFunctionDef() {
17021703
hasSwiftAsyncFunctionDef = true;
17031704
}

lib/IRGen/MetadataRequest.cpp

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1230,13 +1230,6 @@ static MetadataResponse emitTupleTypeMetadataRef(IRGenFunction &IGF,
12301230
}
12311231
}
12321232

1233-
/// Determine whether concurrency support is available in the runtime.
1234-
static bool isConcurrencyAvailable(ASTContext &ctx) {
1235-
auto deploymentAvailability =
1236-
AvailabilityContext::forDeploymentTarget(ctx);
1237-
return deploymentAvailability.isContainedIn(ctx.getConcurrencyAvailability());
1238-
}
1239-
12401233
namespace {
12411234
/// A visitor class for emitting a reference to a metatype object.
12421235
/// This implements a "raw" access, useful for implementing cache
@@ -1598,7 +1591,7 @@ namespace {
15981591
}
15991592

16001593
auto *getMetadataFn = type->getGlobalActor()
1601-
? (isConcurrencyAvailable(IGF.getSwiftModule()->getASTContext())
1594+
? (IGF.IGM.isConcurrencyAvailable()
16021595
? IGF.IGM.getGetFunctionMetadataGlobalActorFn()
16031596
: IGF.IGM.getGetFunctionMetadataGlobalActorBackDeployFn())
16041597
: type->isDifferentiable()

0 commit comments

Comments
 (0)