@@ -63,6 +63,7 @@ sil @useRawPointer : $@convention(thin) (Builtin.RawPointer) -> ()
63
63
sil @initRawPointer : $@convention(thin) () -> Builtin.RawPointer
64
64
65
65
sil @transferIndirect : $@convention(thin) @async <τ_0_0> (@in_guaranteed τ_0_0) -> ()
66
+ sil @transferIndirectWithOutResult : $@convention(thin) @async <τ_0_0> (@in_guaranteed τ_0_0) -> @out τ_0_0
66
67
sil @useIndirect : $@convention(thin) <τ_0_0> (@in_guaranteed τ_0_0) -> ()
67
68
sil @initIndirect : $@convention(thin) <T> () -> @out T
68
69
sil @initIndirectTransferring : $@convention(thin) @async <T> () -> @out T
@@ -92,3 +93,55 @@ bb0(%0 : $*{ var NonSendableKlass }):
92
93
%9999 = tuple ()
93
94
return %9999 : $()
94
95
}
96
+
97
+ // This doesn't error since the @out parameter is not transferred when it is initialized.
98
+ //
99
+ // DISCUSSION: The frontend prevents us from using such a value. But we
100
+ // shouldn't crash on such values.
101
+ sil [ossa] @transfer_does_not_transfer_out_parameters_1 : $@convention(thin) @async () -> () {
102
+ bb0:
103
+ %0 = alloc_stack $NonSendableKlass
104
+ %init = function_ref @initIndirect : $@convention(thin) <T> () -> @out T
105
+ apply %init<NonSendableKlass>(%0) : $@convention(thin) <T> () -> @out T
106
+
107
+ %1 = alloc_stack $NonSendableKlass
108
+ %f = function_ref @transferIndirectWithOutResult : $@convention(thin) @async <τ_0_0> (@in_guaranteed τ_0_0) -> @out τ_0_0
109
+ apply [caller_isolation=nonisolated] [callee_isolation=global_actor] %f<NonSendableKlass>(%1, %0) : $@convention(thin) @async <τ_0_0> (@in_guaranteed τ_0_0) -> @out τ_0_0
110
+
111
+ %useIndirect = function_ref @useIndirect : $@convention(thin) <τ_0_0> (@in_guaranteed τ_0_0) -> ()
112
+ apply %useIndirect<NonSendableKlass>(%1) : $@convention(thin) <τ_0_0> (@in_guaranteed τ_0_0) -> ()
113
+
114
+ destroy_addr %1 : $*NonSendableKlass
115
+ dealloc_stack %1 : $*NonSendableKlass
116
+ destroy_addr %0 : $*NonSendableKlass
117
+ dealloc_stack %0 : $*NonSendableKlass
118
+
119
+ %9999 = tuple ()
120
+ return %9999 : $()
121
+ }
122
+
123
+ sil [ossa] @transfer_does_not_transfer_out_parameters_2 : $@convention(thin) @async () -> () {
124
+ bb0:
125
+ %0 = alloc_stack $NonSendableKlass
126
+ %init = function_ref @initIndirect : $@convention(thin) <T> () -> @out T
127
+ apply %init<NonSendableKlass>(%0) : $@convention(thin) <T> () -> @out T
128
+
129
+ %1 = alloc_stack $NonSendableKlass
130
+ %f = function_ref @transferIndirectWithOutResult : $@convention(thin) @async <τ_0_0> (@in_guaranteed τ_0_0) -> @out τ_0_0
131
+ apply [caller_isolation=nonisolated] [callee_isolation=global_actor] %f<NonSendableKlass>(%1, %0) : $@convention(thin) @async <τ_0_0> (@in_guaranteed τ_0_0) -> @out τ_0_0
132
+
133
+ %f2 = function_ref @transferIndirect : $@convention(thin) @async <τ_0_0> (@in_guaranteed τ_0_0) -> ()
134
+ apply [caller_isolation=nonisolated] [callee_isolation=global_actor] %f2<NonSendableKlass>(%1) : $@convention(thin) @async <τ_0_0> (@in_guaranteed τ_0_0) -> ()
135
+ // expected-warning @-1 {{transferring value of non-Sendable type 'NonSendableKlass' from nonisolated context to global actor '<null>'-isolated context}}
136
+ %useIndirect = function_ref @useIndirect : $@convention(thin) <τ_0_0> (@in_guaranteed τ_0_0) -> ()
137
+ apply %useIndirect<NonSendableKlass>(%1) : $@convention(thin) <τ_0_0> (@in_guaranteed τ_0_0) -> ()
138
+ // expected-note @-1 {{access here could race}}
139
+
140
+ destroy_addr %1 : $*NonSendableKlass
141
+ dealloc_stack %1 : $*NonSendableKlass
142
+ destroy_addr %0 : $*NonSendableKlass
143
+ dealloc_stack %0 : $*NonSendableKlass
144
+
145
+ %9999 = tuple ()
146
+ return %9999 : $()
147
+ }
0 commit comments