Skip to content

Commit 64f273c

Browse files
authored
Merge pull request #69437 from gottesmm/region-isolation-makeover
[region-isolation] Rename pass/feature flag and so some other cleanups.
2 parents e4f0d69 + 382609e commit 64f273c

File tree

103 files changed

+817
-814
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

103 files changed

+817
-814
lines changed

include/swift/Basic/Features.def

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,8 +218,8 @@ EXPERIMENTAL_FEATURE(BuiltinModule, true)
218218
// Enable strict concurrency.
219219
EXPERIMENTAL_FEATURE(StrictConcurrency, true)
220220

221-
/// Defer Sendable checking to SIL diagnostic phase.
222-
EXPERIMENTAL_FEATURE(SendNonSendable, false)
221+
/// Region Based Isolation testing using the TransferNonSendable pass
222+
EXPERIMENTAL_FEATURE(RegionBasedIsolation, false)
223223

224224
/// Within strict concurrency, narrow global variable isolation requirements.
225225
EXPERIMENTAL_FEATURE(GlobalConcurrency, false)

include/swift/SILOptimizer/PassManager/Passes.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ PASS(TempRValueOpt, "temp-rvalue-opt",
367367
"Remove short-lived immutable temporary copies")
368368
PASS(IRGenPrepare, "irgen-prepare",
369369
"Cleanup SIL in preparation for IRGen")
370-
PASS(SendNonSendable, "send-non-sendable",
370+
PASS(TransferNonSendable, "transfer-non-sendable",
371371
"Checks calls that send non-sendable values between isolation domains")
372372
PASS(SILGenCleanup, "silgen-cleanup",
373373
"Cleanup SIL in preparation for diagnostics")

include/swift/SILOptimizer/Utils/PartitionUtils.h

Lines changed: 163 additions & 157 deletions
Large diffs are not rendered by default.

lib/AST/ASTPrinter.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3569,9 +3569,7 @@ static bool usesFeatureParameterPacks(Decl *decl) {
35693569
return false;
35703570
}
35713571

3572-
static bool usesFeatureSendNonSendable(Decl *decl) {
3573-
return false;
3574-
}
3572+
static bool usesFeatureRegionBasedIsolation(Decl *decl) { return false; }
35753573

35763574
static bool usesFeatureGlobalConcurrency(Decl *decl) { return false; }
35773575

lib/SILOptimizer/Mandatory/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ target_sources(swiftSILOptimizer PRIVATE
4242
PMOMemoryUseCollector.cpp
4343
RawSILInstLowering.cpp
4444
ReferenceBindingTransform.cpp
45-
SendNonSendable.cpp
45+
TransferNonSendable.cpp
4646
SILGenCleanup.cpp
4747
YieldOnceCheck.cpp
4848
OSLogOptimization.cpp

lib/SILOptimizer/Mandatory/SendNonSendable.cpp renamed to lib/SILOptimizer/Mandatory/TransferNonSendable.cpp

Lines changed: 241 additions & 242 deletions
Large diffs are not rendered by default.

lib/SILOptimizer/PassManager/PassPipeline.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ static void addMandatoryDiagnosticOptPipeline(SILPassPipelinePlan &P) {
133133
P.addAddressLowering();
134134

135135
P.addFlowIsolation();
136-
P.addSendNonSendable();
136+
P.addTransferNonSendable();
137137

138138
// Automatic differentiation: canonicalize all differentiability witnesses
139139
// and `differentiable_function` instructions.

lib/Sema/TypeCheckConcurrency.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3182,7 +3182,7 @@ namespace {
31823182

31833183
// check if language features ask us to defer sendable diagnostics
31843184
// if so, don't check for sendability of arguments here
3185-
if (!ctx.LangOpts.hasFeature(Feature::SendNonSendable)) {
3185+
if (!ctx.LangOpts.hasFeature(Feature::RegionBasedIsolation)) {
31863186
diagnoseApplyArgSendability(apply, getDeclContext());
31873187
}
31883188

test/Concurrency/LLDBDebuggerFunctionActorExtension.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// RUN: %target-swift-frontend -disable-availability-checking -debugger-support %s -emit-sil -o /dev/null -verify
22
// RUN: %target-swift-frontend -disable-availability-checking -debugger-support %s -emit-sil -o /dev/null -verify -strict-concurrency=targeted
33
// RUN: %target-swift-frontend -disable-availability-checking -debugger-support %s -emit-sil -o /dev/null -verify -strict-concurrency=complete
4-
// RUN: %target-swift-frontend -disable-availability-checking -debugger-support %s -emit-sil -o /dev/null -verify -strict-concurrency=complete -enable-experimental-feature SendNonSendable
4+
// RUN: %target-swift-frontend -disable-availability-checking -debugger-support %s -emit-sil -o /dev/null -verify -strict-concurrency=complete -enable-experimental-feature RegionBasedIsolation
55

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

test/Concurrency/actor_call_implicitly_async.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// RUN: %target-swift-frontend -disable-availability-checking -warn-concurrency -parse-as-library %s -emit-sil -o /dev/null -verify -verify-additional-prefix complete-
2-
// RUN: %target-swift-frontend -disable-availability-checking -warn-concurrency -parse-as-library %s -emit-sil -o /dev/null -verify -enable-experimental-feature SendNonSendable
2+
// RUN: %target-swift-frontend -disable-availability-checking -warn-concurrency -parse-as-library %s -emit-sil -o /dev/null -verify -enable-experimental-feature RegionBasedIsolation
33

44
// REQUIRES: concurrency
55
// REQUIRES: asserts

test/Concurrency/actor_defer.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// RUN: %target-swift-frontend -parse-as-library -emit-sil -DNEGATIVES -verify %s
22
// RUN: %target-swift-frontend -parse-as-library -emit-sil -DNEGATIVES -verify %s -strict-concurrency=targeted
33
// RUN: %target-swift-frontend -parse-as-library -emit-sil -DNEGATIVES -verify %s -strict-concurrency=complete
4-
// RUN: %target-swift-frontend -parse-as-library -emit-sil -DNEGATIVES -verify %s -strict-concurrency=complete -enable-experimental-feature SendNonSendable
4+
// RUN: %target-swift-frontend -parse-as-library -emit-sil -DNEGATIVES -verify %s -strict-concurrency=complete -enable-experimental-feature RegionBasedIsolation
55

66
// RUN: %target-swift-frontend -parse-as-library -emit-sil -enable-actor-data-race-checks -o - %s | %FileCheck %s
77

test/Concurrency/actor_derived_conformances.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// RUN: %target-swift-frontend -disable-availability-checking %s -emit-sil -o /dev/null -verify
22
// RUN: %target-swift-frontend -disable-availability-checking %s -emit-sil -o /dev/null -verify -strict-concurrency=targeted
33
// RUN: %target-swift-frontend -disable-availability-checking %s -emit-sil -o /dev/null -verify -strict-concurrency=complete
4-
// RUN: %target-swift-frontend -disable-availability-checking %s -emit-sil -o /dev/null -verify -strict-concurrency=complete -enable-experimental-feature SendNonSendable
4+
// RUN: %target-swift-frontend -disable-availability-checking %s -emit-sil -o /dev/null -verify -strict-concurrency=complete -enable-experimental-feature RegionBasedIsolation
55

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

test/Concurrency/actor_existentials.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// RUN: %target-swift-frontend -disable-availability-checking %s -emit-sil -o /dev/null -verify
22
// RUN: %target-swift-frontend -disable-availability-checking %s -emit-sil -o /dev/null -verify -strict-concurrency=targeted
33
// RUN: %target-swift-frontend -disable-availability-checking %s -emit-sil -o /dev/null -verify -strict-concurrency=complete
4-
// RUN: %target-swift-frontend -disable-availability-checking %s -emit-sil -o /dev/null -verify -strict-concurrency=complete -enable-experimental-feature SendNonSendable
4+
// RUN: %target-swift-frontend -disable-availability-checking %s -emit-sil -o /dev/null -verify -strict-concurrency=complete -enable-experimental-feature RegionBasedIsolation
55

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

test/Concurrency/actor_inout_isolation.swift

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// RUN: %target-swift-frontend -disable-availability-checking %s -emit-sil -o /dev/null -verify -verify-additional-prefix minimal-targeted-
2-
// RUN: %target-swift-frontend -disable-availability-checking %s -emit-sil -o /dev/null -verify -verify-additional-prefix targeted-complete-sns- -verify-additional-prefix targeted-complete- -verify-additional-prefix minimal-targeted- -strict-concurrency=targeted
3-
// RUN: %target-swift-frontend -disable-availability-checking %s -emit-sil -o /dev/null -verify -verify-additional-prefix targeted-complete-sns- -verify-additional-prefix targeted-complete- -verify-additional-prefix complete-sns- -verify-additional-prefix complete- -strict-concurrency=complete
4-
// RUN: %target-swift-frontend -disable-availability-checking %s -emit-sil -o /dev/null -verify -verify-additional-prefix targeted-complete-sns- -verify-additional-prefix complete-sns- -strict-concurrency=complete -enable-experimental-feature SendNonSendable
2+
// RUN: %target-swift-frontend -disable-availability-checking %s -emit-sil -o /dev/null -verify -verify-additional-prefix targeted-complete-tns- -verify-additional-prefix targeted-complete- -verify-additional-prefix minimal-targeted- -strict-concurrency=targeted
3+
// RUN: %target-swift-frontend -disable-availability-checking %s -emit-sil -o /dev/null -verify -verify-additional-prefix targeted-complete-tns- -verify-additional-prefix targeted-complete- -verify-additional-prefix complete-tns- -verify-additional-prefix complete- -strict-concurrency=complete
4+
// RUN: %target-swift-frontend -disable-availability-checking %s -emit-sil -o /dev/null -verify -verify-additional-prefix targeted-complete-tns- -verify-additional-prefix complete-tns- -strict-concurrency=complete -enable-experimental-feature RegionBasedIsolation
55

66
// REQUIRES: concurrency
77
// REQUIRES: asserts
@@ -102,8 +102,8 @@ extension TestActor {
102102
// external class method call
103103
@available(SwiftStdlib 5.1, *)
104104
class NonAsyncClass { // expected-targeted-complete-note {{class 'NonAsyncClass' does not conform to the 'Sendable' protocol}}
105-
// expected-targeted-complete-sns-note @-1 {{class 'NonAsyncClass' does not conform to the 'Sendable' protocol}}
106-
// expected-sns-note @-2 {{class 'NonAsyncClass' does not conform to the 'Sendable' protocol}}
105+
// expected-targeted-complete-tns-note @-1 {{class 'NonAsyncClass' does not conform to the 'Sendable' protocol}}
106+
// expected-tns-note @-2 {{class 'NonAsyncClass' does not conform to the 'Sendable' protocol}}
107107
func modifyOtherAsync(_ other : inout Int) async {
108108
// ...
109109
}
@@ -121,7 +121,7 @@ extension TestActor {
121121
func passStateIntoDifferentClassMethod() async {
122122
let other = NonAsyncClass()
123123
let otherCurry = other.modifyOtherAsync
124-
// expected-targeted-complete-sns-warning @-1 {{non-sendable type 'NonAsyncClass' exiting actor-isolated context in call to non-isolated instance method 'modifyOtherAsync' cannot cross actor boundary}}
124+
// expected-targeted-complete-tns-warning @-1 {{non-sendable type 'NonAsyncClass' exiting actor-isolated context in call to non-isolated instance method 'modifyOtherAsync' cannot cross actor boundary}}
125125
await other.modifyOtherAsync(&value2)
126126
// expected-error @-1 {{actor-isolated property 'value2' cannot be passed 'inout' to 'async' function call}}
127127
// expected-targeted-complete-warning @-2 {{passing argument of non-sendable type 'NonAsyncClass' outside of actor-isolated context may introduce data races}}
@@ -217,22 +217,22 @@ struct MyGlobalActor {
217217
// expected-note @-1 {{var declared here}}
218218
// expected-note @-2 {{var declared here}}
219219
// expected-note @-3 {{mutation of this var is only permitted within the actor}}
220-
// expected-complete-sns-error @-4 {{top-level code variables cannot have a global actor}}
221-
// expected-complete-sns-note @-5 4{{mutation of this var is only permitted within the actor}}
220+
// expected-complete-tns-error @-4 {{top-level code variables cannot have a global actor}}
221+
// expected-complete-tns-note @-5 4{{mutation of this var is only permitted within the actor}}
222222

223223

224224
if #available(SwiftStdlib 5.1, *) {
225225
let _ = Task.detached { await { (_ foo: inout Int) async in foo += 1 }(&number) }
226226
// expected-error @-1 {{actor-isolated var 'number' cannot be passed 'inout' to 'async' function call}}
227227
// expected-minimal-targeted-error @-2 {{global actor 'MyGlobalActor'-isolated var 'number' can not be used 'inout' from a non-isolated context}}
228-
// expected-complete-sns-error @-3 {{main actor-isolated var 'number' can not be used 'inout' from a non-isolated context}}
228+
// expected-complete-tns-error @-3 {{main actor-isolated var 'number' can not be used 'inout' from a non-isolated context}}
229229
}
230230

231231
// attempt to pass global state owned by the global actor to another async function
232232
@available(SwiftStdlib 5.1, *)
233233
@MyGlobalActor func sneaky() async { await modifyAsynchronously(&number) }
234234
// expected-error @-1 {{actor-isolated var 'number' cannot be passed 'inout' to 'async' function call}}
235-
// expected-complete-sns-error @-2 {{main actor-isolated var 'number' can not be used 'inout' from global actor 'MyGlobalActor'}}
235+
// expected-complete-tns-error @-2 {{main actor-isolated var 'number' can not be used 'inout' from global actor 'MyGlobalActor'}}
236236

237237

238238
// It's okay to pass actor state inout to synchronous functions!
@@ -242,13 +242,13 @@ func globalSyncFunction(_ foo: inout Int) { }
242242
@MyGlobalActor func globalActorSyncFunction(_ foo: inout Int) { }
243243
@available(SwiftStdlib 5.1, *)
244244
@MyGlobalActor func globalActorAsyncOkay() async { globalActorSyncFunction(&number) }
245-
// expected-complete-sns-error @-1 {{main actor-isolated var 'number' can not be used 'inout' from global actor 'MyGlobalActor'}}
245+
// expected-complete-tns-error @-1 {{main actor-isolated var 'number' can not be used 'inout' from global actor 'MyGlobalActor'}}
246246
@available(SwiftStdlib 5.1, *)
247247
@MyGlobalActor func globalActorAsyncOkay2() async { globalSyncFunction(&number) }
248-
// expected-complete-sns-error @-1 {{main actor-isolated var 'number' can not be used 'inout' from global actor 'MyGlobalActor'}}
248+
// expected-complete-tns-error @-1 {{main actor-isolated var 'number' can not be used 'inout' from global actor 'MyGlobalActor'}}
249249
@available(SwiftStdlib 5.1, *)
250250
@MyGlobalActor func globalActorSyncOkay() { globalSyncFunction(&number) }
251-
// expected-complete-sns-error @-1 {{main actor-isolated var 'number' can not be used 'inout' from global actor 'MyGlobalActor'}}
251+
// expected-complete-tns-error @-1 {{main actor-isolated var 'number' can not be used 'inout' from global actor 'MyGlobalActor'}}
252252

253253
// Gently unwrap things that are fine
254254
@available(SwiftStdlib 5.1, *)
@@ -293,11 +293,11 @@ actor ProtectArray {
293293
func test() async {
294294
// FIXME: this is invalid too!
295295
_ = await array.mutateAsynchronously
296-
// expected-targeted-complete-sns-warning@-1 {{non-sendable type '@lvalue [Int]' exiting actor-isolated context in call to non-isolated property 'mutateAsynchronously' cannot cross actor boundary}}
296+
// expected-targeted-complete-tns-warning@-1 {{non-sendable type '@lvalue [Int]' exiting actor-isolated context in call to non-isolated property 'mutateAsynchronously' cannot cross actor boundary}}
297297

298298
_ = await array[mutateAsynchronously: 0]
299299
// expected-error@-1 {{actor-isolated property 'array' cannot be passed 'inout' to 'async' function call}}
300-
// expected-targeted-complete-sns-warning@-2 {{non-sendable type 'inout Array<Int>' exiting actor-isolated context in call to non-isolated subscript 'subscript(mutateAsynchronously:)' cannot cross actor boundary}}
300+
// expected-targeted-complete-tns-warning@-2 {{non-sendable type 'inout Array<Int>' exiting actor-isolated context in call to non-isolated subscript 'subscript(mutateAsynchronously:)' cannot cross actor boundary}}
301301

302302
await passToAsync(array[0])
303303

test/Concurrency/actor_isolation.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// RUN: %target-swift-frontend -emit-module -emit-module-path %t/OtherActors.swiftmodule -module-name OtherActors %S/Inputs/OtherActors.swift -disable-availability-checking
44

55
// RUN: %target-swift-frontend -I %t -disable-availability-checking -warn-concurrency -parse-as-library -emit-sil -o /dev/null -verify %s
6-
// RUN: %target-swift-frontend -I %t -disable-availability-checking -warn-concurrency -parse-as-library -emit-sil -o /dev/null -verify -enable-experimental-feature SendNonSendable %s
6+
// RUN: %target-swift-frontend -I %t -disable-availability-checking -warn-concurrency -parse-as-library -emit-sil -o /dev/null -verify -enable-experimental-feature RegionBasedIsolation %s
77

88
// REQUIRES: concurrency
99
// REQUIRES: asserts

test/Concurrency/actor_isolation_cycle.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// RUN: %target-swift-frontend %s -emit-sil -o /dev/null -verify
22
// RUN: %target-swift-frontend %s -emit-sil -o /dev/null -verify -strict-concurrency=targeted
33
// RUN: %target-swift-frontend %s -emit-sil -o /dev/null -verify -strict-concurrency=complete
4-
// RUN: %target-swift-frontend %s -emit-sil -o /dev/null -verify -strict-concurrency=complete -enable-experimental-feature SendNonSendable
4+
// RUN: %target-swift-frontend %s -emit-sil -o /dev/null -verify -strict-concurrency=complete -enable-experimental-feature RegionBasedIsolation
55

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

test/Concurrency/actor_isolation_objc.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// RUN: %target-swift-frontend -disable-availability-checking %s -emit-sil -o /dev/null -verify
22
// RUN: %target-swift-frontend -disable-availability-checking %s -emit-sil -o /dev/null -verify -strict-concurrency=targeted
33
// RUN: %target-swift-frontend -disable-availability-checking %s -emit-sil -o /dev/null -verify -strict-concurrency=complete
4-
// RUN: %target-swift-frontend -disable-availability-checking %s -emit-sil -o /dev/null -verify -strict-concurrency=complete -enable-experimental-feature SendNonSendable
4+
// RUN: %target-swift-frontend -disable-availability-checking %s -emit-sil -o /dev/null -verify -strict-concurrency=complete -enable-experimental-feature RegionBasedIsolation
55

66
// REQUIRES: concurrency
77
// REQUIRES: objc_interop

test/Concurrency/actor_isolation_swift6.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// RUN: %target-swift-frontend -disable-availability-checking -warn-concurrency -swift-version 6 -emit-sil -o /dev/null -verify %s
2-
// RUN: %target-swift-frontend -disable-availability-checking -warn-concurrency -swift-version 6 -emit-sil -o /dev/null -verify -enable-experimental-feature SendNonSendable %s
2+
// RUN: %target-swift-frontend -disable-availability-checking -warn-concurrency -swift-version 6 -emit-sil -o /dev/null -verify -enable-experimental-feature RegionBasedIsolation %s
33

44
// REQUIRES: concurrency
55
// REQUIRES: asserts

0 commit comments

Comments
 (0)