|
5 | 5 | // REQUIRES: swift_feature_NonisolatedNonsendingByDefault
|
6 | 6 |
|
7 | 7 | // Validate that both with and without the experimental flag we properly codegen
|
8 |
| -// execution(caller) and execution(concurrent). |
| 8 | +// `@concurrent` and `nonisolated(nonsending)` |
9 | 9 |
|
10 | 10 | // CHECK-LABEL: // executionCaller()
|
11 | 11 | // CHECK-NEXT: // Isolation: caller_isolation_inheriting
|
@@ -62,3 +62,36 @@ extension S {
|
62 | 62 | // CHECK: sil hidden [ossa] @$s14execution_attr1SV0A17CallerFieldMethodyyyyYaYCXEF : $@convention(method) (@guaranteed @noescape @async @callee_guaranteed (@sil_isolated @sil_implicit_leading_param @guaranteed Optional<any Actor>) -> (), @guaranteed S) -> () {
|
63 | 63 | func executionCallerFieldMethod(_ x: nonisolated(nonsending) () async -> ()) {}
|
64 | 64 | }
|
| 65 | + |
| 66 | +// CHECK-LABEL: sil hidden [ossa] @$s14execution_attr24testWithDynamicIsolation2fnyyyYAXE_tYaF : $@convention(thin) @async (@guaranteed @isolated(any) @noescape @callee_guaranteed () -> ()) -> () { |
| 67 | +// CHECK: bb0([[PARAM_FN:%.*]] : @guaranteed $@isolated(any) @noescape @callee_guaranteed () -> ()): |
| 68 | +// CHECK: [[GENERIC_EXEC:%.*]] = enum $Optional<Builtin.Executor>, #Optional.none!enumelt |
| 69 | +// CHECK-NEXT: hop_to_executor [[GENERIC_EXEC]] |
| 70 | +// CHECK-NEXT: [[FN:%.*]] = copy_value [[PARAM_FN]] |
| 71 | +// CHECK-NEXT: [[BORROWED_FN:%.*]] = begin_borrow [[FN]] |
| 72 | +// CHECK-NEXT: [[FN_ISOLATION:%.*]] = function_extract_isolation [[BORROWED_FN]] |
| 73 | +// CHECK-NEXT: hop_to_executor [[FN_ISOLATION]] |
| 74 | +// CHECK-NEXT: [[BORROWED_FN:%.*]] = begin_borrow [[FN]] |
| 75 | +// CHECK-NEXT: apply [[BORROWED_FN]]() |
| 76 | +// CHECK: hop_to_executor [[GENERIC_EXEC]] |
| 77 | +// CHECK: } // end sil function '$s14execution_attr24testWithDynamicIsolation2fnyyyYAXE_tYaF' |
| 78 | +@concurrent |
| 79 | +func testWithDynamicIsolation(fn: @isolated(any) () -> Void) async { |
| 80 | + await fn() |
| 81 | +} |
| 82 | + |
| 83 | +// CHECK-LABEL: sil hidden [ossa] @$s14execution_attr38testCallerIsolatedWithDynamicIsolation2fnyyyYAXE_tYaF : $@convention(thin) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Optional<any Actor>, @guaranteed @isolated(any) @noescape @callee_guaranteed () -> ()) -> () { |
| 84 | +// CHECK: bb0([[ISOLATION:%.*]] : @guaranteed $Optional<any Actor>, [[PARAM_FN:%.*]] : @guaranteed $@isolated(any) @noescape @callee_guaranteed () -> ()): |
| 85 | +// CHECK: hop_to_executor [[ISOLATION]] |
| 86 | +// CHECK-NEXT: [[FN:%.*]] = copy_value [[PARAM_FN]] |
| 87 | +// CHECK-NEXT: [[BORROWED_FN:%.*]] = begin_borrow [[FN]] |
| 88 | +// CHECK-NEXT: [[FN_ISOLATION:%.*]] = function_extract_isolation [[BORROWED_FN]] |
| 89 | +// CHECK-NEXT: hop_to_executor [[FN_ISOLATION]] |
| 90 | +// CHECK-NEXT: [[BORROWED_FN:%.*]] = begin_borrow [[FN]] |
| 91 | +// CHECK-NEXT: apply [[BORROWED_FN]]() |
| 92 | +// CHECK: hop_to_executor [[ISOLATION]] |
| 93 | +// CHECK: } // end sil function '$s14execution_attr38testCallerIsolatedWithDynamicIsolation2fnyyyYAXE_tYaF' |
| 94 | +nonisolated(nonsending) |
| 95 | +func testCallerIsolatedWithDynamicIsolation(fn: @isolated(any) () -> Void) async { |
| 96 | + await fn() |
| 97 | +} |
0 commit comments