Skip to content

[region-isolation] Change semantics of function_extract_isolation from AssertingIfNonSendable -> Require. #72368

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/SILOptimizer/Analysis/RegionAnalysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2638,7 +2638,7 @@ CONSTANT_TRANSLATION(DynamicMethodBranchInst, TerminatorPhi)
CONSTANT_TRANSLATION(AwaitAsyncContinuationInst, AssertingIfNonSendable)
CONSTANT_TRANSLATION(GetAsyncContinuationInst, AssertingIfNonSendable)
CONSTANT_TRANSLATION(ExtractExecutorInst, AssertingIfNonSendable)
CONSTANT_TRANSLATION(FunctionExtractIsolationInst, AssertingIfNonSendable)
CONSTANT_TRANSLATION(FunctionExtractIsolationInst, Require)

//===---
// Existential Box
Expand Down
17 changes: 17 additions & 0 deletions test/Concurrency/transfernonsendable_instruction_matching.sil
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ sil_stage raw

import Swift
import Builtin
import _Concurrency

class NonSendableKlass {}

Expand Down Expand Up @@ -1545,6 +1546,22 @@ bb0(%index : $Builtin.Word):
return %9999 : $()
}

sil @function_extract_isolation_test_closure : $@convention(thin) (@guaranteed Optional<any Actor>, Int) -> ()

// This used to crash when function_extract_isolation was AssertingIfNonSendable.
sil [ossa] @function_extract_isolation_test : $@async @convention(thin) (@owned Optional<any Actor>, Int) -> () {
bb0(%actor : @owned $Optional<any Actor>, %int : $Int):
%f = function_ref @function_extract_isolation_test_closure : $@convention(thin) (@guaranteed Optional<any Actor>, Int) -> ()
%closure = partial_apply [isolated_any] [callee_guaranteed] %f(%actor, %int) : $@convention(thin) (@guaranteed Optional<any Actor>, Int) -> ()
%closure_b = begin_borrow %closure : $@callee_guaranteed @isolated(any) () -> ()
%outputActor = function_extract_isolation %closure_b : $@callee_guaranteed @isolated(any) () -> ()
end_borrow %closure_b : $@callee_guaranteed @isolated(any) () -> ()
destroy_value %closure : $@callee_guaranteed @isolated(any) () -> ()

%9999 = tuple ()
return %9999 : $()
}

sil [ossa] @begin_unpaired_access_test : $@async @convention(thin) () -> () {
bb0:
%constructFn = function_ref @constructNonSendableKlass : $@convention(thin) () -> @owned NonSendableKlass
Expand Down