diff --git a/include/swift/SILOptimizer/Utils/PartitionUtils.h b/include/swift/SILOptimizer/Utils/PartitionUtils.h index 9b859ef34c372..1ae400441b3d0 100644 --- a/include/swift/SILOptimizer/Utils/PartitionUtils.h +++ b/include/swift/SILOptimizer/Utils/PartitionUtils.h @@ -1375,13 +1375,6 @@ struct PartitionOpEvaluator { void handleLocalUseAfterTransferHelper(const PartitionOp &op, Element elt, Operand *transferringOp) const { if (shouldTryToSquelchErrors()) { - if (auto isolationInfo = getIsolationInfo(op)) { - if (isolationInfo.isActorIsolated() && - isolationInfo.hasSameIsolation( - SILIsolationInfo::get(transferringOp->getUser()))) - return; - } - if (SILValue equivalenceClassRep = getRepresentative(transferringOp->get())) { diff --git a/test/Concurrency/concurrent_value_checking.swift b/test/Concurrency/concurrent_value_checking.swift index 530ff9cbdedd8..8eaa0c4a21bb4 100644 --- a/test/Concurrency/concurrent_value_checking.swift +++ b/test/Concurrency/concurrent_value_checking.swift @@ -6,8 +6,7 @@ // REQUIRES: asserts class NotConcurrent { } // expected-note 13{{class 'NotConcurrent' does not conform to the 'Sendable' protocol}} -// expected-complete-note @-1 13{{class 'NotConcurrent' does not conform to the 'Sendable' protocol}} -// expected-tns-allow-typechecker-note @-2 {{class 'NotConcurrent' does not conform to the 'Sendable' protocol}} +// expected-tns-allow-typechecker-note @-1 {{class 'NotConcurrent' does not conform to the 'Sendable' protocol}} // ---------------------------------------------------------------------- // Sendable restriction on actor operations @@ -67,23 +66,23 @@ actor A2 { } func testActorCreation(value: NotConcurrent) async { - _ = A2(value: value) // expected-complete-warning{{passing argument of non-sendable type 'NotConcurrent' into actor-isolated context may introduce data races}} + _ = A2(value: value) // expected-tns-warning @-1 {{sending 'value' risks causing data races}} // expected-tns-note @-2 {{sending task-isolated 'value' to actor-isolated initializer 'init(value:)' risks causing data races between actor-isolated and task-isolated uses}} - _ = await A2(valueAsync: value) // expected-complete-warning{{passing argument of non-sendable type 'NotConcurrent' into actor-isolated context may introduce data races}} + _ = await A2(valueAsync: value) // expected-tns-warning @-1 {{sending 'value' risks causing data races}} // expected-tns-note @-2 {{sending task-isolated 'value' to actor-isolated initializer 'init(valueAsync:)' risks causing data races between actor-isolated and task-isolated uses}} - _ = A2(delegatingSync: value) // expected-complete-warning{{passing argument of non-sendable type 'NotConcurrent' into actor-isolated context may introduce data races}} + _ = A2(delegatingSync: value) // expected-tns-warning @-1 {{sending 'value' risks causing data races}} // expected-tns-note @-2 {{sending task-isolated 'value' to actor-isolated initializer 'init(delegatingSync:)' risks causing data races between actor-isolated and task-isolated uses}} - _ = await A2(delegatingAsync: value, 9) // expected-complete-warning{{passing argument of non-sendable type 'NotConcurrent' into actor-isolated context may introduce data races}} + _ = await A2(delegatingAsync: value, 9) // expected-tns-warning @-1 {{sending 'value' risks causing data races}} // expected-tns-note @-2 {{sending task-isolated 'value' to actor-isolated initializer 'init(delegatingAsync:_:)' risks causing data races between actor-isolated and task-isolated uses}} - _ = await A2(nonisoAsync: value, 3) // expected-complete-warning{{passing argument of non-sendable type 'NotConcurrent' into actor-isolated context may introduce data races}} + _ = await A2(nonisoAsync: value, 3) // expected-tns-warning @-1 {{sending 'value' risks causing data races}} // expected-tns-note @-2 {{sending task-isolated 'value' to actor-isolated initializer 'init(nonisoAsync:_:)' risks causing data races between actor-isolated and task-isolated uses}} } @@ -104,7 +103,7 @@ extension A1 { // expected-warning@-1 {{expression is 'async' but is not marked with 'await'}} // expected-note@-2 {{property access is 'async'}} _ = await other.synchronous() // expected-warning{{non-sendable type 'NotConcurrent?' returned by call to actor-isolated function cannot cross actor boundary}} - _ = await other.asynchronous(nil) // expected-complete-warning{{passing argument of non-sendable type 'NotConcurrent?' into actor-isolated context may introduce data races}} + _ = await other.asynchronous(nil) } } @@ -142,8 +141,9 @@ func globalTest() async { // expected-warning@+2 {{expression is 'async' but is not marked with 'await'}} // expected-note@+1 {{property access is 'async'}} let a = globalValue // expected-warning{{non-sendable type 'NotConcurrent?' in implicitly asynchronous access to global actor 'SomeGlobalActor'-isolated let 'globalValue' cannot cross actor boundary}} - await globalAsync(a) // expected-complete-warning{{passing argument of non-sendable type 'NotConcurrent?' into global actor 'SomeGlobalActor'-isolated context may introduce data races}} - await globalSync(a) // expected-complete-warning{{passing argument of non-sendable type 'NotConcurrent?' into global actor 'SomeGlobalActor'-isolated context may introduce data races}} + await globalAsync(a) // expected-tns-warning {{sending 'a' risks causing data races}} + // expected-tns-note @-1 {{sending global actor 'SomeGlobalActor'-isolated 'a' to global actor 'SomeGlobalActor'-isolated global function 'globalAsync' risks causing data races between global actor 'SomeGlobalActor'-isolated and local nonisolated uses}} + await globalSync(a) // expected-tns-note {{access can happen concurrently}} // expected-warning@+2 {{expression is 'async' but is not marked with 'await'}} // expected-note@+1 {{property access is 'async'}} @@ -154,7 +154,7 @@ func globalTest() async { // expected-typechecker-note@+2 {{call is 'async'}} // expected-typechecker-note@+1 {{property access is 'async'}} globalAsync(E.notSafe) - // expected-complete-warning@-1 {{passing argument of non-sendable type 'NotConcurrent?' into global actor 'SomeGlobalActor'-isolated context may introduce data races}} + // expected-typechecker-warning@-2 {{non-sendable type 'NotConcurrent?' in implicitly asynchronous access to global actor 'SomeGlobalActor'-isolated static property 'notSafe' cannot cross actor boundary}} #endif } @@ -178,9 +178,10 @@ func globalTestMain(nc: NotConcurrent) async { // expected-warning@+2 {{expression is 'async' but is not marked with 'await'}} // expected-note@+1 {{property access is 'async'}} let a = globalValue // expected-warning {{non-sendable type 'NotConcurrent?' in implicitly asynchronous access to global actor 'SomeGlobalActor'-isolated let 'globalValue' cannot cross actor boundary}} - await globalAsync(a) // expected-complete-warning {{passing argument of non-sendable type 'NotConcurrent?' into global actor 'SomeGlobalActor'-isolated context may introduce data races}} - await globalSync(a) // expected-complete-warning {{passing argument of non-sendable type 'NotConcurrent?' into global actor 'SomeGlobalActor'-isolated context may introduce data races}} - _ = await ClassWithGlobalActorInits(nc) // expected-complete-warning {{passing argument of non-sendable type 'NotConcurrent' into global actor 'SomeGlobalActor'-isolated context may introduce data races}} + await globalAsync(a) // expected-tns-warning {{sending 'a' risks causing data races}} + // expected-tns-note @-1 {{sending global actor 'SomeGlobalActor'-isolated 'a' to global actor 'SomeGlobalActor'-isolated global function 'globalAsync' risks causing data races between global actor 'SomeGlobalActor'-isolated and local main actor-isolated uses}} + await globalSync(a) // expected-tns-note {{access can happen concurrently}} + _ = await ClassWithGlobalActorInits(nc) // expected-warning @-1 {{non-sendable type 'ClassWithGlobalActorInits' returned by call to global actor 'SomeGlobalActor'-isolated function cannot cross actor boundary}} // expected-tns-warning @-2 {{sending 'nc' risks causing data races}} // expected-tns-note @-3 {{sending main actor-isolated 'nc' to global actor 'SomeGlobalActor'-isolated initializer 'init(_:)' risks causing data races between global actor 'SomeGlobalActor'-isolated and main actor-isolated uses}} diff --git a/test/Concurrency/sendable_checking.swift b/test/Concurrency/sendable_checking.swift index 9a51673d76679..56364418b6135 100644 --- a/test/Concurrency/sendable_checking.swift +++ b/test/Concurrency/sendable_checking.swift @@ -295,9 +295,12 @@ func testNonSendableBaseArg() async { let t = NonSendable() await t.update() // expected-targeted-and-complete-warning @-1 {{passing argument of non-sendable type 'NonSendable' into main actor-isolated context may introduce data races}} + // expected-tns-warning @-2 {{sending 't' risks causing data races}} + // expected-tns-note @-3 {{sending 't' to main actor-isolated instance method 'update()' risks causing data races between main actor-isolated and local nonisolated uses}} _ = await t.x // expected-warning @-1 {{non-sendable type 'NonSendable' passed in implicitly asynchronous call to main actor-isolated property 'x' cannot cross actor boundary}} + // expected-tns-note @-2 {{access can happen concurrently}} } // We get the region isolation error here since t.y is custom actor isolated. diff --git a/test/Concurrency/transfernonsendable.swift b/test/Concurrency/transfernonsendable.swift index 5a97e2868c14c..a190308139246 100644 --- a/test/Concurrency/transfernonsendable.swift +++ b/test/Concurrency/transfernonsendable.swift @@ -151,10 +151,7 @@ func closureInOut(_ a: MyActor) async { // expected-tns-note @-3 {{sending 'ns0' to actor-isolated instance method 'useKlass' risks causing data races between actor-isolated and local nonisolated uses}} if await booleanFlag { - // This is not an actual use since we are passing values to the same - // isolation domain. - await a.useKlass(ns1) - // expected-complete-warning @-1 {{passing argument of non-sendable type 'NonSendableKlass'}} + await a.useKlass(ns1) // expected-tns-note {{access can happen concurrently}} } else { closure() // expected-tns-note {{access can happen concurrently}} } @@ -1230,11 +1227,11 @@ func varNonSendableNonTrivialLetStructFieldClosureFlowSensitive4() async { // good... that is QoI though. await transferToMain(test) // expected-tns-warning {{sending 'test' risks causing data races}} // expected-tns-note @-1 {{sending 'test' to main actor-isolated global function 'transferToMain' risks causing data races between main actor-isolated and local nonisolated uses}} - // expected-complete-warning @-2 {{passing argument of non-sendable type 'StructFieldTests' into main actor-isolated context may introduce data races}} + // expected-tns-note @-2 {{access can happen concurrently}} // This is treated as a use since test is in box form and is mutable. So we // treat assignment as a merge. - test = StructFieldTests() // expected-tns-note {{access can happen concurrently}} + test = StructFieldTests() cls = { useInOut(&test.varSendableNonTrivial) } @@ -1265,7 +1262,7 @@ func varNonSendableNonTrivialLetStructFieldClosureFlowSensitive5() async { } test.varSendableNonTrivial = SendableKlass() - useValue(test) // expected-tns-note {{access can happen concurrently}} + useValue(test) } func varNonSendableNonTrivialLetStructFieldClosureFlowSensitive6() async { @@ -1434,7 +1431,7 @@ func controlFlowTest2() async { x = NonSendableKlass() } - useValue(x) // expected-tns-note {{access can happen concurrently}} + useValue(x) } //////////////////////// @@ -1750,8 +1747,9 @@ func sendableGlobalActorIsolated() { // value. func testIndirectParameterSameIsolationNoError() async { let x = NonSendableKlass() - await transferToMain(x) // expected-complete-warning {{passing argument of non-sendable type 'NonSendableKlass' into main actor-isolated context may introduce data races}} - await transferToMain(x) // expected-complete-warning {{passing argument of non-sendable type 'NonSendableKlass' into main actor-isolated context may introduce data races}} + await transferToMain(x) // expected-tns-warning {{sending 'x' risks causing data races}} + // expected-tns-note @-1 {{sending 'x' to main actor-isolated global function 'transferToMain' risks causing data races between main actor-isolated and local nonisolated uses}} + await transferToMain(x) // expected-tns-note {{access can happen concurrently}} } extension MyActor { diff --git a/test/Concurrency/transfernonsendable_asynclet.swift b/test/Concurrency/transfernonsendable_asynclet.swift index ccdf105f73aa7..c4768dfbe29d8 100644 --- a/test/Concurrency/transfernonsendable_asynclet.swift +++ b/test/Concurrency/transfernonsendable_asynclet.swift @@ -293,13 +293,13 @@ func asyncLet_Let_ActorIsolated_CallBuriedInOtherExpr3() async { let _ = await y } -// Make sure that we do not emit an error for transferToMainInt in the async val -// function itself since we are sending the value to the same main actor -// isolated use and transferring it into one async let variable. func asyncLet_Let_ActorIsolated_CallBuriedInOtherExpr4() async { let x = NonSendableKlass() async let y = useValue(transferToMainInt(x) + transferToMainInt(x)) + // expected-warning @-1:26 {{sending 'x' risks causing data races}} + // expected-note @-2:26 {{sending 'x' to main actor-isolated global function 'transferToMainInt' risks causing data races between main actor-isolated and local nonisolated uses}} + // expected-note @-3:49 {{access can happen concurrently}} let _ = await y } diff --git a/test/Concurrency/transfernonsendable_instruction_matching.sil b/test/Concurrency/transfernonsendable_instruction_matching.sil index 6350e1d219d5a..47e0e0952e12c 100644 --- a/test/Concurrency/transfernonsendable_instruction_matching.sil +++ b/test/Concurrency/transfernonsendable_instruction_matching.sil @@ -645,14 +645,12 @@ bb0: fix_lifetime %value : $SendableKlass - // This is not considered a bad use of the raw pointer since this is - // sending to the same isolation domain. apply [caller_isolation=nonisolated] [callee_isolation=global_actor] %transferRawPointer(%rawPointer) : $@convention(thin) @async (Builtin.RawPointer) -> () // expected-warning @-1 {{}} + // expected-note @-2 {{access can happen concurrently}} fix_lifetime %rawPointer : $Builtin.RawPointer // expected-note @-1 {{access can happen concurrently}} - // expected-note @-2 {{access can happen concurrently}} destroy_value %value : $SendableKlass %9999 = tuple () @@ -725,10 +723,10 @@ bb0: apply [caller_isolation=nonisolated] [callee_isolation=global_actor] %transferRawPointer(%rawPointer) : $@convention(thin) @async (Builtin.RawPointer) -> () // expected-warning @-1 {{}} + // expected-note @-2 {{access can happen concurrently}} fix_lifetime %rawPointer : $Builtin.RawPointer // expected-note @-1 {{access can happen concurrently}} - // expected-note @-2 {{access can happen concurrently}} destroy_value %value : $SendableKlass %9999 = tuple () @@ -804,10 +802,10 @@ bb0: apply [caller_isolation=nonisolated] [callee_isolation=global_actor] %transferRawPointer(%rawPointer) : $@convention(thin) @async (Builtin.RawPointer) -> () // expected-warning @-1 {{}} + // expected-note @-2 {{access can happen concurrently}} fix_lifetime %rawPointer : $Builtin.RawPointer // expected-note @-1 {{access can happen concurrently}} - // expected-note @-2 {{access can happen concurrently}} end_borrow %valueB : $SendableKlass destroy_value %value : $SendableKlass