Skip to content

Commit 5a4460e

Browse files
authored
Merge pull request #74702 from rjmccall/runtime-availability-update-6.0
[6.0] Implement getSwiftRuntimeCompatibilityVersionForTarget for recent releases
2 parents a2184be + 125d833 commit 5a4460e

18 files changed

+69
-36
lines changed

include/swift/AST/DiagnosticsSema.def

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5626,8 +5626,6 @@ ERROR(isolated_parameter_combined_nonisolated,none,
56265626
ERROR(isolated_parameter_isolated_attr_type,none,
56275627
"function with 'isolated' parameter cannot also be '@isolated(%0)'",
56285628
(StringRef))
5629-
ERROR(isolated_any_experimental,none,
5630-
"attribute requires '-enable-experimental-feature IsolatedAny'", ())
56315629
ERROR(isolated_attr_global_actor_type,none,
56325630
"function type cannot have both a global actor and '@isolated(%0)'",
56335631
(StringRef))

include/swift/Basic/Features.def

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,8 @@ LANGUAGE_FEATURE(BuiltinAddressOfRawLayout, 0, "Builtin.addressOfRawLayout")
200200
LANGUAGE_FEATURE(TransferringArgsAndResults, 430, "Transferring args and results")
201201
SUPPRESSIBLE_LANGUAGE_FEATURE(SendingArgsAndResults, 430, "Sending arg and results")
202202
LANGUAGE_FEATURE(BorrowingSwitch, 432, "Noncopyable type pattern matching")
203+
CONDITIONALLY_SUPPRESSIBLE_LANGUAGE_FEATURE(IsolatedAny, 431, "@isolated(any) function types")
204+
LANGUAGE_FEATURE(IsolatedAny2, 431, "@isolated(any) function types")
203205

204206
// Swift 6
205207
UPCOMING_FEATURE(ConciseMagicFile, 274, 6)
@@ -371,15 +373,9 @@ EXPERIMENTAL_FEATURE(GroupActorErrors, true)
371373
// Enable explicit isolation of closures.
372374
EXPERIMENTAL_FEATURE(ClosureIsolation, true)
373375

374-
// Enable isolated(any) attribute on function types.
375-
CONDITIONALLY_SUPPRESSIBLE_EXPERIMENTAL_FEATURE(IsolatedAny, true)
376-
377376
// Whether lookup of members respects the enclosing file's imports.
378377
EXPERIMENTAL_FEATURE_EXCLUDED_FROM_MODULE_INTERFACE(MemberImportVisibility, true)
379378

380-
// Alias for IsolatedAny
381-
EXPERIMENTAL_FEATURE(IsolatedAny2, true)
382-
383379
// Enable @implementation on extensions of ObjC classes.
384380
EXPERIMENTAL_FEATURE(ObjCImplementation, true)
385381

lib/Basic/Platform.cpp

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,13 @@ swift::getSwiftRuntimeCompatibilityVersionForTarget(
470470
return floorFor64(llvm::VersionTuple(5, 5));
471471
return floorFor64(llvm::VersionTuple(5, 6));
472472
} else if (Major == 13) {
473-
return floorFor64(llvm::VersionTuple(5, 7));
473+
if (Minor <= 2)
474+
return floorFor64(llvm::VersionTuple(5, 7));
475+
return floorFor64(llvm::VersionTuple(5, 8));
476+
} else if (Major == 14) {
477+
if (Minor <= 3)
478+
return floorFor64(llvm::VersionTuple(5, 9));
479+
return floorFor64(llvm::VersionTuple(5, 10));
474480
}
475481
} else if (Triple.isiOS()) { // includes tvOS
476482
llvm::VersionTuple OSVersion = Triple.getiOSVersion();
@@ -510,7 +516,13 @@ swift::getSwiftRuntimeCompatibilityVersionForTarget(
510516
return floorForArchitecture(llvm::VersionTuple(5, 5));
511517
return floorForArchitecture(llvm::VersionTuple(5, 6));
512518
} else if (Major <= 16) {
513-
return floorForArchitecture(llvm::VersionTuple(5, 7));
519+
if (Minor <= 3)
520+
return floorForArchitecture(llvm::VersionTuple(5, 7));
521+
return floorForArchitecture(llvm::VersionTuple(5, 8));
522+
} else if (Major <= 17) {
523+
if (Minor <= 3)
524+
return floorForArchitecture(llvm::VersionTuple(5, 9));
525+
return floorForArchitecture(llvm::VersionTuple(5, 10));
514526
}
515527
} else if (Triple.isWatchOS()) {
516528
llvm::VersionTuple OSVersion = Triple.getWatchOSVersion();
@@ -541,11 +553,25 @@ swift::getSwiftRuntimeCompatibilityVersionForTarget(
541553
return floorFor64bits(llvm::VersionTuple(5, 5));
542554
return floorFor64bits(llvm::VersionTuple(5, 6));
543555
} else if (Major <= 9) {
544-
return floorFor64bits(llvm::VersionTuple(5, 7));
556+
if (Minor <= 3)
557+
return floorFor64bits(llvm::VersionTuple(5, 7));
558+
return floorFor64bits(llvm::VersionTuple(5, 8));
559+
} else if (Major <= 10) {
560+
if (Minor <= 3)
561+
return floorFor64bits(llvm::VersionTuple(5, 9));
562+
return floorFor64bits(llvm::VersionTuple(5, 10));
545563
}
546564
}
547565
else if (Triple.isXROS()) {
548-
return std::nullopt;
566+
llvm::VersionTuple OSVersion = Triple.getOSVersion();
567+
unsigned Major = OSVersion.getMajor();
568+
unsigned Minor = OSVersion.getMinor().value_or(0);
569+
570+
if (Major <= 1) {
571+
if (Minor <= 0)
572+
return llvm::VersionTuple(5, 9);
573+
return llvm::VersionTuple(5, 10);
574+
}
549575
}
550576

551577
return std::nullopt;

lib/Sema/TypeCheckType.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3937,11 +3937,6 @@ NeverNullType TypeResolver::resolveASTFunctionType(
39373937
if (isolatedAttr && !isolatedAttr->isInvalid()) {
39383938
switch (isolatedAttr->getIsolationKind()) {
39393939
case IsolatedTypeAttr::IsolationKind::Dynamic:
3940-
if (!getASTContext().LangOpts.hasFeature(Feature::IsolatedAny)) {
3941-
diagnose(isolatedAttr->getAtLoc(), diag::isolated_any_experimental);
3942-
// Proceed as normal.
3943-
}
3944-
39453940
if (representation != FunctionType::Representation::Swift) {
39463941
assert(conventionAttr);
39473942
diagnoseInvalid(repr, isolatedAttr->getAtLoc(),

stdlib/public/Concurrency/CMakeLists.txt

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,6 @@ else()
6060
list(APPEND SWIFT_RUNTIME_CONCURRENCY_C_FLAGS "-fswift-async-fp=never")
6161
endif()
6262

63-
list(APPEND SWIFT_RUNTIME_CONCURRENCY_SWIFT_FLAGS
64-
"-enable-experimental-feature"
65-
"IsolatedAny2"
66-
)
67-
6863
list(APPEND SWIFT_RUNTIME_CONCURRENCY_C_FLAGS
6964
"-D__STDC_WANT_LIB_EXT1__=1")
7065

test/Concurrency/isolated_any.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %target-swift-frontend -typecheck -verify -disable-availability-checking -strict-concurrency=complete -enable-experimental-feature IsolatedAny -enable-upcoming-feature InferSendableFromCaptures %s
1+
// RUN: %target-swift-frontend -typecheck -verify -disable-availability-checking -strict-concurrency=complete -enable-upcoming-feature InferSendableFromCaptures %s
22

33
// REQUIRES: asserts
44

test/Distributed/distributed_actor_isolated_any.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// RUN: %empty-directory(%t)
22
// RUN: %target-swift-frontend-emit-module -emit-module-path %t/FakeDistributedActorSystems.swiftmodule -module-name FakeDistributedActorSystems -disable-availability-checking %S/Inputs/FakeDistributedActorSystems.swift
33

4-
// RUN: %target-swift-frontend -emit-silgen -enable-experimental-feature IsolatedAny %s -module-name test -swift-version 5 -disable-availability-checking -I %t | %FileCheck %s
4+
// RUN: %target-swift-frontend -emit-silgen %s -module-name test -swift-version 5 -disable-availability-checking -I %t | %FileCheck %s
55

66
// REQUIRES: concurrency
77
// REQUIRES: asserts

test/IRGen/isolated_any.sil

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %target-swift-frontend -emit-ir %s -enable-experimental-feature IsolatedAny | %IRGenFileCheck %s
1+
// RUN: %target-swift-frontend -emit-ir %s | %IRGenFileCheck %s
22

33
// REQUIRES: concurrency
44

test/IRGen/isolated_any_metadata.sil

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
// RUN: %swift -emit-ir %s -enable-experimental-feature IsolatedAny -target x86_64-apple-macosx10.10 -disable-legacy-type-info -parse-stdlib | %FileCheck -DINT=i64 %s -check-prefixes=CHECK,CHECK-ACCESSOR
2-
// RUN: %swift -emit-ir %s -enable-experimental-feature IsolatedAny -target x86_64-unknown-linux-gnu -disable-legacy-type-info -parse-stdlib | %FileCheck -DINT=i64 %s -check-prefixes=CHECK,CHECK-DEMANGLE
1+
// RUN: %swift -emit-ir %s -target x86_64-apple-macosx10.10 -disable-legacy-type-info -parse-stdlib | %FileCheck -DINT=i64 %s -check-prefixes=CHECK,CHECK-ACCESSOR
2+
// RUN: %swift -emit-ir %s -target x86_64-unknown-linux-gnu -disable-legacy-type-info -parse-stdlib | %FileCheck -DINT=i64 %s -check-prefixes=CHECK,CHECK-DEMANGLE
33

44
// REQUIRES: concurrency
55

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// RUN: %target-swift-frontend -emit-ir -target %target-cpu-apple-macos99.99 %s | %FileCheck --check-prefix=CHECK --check-prefix=CHECK-PRESENT %s
2+
// RUN: %target-swift-frontend -emit-ir -target %target-cpu-apple-macos14.4 %s | %FileCheck --check-prefix=CHECK --check-prefix=CHECK-SUPPRESSED %s
3+
4+
// REQUIRES: OS=macosx
5+
// UNSUPPORTED: CPU=arm64e
6+
7+
public struct MyStruct {
8+
let fn: @isolated(any) () -> ()
9+
}
10+
11+
// Make sure that we only emit a demangling-based type description
12+
// for @isolated(any) types when deploying to runtimes that support it.
13+
// If we don't, we fall back on using a type metadata accessor, which
14+
// is fine. Since this is for reflective metadata, we could go a step
15+
// further if we decide we really only care about layout equivalence for
16+
// these; if so, we could just suppress the @isolated(any) part of the
17+
// type completely, since it has the the same external layout as an
18+
// ordinary function type.
19+
// rdar://129861211
20+
21+
// CHECK-LABEL: @"$s32reflection_metadata_isolated_any8MyStructVMF" = internal constant
22+
// CHECK-PRESENT-SAME: ptr @"symbolic yyYAc"
23+
// CHECK-SUPPRESSED-SAME: ptr @"get_type_metadata yyYAc.1"

0 commit comments

Comments
 (0)