@@ -22,82 +22,76 @@ distributed actor MyDistActor {
22
22
23
23
// MARK: distributed actor check
24
24
25
- // This test checks that we resign the identity for local deallocations,
26
- // destroy only the correct stored properties whether remote or local, and also
27
- // destroy the executor.
28
-
29
- // CHECK-LABEL: sil hidden{{.*}} @$s14default_deinit11MyDistActorCfd : $@convention(method) (@guaranteed MyDistActor) -> @owned Builtin.NativeObject {
25
+ // ===== -----------------------------------------------------------------------
26
+ // CHECK-LABEL: sil hidden @$s14default_deinit11MyDistActorCfd : $@convention(method) (@guaranteed MyDistActor) -> @owned Builtin.NativeObject {
30
27
// CHECK: bb0([[SELF:%[0-9]+]] : $MyDistActor):
31
- // CHECK: [[EXI_SELF:%[0-9]+]] = init_existential_ref [[SELF]] : $MyDistActor
32
- // CHECK: [[IS_REMOTE_FN:%[0-9]+]] = function_ref @swift_distributed_actor_is_remote
33
- // CHECK: [[IS_REMOTE:%[0-9]+]] = apply [[IS_REMOTE_FN]]([[EXI_SELF]])
34
- // CHECK: [[RAW_BOOL:%[0-9]+]] = struct_extract [[IS_REMOTE]] : $Bool, #Bool._value
35
- // CHECK: cond_br [[RAW_BOOL]], [[REMOTE_BB:bb[0-9]+]], [[LOCAL_BB:bb[0-9]+]]
36
-
37
- // *** If local... invoke system.resignID()
38
- // CHECK: [[LOCAL_BB]]:
39
- // CHECK: [[ID_REF:%[0-9]+]] = ref_element_addr [[SELF]] : $MyDistActor, #MyDistActor.id
40
- // CHECK: [[SYS_REF:%[0-9]+]] = ref_element_addr [[SELF]] : $MyDistActor, #MyDistActor.actorSystem
41
- // CHECK: [[ID_LOAD:%[0-9]+]] = load [[ID_REF]] : $*ActorAddress
42
- // CHECK: [[SYS_LOAD:%[0-9]+]] = load [[SYS_REF]] : $*FakeActorSystem
43
- // CHECK: [[RESIGN:%[0-9]+]] = function_ref @$s27FakeDistributedActorSystems0aC6SystemV8resignIDyyAA0C7AddressVF : $@convention(method) (@guaranteed ActorAddress, @guaranteed FakeActorSystem) -> ()
44
- // CHECK: apply [[RESIGN]]([[ID_LOAD]], [[SYS_LOAD]])
45
- // CHECK: br [[CONTINUE:bb[0-9]+]]
46
-
47
- // *** If remote...
48
- // CHECK: [[REMOTE_BB]]:
49
- // CHECK: br [[CONTINUE]]
50
-
51
- // Now we deallocate stored properties, and how we do that depends again on
52
- // being remote or local. Default code emission does another is_remote test,
53
- // so we check for that here and leave tail-merging to the optimizer, for now.
54
- // CHECK: [[CONTINUE]]:
55
- // *** this is entirely copy-pasted from the first check in bb0 ***
56
- // CHECK: [[EXI_SELF:%[0-9]+]] = init_existential_ref [[SELF]] : $MyDistActor
57
- // CHECK: [[IS_REMOTE_FN:%[0-9]+]] = function_ref @swift_distributed_actor_is_remote
58
- // CHECK: [[IS_REMOTE:%[0-9]+]] = apply [[IS_REMOTE_FN]]([[EXI_SELF]])
59
- // CHECK: [[RAW_BOOL:%[0-9]+]] = struct_extract [[IS_REMOTE]] : $Bool, #Bool._value
60
- // CHECK: cond_br [[RAW_BOOL]], [[REMOTE_BB_DEALLOC:bb[0-9]+]], [[LOCAL_BB_DEALLOC:bb[0-9]+]]
61
-
62
- // *** only destroy the id and system if remote ***
63
- // CHECK: [[REMOTE_BB_DEALLOC]]:
64
- // *** destroy identity ***
65
- // CHECK: [[REF:%[0-9]+]] = ref_element_addr [[SELF]] : $MyDistActor, #MyDistActor.id
66
- // CHECK: [[ACCESS:%[0-9]+]] = begin_access [deinit] [static] [[REF]]
67
- // CHECK: destroy_addr [[ACCESS]] : $*ActorAddress
68
- // CHECK: end_access [[ACCESS]]
69
- // *** destroy system ***
70
- // CHECK: [[REF:%[0-9]+]] = ref_element_addr [[SELF]] : $MyDistActor, #MyDistActor.actorSystem
71
- // CHECK: [[ACCESS:%[0-9]+]] = begin_access [deinit] [static] [[REF]]
72
- // CHECK: destroy_addr [[ACCESS]] : $*FakeActorSystem
73
- // CHECK: end_access [[ACCESS]]
74
- // CHECK: br [[AFTER_DEALLOC:bb[0-9]+]]
75
-
76
- // *** destroy everything if local ***
77
- // CHECK: [[LOCAL_BB_DEALLOC]]:
78
- // *** destroy identity ***
79
- // CHECK: [[REF:%[0-9]+]] = ref_element_addr [[SELF]] : $MyDistActor, #MyDistActor.id
80
- // CHECK: [[ACCESS:%[0-9]+]] = begin_access [deinit] [static] [[REF]]
81
- // CHECK: destroy_addr [[ACCESS]] : $*ActorAddress
82
- // CHECK: end_access [[ACCESS]]
83
- // *** destroy system ***
84
- // SKIP: [[REF:%[0-9]+]] = ref_element_addr [[SELF]] : $MyDistActor, #MyDistActor.actorSystem
85
- // SKIP: [[ACCESS:%[0-9]+]] = begin_access [deinit] [static] [[REF]]
86
- // SKIP: destroy_addr [[ACCESS]] : $*FakeActorSystem
87
- // SKIP: end_access [[ACCESS]]
88
- // *** destroy the user-defined field ***
89
- // CHECK: [[REF:%[0-9]+]] = ref_element_addr [[SELF]] : $MyDistActor, #MyDistActor.localOnlyField
90
- // CHECK: [[ACCESS:%[0-9]+]] = begin_access [deinit] [static] [[REF]]
91
- // CHECK: destroy_addr [[ACCESS]] : $*SomeClass
92
- // CHECK: end_access [[ACCESS]]
93
- // CHECK: br [[AFTER_DEALLOC]]
28
+ // CHECK: [[EXI_SELF:%[0-9]+]] = init_existential_ref [[SELF]] : $MyDistActor : $MyDistActor, $AnyObject
29
+ // CHECK: [[IS_REMOTE_FN:%[0-9]+]] = function_ref @swift_distributed_actor_is_remote : $@convention(thin) (@guaranteed AnyObject) -> Bool
30
+ // CHECK: [[IS_REMOTE:%[0-9]+]] = apply [[IS_REMOTE_FN]]([[EXI_SELF]])
31
+ // CHECK: [[RAW_BOOL:%[0-9]+]] = struct_extract [[IS_REMOTE]] : $Bool, #Bool._value
32
+ // CHECK: cond_br [[RAW_BOOL]], [[REMOTE_ACTOR_DEINIT_BB:bb[0-9]+]], [[DEINIT_BODY_BB:bb[0-9]+]]
33
+
34
+ // ===== -----------------------------------------------------------------------
35
+ // CHECK: // deinitBodyBB
36
+ // CHECK: [[DEINIT_BODY_BB]]:
37
+
38
+ // Resign the ID by calling actorSystem.resignID, before we destroy properties:
39
+ // CHECK: [[ID_REF:%[0-9]+]] = ref_element_addr [[SELF]] : $MyDistActor, #MyDistActor.id
40
+ // CHECK: [[SYS_REF:%[0-9]+]] = ref_element_addr [[SELF]] : $MyDistActor, #MyDistActor.actorSystem
41
+ // CHECK: [[ID_LOAD:%[0-9]+]] = load [[ID_REF]] : $*ActorAddress
42
+ // CHECK: [[SYS_LOAD:%[0-9]+]] = load [[SYS_REF]] : $*FakeActorSystem
43
+ // CHECK: [[FN_REF:%[0-9]+]] = function_ref @$s27FakeDistributedActorSystems0aC6SystemV8resignIDyyAA0C7AddressVF : $@convention(method) (@guaranteed ActorAddress, @guaranteed FakeActorSystem) -> ()
44
+ // CHECK: [[DROP:%[0-9]+]] = apply [[FN_REF]]([[ID_LOAD]], [[SYS_LOAD]]) : $@convention(method) (@guaranteed ActorAddress, @guaranteed FakeActorSystem) -> ()
45
+ // CHECK: [[DROP:%[0-9]+]] = tuple ()
46
+
47
+ // Destroy implicit Distributed Actor field: id
48
+ // CHECK: [[REF:%[0-9]+]] = ref_element_addr [[SELF]] : $MyDistActor, #MyDistActor.id
49
+ // CHECK: [[ACCESS:%[0-9]+]] = begin_access [deinit] [static] [[REF]] : $*ActorAddress
50
+ // CHECK: destroy_addr [[ACCESS]] : $*ActorAddress
51
+ // CHECK: end_access [[ACCESS]] : $*ActorAddress
52
+
53
+ // Destroy implicit Distributed Actor field: actorSystem
54
+ // CHECK: [[REF:%[0-9]+]] = ref_element_addr [[SELF]] : $MyDistActor, #MyDistActor.actorSystem
55
+ // CHECK: [[ACCESS:%[0-9]+]] = begin_access [deinit] [static] [[REF]] : $*FakeActorSystem
56
+ // CHECK: destroy_addr [[ACCESS]] : $*FakeActorSystem
57
+ // CHECK: end_access [[ACCESS]] : $*FakeActorSystem
58
+
59
+ // Destroy local fields:
60
+ // CHECK: [[REF:%[0-9]+]] = ref_element_addr [[SELF]] : $MyDistActor, #MyDistActor.localOnlyField
61
+ // CHECK: [[ACCESS:%[0-9]+]] = begin_access [deinit] [static] [[REF]] : $*SomeClass
62
+ // CHECK: destroy_addr [[ACCESS]] : $*SomeClass
63
+ // CHECK: end_access [[ACCESS]] : $*SomeClass
64
+ // CHECK: br [[FINISH_DEINIT_BB:bb[0-9]+]]
65
+
66
+ // ===== -----------------------------------------------------------------------
67
+ // CHECK: // finishDeinitBB
68
+ // CHECK: [[FINISH_DEINIT_BB]]:
69
+ // CHECK: [[BUILTIN:%[0-9]+]] = builtin "destroyDefaultActor"([[SELF]] : $MyDistActor) : $()
70
+ // CHECK: [[CAST:%[0-9]+]] = unchecked_ref_cast [[SELF]] : $MyDistActor to $Builtin.NativeObject
71
+ // CHECK: return [[CAST]] : $Builtin.NativeObject
72
+
73
+ // ===== -----------------------------------------------------------------------
74
+ // CHECK: // remoteActorDeinitBB
75
+ // CHECK: [[REMOTE_ACTOR_DEINIT_BB]]:
76
+
77
+ // Even just the remote deinit branch must destroy the ID
78
+ // CHECK: [[REF:%[0-9]+]] = ref_element_addr [[SELF]] : $MyDistActor, #MyDistActor.id
79
+ // CHECK: [[ACCESS:%[0-9]+]] = begin_access [deinit] [static] [[REF]] : $*ActorAddress
80
+ // CHECK: destroy_addr [[ACCESS]] : $*ActorAddress
81
+ // CHECK: end_access [[ACCESS]] : $*ActorAddress
82
+
83
+ // As well as the actor system:
84
+ // CHECK: [[REF:%[0-9]+]] = ref_element_addr [[SELF]] : $MyDistActor, #MyDistActor.actorSystem
85
+ // CHECK: [[ACCESS:%[0-9]+]] = begin_access [deinit] [static] [[REF]] : $*FakeActorSystem
86
+ // CHECK: destroy_addr [[ACCESS]] : $*FakeActorSystem
87
+ // CHECK: end_access [[ACCESS]] : $*FakeActorSystem
88
+ // CHECK: br [[FINISH_DEINIT_BB]]
94
89
95
- // CHECK: [[AFTER_DEALLOC]]:
96
- // CHECK: builtin "destroyDefaultActor"([[SELF]] : $MyDistActor)
97
- // CHECK: [[CAST:%[0-9]+]] = unchecked_ref_cast [[SELF]]
98
- // CHECK: return [[CAST]] : $Builtin.NativeObject
99
90
// CHECK: } // end sil function '$s14default_deinit11MyDistActorCfd'
100
91
92
+ // This test checks that we resign the identity for local deallocations,
93
+ // destroy only the correct stored properties whether remote or local, and also
94
+ // destroy the executor.
101
95
102
96
// MARK: local actor check
103
97
@@ -111,7 +105,6 @@ actor SimpleActor {
111
105
112
106
// additionally, we add basic coverage for a non-distributed actor's deinit
113
107
114
-
115
108
// CHECK-LABEL: sil hidden{{.*}} @$s14default_deinit11SimpleActorCfd : $@convention(method) (@guaranteed SimpleActor) -> @owned Builtin.NativeObject {
116
109
// CHECK: bb0([[SELF:%[0-9]+]] : $SimpleActor):
117
110
// CHECK: [[REF:%[0-9]+]] = ref_element_addr [[SELF]] : $SimpleActor, #SimpleActor.someField
0 commit comments