Files
swift-mirror/test/SIL/Serialization/actor_isolation_crossing.sil
Michael Gottesman f328e7893b [region-isolation] Add support for representing ApplyIsolationCrossing at the SIL level on apply, begin_apply, try_apply.
Some notes:

This is not emitted by SILGen. This is just intended to be used so I can write
SIL test cases for transfer non sendable. I did this by adding an
ActorIsolationCrossing field to all FullApplySites rather than adding it into
the type system on a callee. The reason that this makes sense from a modeling
perspective is that an actor isolation crossing is a caller concept since it is
describing a difference in between the caller's and callee's isolation. As a
bonus it makes this a less viral change.

For simplicity, I made it so that the isolation is represented as an optional
modifier on the instructions:

  apply [callee_isolation=XXXX] [caller_isolation=XXXX]

where XXXX is a printed representation of the actor isolation.

When neither callee or caller isolation is specified then the
ApplyIsolationCrossing is std::nullopt. If only one is specified, we make the
other one ActorIsolation::Unspecified.

This required me to move ActorIsolationCrossing from AST/Expr.h ->
AST/ActorIsolation.h to work around compilation issues... Arguably that is where
it should exist anyways so it made sense.

rdar://118521597
2023-12-11 19:27:27 -06:00

59 lines
2.3 KiB
Plaintext

// First parse this and then emit a *.sib. Then read in the *.sib, then recreate
// RUN: %empty-directory(%t)
// RUN: %target-sil-opt %s -emit-sib -o %t/tmp.sib -module-name borrow
// RUN: %target-sil-opt %t/tmp.sib -o %t/tmp.2.sib -module-name borrow
// RUN: %target-sil-opt %t/tmp.2.sib -module-name borrow -emit-sorted-sil | %FileCheck %s
sil_stage canonical
sil @asyncCaller : $@async () -> () {
bb0:
%0 = tuple ()
return %0 : $()
}
// CHECK-LABEL: sil @asyncCallee1 : $@convention(thin) @async () -> () {
// CHECK: apply [callee_isolation=actor_instance] [caller_isolation=actor_instance] %0() : $@convention(thin) @async () -> ()
// CHECK: } // end sil function 'asyncCallee1'
sil @asyncCallee1 : $@convention(thin) @async () -> () {
bb0:
%0 = function_ref @asyncCaller : $@convention(thin) @async () -> ()
apply [callee_isolation=actor_instance] [caller_isolation=actor_instance] %0() : $@convention(thin) @async () -> ()
%9999 = tuple ()
return %9999 : $()
}
// CHECK-LABEL: sil @asyncCallee2 : $@convention(thin) @async () -> () {
// CHECK: apply [callee_isolation=actor_instance] %0() : $@convention(thin) @async () -> ()
// CHECK: } // end sil function 'asyncCallee2'
sil @asyncCallee2 : $@convention(thin) @async () -> () {
bb0:
%0 = function_ref @asyncCaller : $@convention(thin) @async () -> ()
apply [callee_isolation=actor_instance] %0() : $@convention(thin) @async () -> ()
%9999 = tuple ()
return %9999 : $()
}
// CHECK-LABEL: sil @asyncCallee3 : $@convention(thin) @async () -> () {
// CHECK: apply [caller_isolation=actor_instance] %0() : $@convention(thin) @async () -> ()
// CHECK: } // end sil function 'asyncCallee3'
sil @asyncCallee3 : $@convention(thin) @async () -> () {
bb0:
%0 = function_ref @asyncCaller : $@convention(thin) @async () -> ()
apply [caller_isolation=actor_instance] %0() : $@convention(thin) @async () -> ()
%9999 = tuple ()
return %9999 : $()
}
// CHECK-LABEL: sil @asyncCallee4 : $@convention(thin) @async () -> () {
// CHECK: apply [caller_isolation=global_actor] %0() : $@convention(thin) @async () -> ()
// CHECK: } // end sil function 'asyncCallee4'
sil @asyncCallee4 : $@convention(thin) @async () -> () {
bb0:
%0 = function_ref @asyncCaller : $@convention(thin) @async () -> ()
apply [caller_isolation=global_actor] %0() : $@convention(thin) @async () -> ()
%9999 = tuple ()
return %9999 : $()
}