Skip to content

Commit 4d7854f

Browse files
committed
Use AvailabilityContext to check for concurrency availability
1 parent 16a5d69 commit 4d7854f

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
@@ -1778,36 +1778,14 @@ const TypeLayoutEntry &IRGenModule::getTypeLayoutEntry(SILType T) {
17781778
return Types.getTypeLayoutEntry(T);
17791779
}
17801780

1781-
/// Return whether FrameLowering should always set the "extended frame
1782-
/// present" bit in FP, or set it based on a symbol in the runtime.
1783-
static bool isSwiftAsyncContextIsDynamicallySet(llvm::Triple TT) {
1784-
// Older OS versions (particularly system unwinders) are confused by the
1785-
// Swift extended frame, so when building code that might be run on them we
1786-
// must dynamically query the concurrency library to determine whether
1787-
// extended frames should be flagged as present.
1788-
unsigned Major, Minor, Micro;
1789-
TT.getOSVersion(Major, Minor, Micro);
1790-
switch(TT.getOS()) {
1791-
default:
1792-
return false;
1793-
case llvm::Triple::IOS:
1794-
case llvm::Triple::TvOS:
1795-
return Major < 15;
1796-
case llvm::Triple::WatchOS:
1797-
return Major < 8;
1798-
case llvm::Triple::MacOSX:
1799-
case llvm::Triple::Darwin:
1800-
return Major < 12;
1801-
}
1802-
}
18031781

18041782
void IRGenModule::emitSwiftAsyncExtendedFrameInfoWeakRef() {
18051783
if (!hasSwiftAsyncFunctionDef || extendedFramePointerFlagsWeakRef)
18061784
return;
18071785
if (IRGen.Opts.SwiftAsyncFramePointer !=
18081786
SwiftAsyncFramePointerKind::Auto)
18091787
return;
1810-
if (!isSwiftAsyncContextIsDynamicallySet(Triple))
1788+
if (isConcurrencyAvailable())
18111789
return;
18121790

18131791
// Emit a weak reference to the `swift_async_extendedFramePointerFlags` symbol
@@ -1819,3 +1797,10 @@ void IRGenModule::emitSwiftAsyncExtendedFrameInfoWeakRef() {
18191797
llvm::GlobalValue::ExternalWeakLinkage, nullptr,
18201798
symbolName);
18211799
}
1800+
1801+
bool IRGenModule::isConcurrencyAvailable() {
1802+
auto &ctx = getSwiftModule()->getASTContext();
1803+
auto deploymentAvailability =
1804+
AvailabilityContext::forDeploymentTarget(ctx);
1805+
return deploymentAvailability.isContainedIn(ctx.getConcurrencyAvailability());
1806+
}

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)