@@ -90,7 +90,7 @@ public distributed actor MyOtherActor {
90
90
91
91
// CHECK: define hidden swifttailcc void @"$s27distributed_actor_accessors7MyActorC7simple1yySiFTE"
92
92
93
- // CHECK: define internal swifttailcc void @"$s27distributed_actor_accessors7MyActorC7simple1yySiFTETF"(%swift.context* swiftasync %0, i8* %1, i8* %2, %swift.refcounted* swiftself %3)
93
+ // CHECK: define internal swifttailcc void @"$s27distributed_actor_accessors7MyActorC7simple1yySiFTETF"(%swift.context* swiftasync %0, i8* %1, i8* %2, %T27distributed_actor_accessors7MyActorC* %3)
94
94
95
95
/// Read the current offset and cast an element to `Int`
96
96
@@ -100,16 +100,20 @@ public distributed actor MyOtherActor {
100
100
// CHECK-NEXT: [[NATIVE_VAL_LOC:%.*]] = getelementptr inbounds %TSi, %TSi* [[ELT_PTR]], i32 0, i32 0
101
101
// CHECK-NEXT: [[ARG_VAL:%.*]] = load i32, i32* [[NATIVE_VAL_LOC]]
102
102
103
- /// Retrieve an async pointer to the distributed thunk for `simple1`
103
+ /// Setup task context for async call to `simple1` thunk
104
104
105
- // CHECK: [[THUNK_LOC :%.*]] = add i32 ptrtoint (void (%swift.context*, i32, %T27distributed_actor_accessors7MyActorC*)* @"$s27distributed_actor_accessors7MyActorC7simple1yySiFTE" to i32), {{.*}}
106
- // CHECK-NEXT: [[OPAQUE_THUNK_PTR :%.*]] = inttoptr i32 [[THUNK_LOC]] to i8*
107
- // CHECK-NEXT : [[THUNK_PTR :%.*]] = bitcast i8* [[OPAQUE_THUNK_PTR ]] to void ( %swift.context*, i32, %T27distributed_actor_accessors7MyActorC*) *
105
+ // CHECK: [[CONTEXT_SIZE :%.*]] = load i32, i32* getelementptr inbounds (%swift.async_func_pointer, %swift.async_func_pointer* @"$s27distributed_actor_accessors7MyActorC7simple1yySiFTETu", i32 0, i32 1)
106
+ // CHECK-NEXT: [[THUNK_ASYNC_CONTEXT :%.*]] = call swiftcc i8* @swift_task_alloc( i32 [[CONTEXT_SIZE]])
107
+ // CHECK: [[THUNK_CONTEXT_PTR :%.*]] = bitcast i8* [[THUNK_ASYNC_CONTEXT ]] to %swift.context*
108
108
109
109
/// Call distributed thunk for `simple1` and `end` async context without results
110
110
111
- // CHECK: [[THUNK_PTR_REF:%.*]] = bitcast void (%swift.context*, i32, %T27distributed_actor_accessors7MyActorC*)* [[THUNK_PTR]] to i8*
112
- // CHECK-NEXT: [[THUNK_RESULT:%.*]] = call { i8*, %swift.error* } (i32, i8*, i8*, ...) @llvm.coro.suspend.async.sl_p0i8p0s_swift.errorss({{.*}}, i8* [[THUNK_PTR_REF]], %swift.context* {{.*}}, i32 [[ARG_VAL]], %T27distributed_actor_accessors7MyActorC* {{.*}})
111
+ // CHECK: [[THUNK_RESULT:%.*]] = call { i8*, %swift.error* } (i32, i8*, i8*, ...) @llvm.coro.suspend.async.sl_p0i8p0s_swift.errorss(
112
+ // CHECK-SAME: i8* bitcast (void (%swift.context*, i32, %T27distributed_actor_accessors7MyActorC*)* @"$s27distributed_actor_accessors7MyActorC7simple1yySiFTE" to i8*)
113
+ // CHECK-SAME: %swift.context* [[THUNK_CONTEXT_PTR]],
114
+ // CHECK-SAME: i32 [[ARG_VAL]],
115
+ // CHECK-SAME: %T27distributed_actor_accessors7MyActorC* %3)
116
+
113
117
// CHECK-NEXT: [[TASK_REF:%.*]] = extractvalue { i8*, %swift.error* } [[THUNK_RESULT]], 0
114
118
// CHECK-NEXT: {{.*}} = call i8* @__swift_async_resume_project_context(i8* [[TASK_REF]])
115
119
// CHECK: {{.*}} = call i1 (i8*, i1, ...) @llvm.coro.end.async({{.*}}, %swift.context* {{.*}}, %swift.error* {{.*}})
@@ -125,16 +129,20 @@ public distributed actor MyOtherActor {
125
129
/// !!! - We are not going to double-check argument extraction here since it's the same as `simple1`.
126
130
// CHECK: [[NATIVE_ARG_VAL:%.*]] = load i32, i32* {{.*}}
127
131
128
- /// Load async pointer to distributed thunk for `simple2`
132
+ /// Setup task context for async call to `simple2` thunk
129
133
130
- // CHECK: [[THUNK_LOC :%.*]] = add i32 ptrtoint (void (%swift.context*, i32, %T27distributed_actor_accessors7MyActorC*)* @"$s27distributed_actor_accessors7MyActorC7simple2ySSSiFTE" to i32), {{.*}}
131
- // CHECK-NEXT: [[OPAQUE_THUNK_PTR :%.*]] = inttoptr i32 [[THUNK_LOC]] to i8*
132
- // CHECK-NEXT : [[THUNK_PTR :%.*]] = bitcast i8* [[OPAQUE_THUNK_PTR ]] to void ( %swift.context*, i32, %T27distributed_actor_accessors7MyActorC*) *
134
+ // CHECK: [[CONTEXT_SIZE :%.*]] = load i32, i32* getelementptr inbounds (%swift.async_func_pointer, %swift.async_func_pointer* @"$s27distributed_actor_accessors7MyActorC7simple2ySSSiFTETu", i32 0, i32 1)
135
+ // CHECK-NEXT: [[THUNK_ASYNC_CONTEXT :%.*]] = call swiftcc i8* @swift_task_alloc( i32 [[CONTEXT_SIZE]])
136
+ // CHECK: [[THUNK_CONTEXT_PTR :%.*]] = bitcast i8* [[THUNK_ASYNC_CONTEXT ]] to %swift.context*
133
137
134
138
/// Call the thunk with extracted argument value
135
139
136
- // CHECK: [[THUNK_PTR_REF:%.*]] = bitcast void (%swift.context*, i32, %T27distributed_actor_accessors7MyActorC*)* [[THUNK_PTR]] to i8*
137
- // CHECK-NEXT: [[THUNK_RESULT:%.*]] = call { i8*, i32, i32, i32, %swift.error* } (i32, i8*, i8*, ...) @llvm.coro.suspend.async.sl_p0i8i32i32i32p0s_swift.errorss({{.*}}, i8* [[THUNK_PTR_REF]], %swift.context* {{.*}}, i32 [[NATIVE_ARG_VAL]], %T27distributed_actor_accessors7MyActorC* {{.*}})
140
+ // CHECK: [[THUNK_RESULT:%.*]] = call { i8*, i32, i32, i32, %swift.error* } (i32, i8*, i8*, ...) @llvm.coro.suspend.async.sl_p0i8i32i32i32p0s_swift.errorss(
141
+ // CHECK-SAME: i8* bitcast (void (%swift.context*, i32, %T27distributed_actor_accessors7MyActorC*)* @"$s27distributed_actor_accessors7MyActorC7simple2ySSSiFTE" to i8*)
142
+ // CHECK-SAME: %swift.context* [[THUNK_CONTEXT_PTR]],
143
+ // CHECK-SAME: i32 [[NATIVE_ARG_VAL]],
144
+ // CHECK-SAME: %T27distributed_actor_accessors7MyActorC* %3)
145
+
138
146
// CHECK-NEXT: [[TASK_REF:%.*]] = extractvalue { i8*, i32, i32, i32, %swift.error* } [[THUNK_RESULT]], 0
139
147
// CHECK-NEXT: {{.*}} = call i8* @__swift_async_resume_project_context(i8* [[TASK_REF]])
140
148
@@ -152,7 +160,7 @@ public distributed actor MyOtherActor {
152
160
// CHECK: define hidden swifttailcc void @"$s27distributed_actor_accessors7MyActorC7simple3ySiSSFTE"
153
161
154
162
/// !!! in `simple3` interesting bits are: argument value extraction (because string is exploded into N arguments) and call to distributed thunk
155
- // CHECK: define internal swifttailcc void @"$s27distributed_actor_accessors7MyActorC7simple3ySiSSFTETF"(%swift.context* swiftasync {{.*}}, i8* [[ARG_BUFF:%.*]], i8* [[RESULT_BUFF:%.*]], %swift.refcounted* swiftself {{.*}})
163
+ // CHECK: define internal swifttailcc void @"$s27distributed_actor_accessors7MyActorC7simple3ySiSSFTETF"(%swift.context* swiftasync {{.*}}, i8* [[ARG_BUFF:%.*]], i8* [[RESULT_BUFF:%.*]], %T27distributed_actor_accessors7MyActorC* {{.*}})
156
164
157
165
// CHECK: [[TYPED_RESULT_BUFF:%.*]] = bitcast i8* [[RESULT_BUFF]] to %TSi*
158
166
@@ -164,17 +172,17 @@ public distributed actor MyOtherActor {
164
172
// CHECK-NEXT: [[NATIVE_STR_VAL_PTR:%.*]] = bitcast %Ts13_StringObjectV7VariantO* %._guts._object._variant to i32*
165
173
// CHECK-NEXT: [[STR_VAL:%.*]] = load i32, i32* [[NATIVE_STR_VAL_PTR]]
166
174
167
- /// Load pointer to a distributed thunk for `simple3`
175
+ /// Setup task context for async call to `simple3` thunk
168
176
169
- // CHECK: [[THUNK_LOC:%.*]] = add i32 ptrtoint (void (%swift.context*, i32, i32, i32, %T27distributed_actor_accessors7MyActorC*)* @"$s27distributed_actor_accessors7MyActorC7simple3ySiSSFTE" to i32)
170
- // CHECK-NEXT: [[OPAQUE_THUNK_PTR:%.*]] = inttoptr i32 [[THUNK_LOC]] to i8*
171
- // CHECK-NEXT: [[THUNK_PTR:%.*]] = bitcast i8* [[OPAQUE_THUNK_PTR]] to void (%swift.context*, i32, i32, i32, %T27distributed_actor_accessors7MyActorC*)*
177
+ // CHECK: [[CONTEXT_SIZE:%.*]] = load i32, i32* getelementptr inbounds (%swift.async_func_pointer, %swift.async_func_pointer* @"$s27distributed_actor_accessors7MyActorC7simple3ySiSSFTETu", i32 0, i32 1)
178
+ // CHECK-NEXT: [[THUNK_ASYNC_CONTEXT:%.*]] = call swiftcc i8* @swift_task_alloc(i32 [[CONTEXT_SIZE]])
172
179
173
180
// CHECK: [[TMP_STR_ARG:%.*]] = bitcast { i32, i32, i32 }* %temp-coercion.coerced to %TSS*
174
181
// CHECK-NEXT: %._guts1 = getelementptr inbounds %TSS, %TSS* [[TMP_STR_ARG]], i32 0, i32 0
175
182
176
183
// CHECK: store i32 %10, i32* %._guts1._object._count._value, align 4
177
- // CHECK: store i32 %12, i32* %28, align 4
184
+ // CHECK: [[VARIANT:%.*]] = bitcast %Ts13_StringObjectV7VariantO* %._guts1._object._variant to i32*
185
+ // CHECK-NEXT: store i32 %12, i32* [[VARIANT]], align 4
178
186
179
187
// CHECK: [[STR_ARG_SIZE_PTR:%.*]] = getelementptr inbounds { i32, i32, i32 }, { i32, i32, i32 }* %temp-coercion.coerced, i32 0, i32 0
180
188
// CHECK: [[STR_ARG_SIZE:%.*]] = load i32, i32* [[STR_ARG_SIZE_PTR]]
@@ -187,8 +195,16 @@ public distributed actor MyOtherActor {
187
195
188
196
/// Call distributed thunk with exploaded string value
189
197
190
- // CHECK: [[OPAQUE_THUNK_PTR:%.*]] = bitcast void (%swift.context*, i32, i32, i32, %T27distributed_actor_accessors7MyActorC*)* [[THUNK_PTR]] to i8*
191
- // CHECK-NEXT: [[THUNK_RESULT:%.*]] = call { i8*, i32, %swift.error* } (i32, i8*, i8*, ...) @llvm.coro.suspend.async.sl_p0i8i32p0s_swift.errorss({{.*}}, i8* [[OPAQUE_THUNK_PTR]], %swift.context* {{.*}}, i32 [[STR_ARG_SIZE]], i32 [[STR_ARG_VAL]], i32 [[STR_ARG_FLAGS]], %T27distributed_actor_accessors7MyActorC* {{.*}})
198
+ // CHECK: [[THUNK_CONTEXT_PTR:%.*]] = bitcast i8* [[THUNK_ASYNC_CONTEXT]] to %swift.context*
199
+
200
+ // CHECK: [[THUNK_RESULT:%.*]] = call { i8*, i32, %swift.error* } (i32, i8*, i8*, ...) @llvm.coro.suspend.async.sl_p0i8i32p0s_swift.errorss(
201
+ // CHECK-SAME: i8* bitcast (void (%swift.context*, i32, i32, i32, %T27distributed_actor_accessors7MyActorC*)* @"$s27distributed_actor_accessors7MyActorC7simple3ySiSSFTE" to i8*),
202
+ // CHECK-SAME: %swift.context* [[THUNK_CONTEXT_PTR]],
203
+ // CHECK-SAME: i32 [[STR_ARG_SIZE]],
204
+ // CHECK-SAME: i32 [[STR_ARG_VAL]],
205
+ // CHECK_SAME: i32 [[STR_ARG_FLAGS]],
206
+ // CHECK-SAME: %T27distributed_actor_accessors7MyActorC* %3)
207
+
192
208
// CHECK-NEXT: [[TASK_REF:%.*]] = extractvalue { i8*, i32, %swift.error* } [[THUNK_RESULT]], 0
193
209
// CHECK-NEXT: {{.*}} = call i8* @__swift_async_resume_project_context(i8* [[TASK_REF]])
194
210
// CHECK: [[INT_RES:%.*]] = extractvalue { i8*, i32, %swift.error* } [[THUNK_RESULT]], 1
@@ -200,7 +216,7 @@ public distributed actor MyOtherActor {
200
216
201
217
// CHECK: define hidden swifttailcc void @"$s27distributed_actor_accessors7MyActorC16single_case_enumyAA7SimpleEOAFFTE"
202
218
203
- // CHECK: define internal swifttailcc void @"$s27distributed_actor_accessors7MyActorC16single_case_enumyAA7SimpleEOAFFTETF"(%swift.context* swiftasync %0, i8* [[BUFFER:%.*]], i8* [[RESULT_BUFF:%.*]], %swift.refcounted* swiftself {{.*}})
219
+ // CHECK: define internal swifttailcc void @"$s27distributed_actor_accessors7MyActorC16single_case_enumyAA7SimpleEOAFFTETF"(%swift.context* swiftasync %0, i8* [[BUFFER:%.*]], i8* [[RESULT_BUFF:%.*]], %T27distributed_actor_accessors7MyActorC* {{.*}})
204
220
205
221
/// First, let's check that there were no loads from the argument buffer and no stores to "current offset".
206
222
@@ -256,7 +272,7 @@ public distributed actor MyOtherActor {
256
272
257
273
// CHECK: define hidden swifttailcc void @"$s27distributed_actor_accessors7MyActorC7complexyAA11LargeStructVSaySiG_AA3ObjCSSSgAFtFTE"
258
274
259
- // CHECK: define internal swifttailcc void @"$s27distributed_actor_accessors7MyActorC7complexyAA11LargeStructVSaySiG_AA3ObjCSSSgAFtFTETF"(%swift.context* swiftasync {{.*}}, i8* [[ARG_BUFF:%.*]], i8* [[RESULT_BUFF:%.*]], %swift.refcounted* swiftself {{.*}})
275
+ // CHECK: define internal swifttailcc void @"$s27distributed_actor_accessors7MyActorC7complexyAA11LargeStructVSaySiG_AA3ObjCSSSgAFtFTETF"(%swift.context* swiftasync {{.*}}, i8* [[ARG_BUFF:%.*]], i8* [[RESULT_BUFF:%.*]], %T27distributed_actor_accessors7MyActorC* {{.*}})
260
276
261
277
/// First, let's check that all of the different argument types here are loaded correctly.
262
278
@@ -324,7 +340,7 @@ public distributed actor MyOtherActor {
324
340
325
341
/// Let's check that there is no offset allocation here since parameter list is empty
326
342
327
- // CHECK: define internal swifttailcc void @"$s27distributed_actor_accessors12MyOtherActorC5emptyyyFTETF"(%swift.context* swiftasync {{.*}}, i8* [[ARG_BUFF:%.*]], i8* [[RESULT_BUFF:%.*]], %swift.refcounted* swiftself {{.*}})
343
+ // CHECK: define internal swifttailcc void @"$s27distributed_actor_accessors12MyOtherActorC5emptyyyFTETF"(%swift.context* swiftasync {{.*}}, i8* [[ARG_BUFF:%.*]], i8* [[RESULT_BUFF:%.*]], %T27distributed_actor_accessors12MyOtherActorC* {{.*}})
328
344
// CHECK-NEXT: entry:
329
345
// CHECK-NEXT: {{.*}} = alloca %swift.context*
330
346
// CHECK-NEXT: %swifterror = alloca %swift.error*
@@ -333,4 +349,4 @@ public distributed actor MyOtherActor {
333
349
// CHECK-NEXT: store %swift.context* {{.*}}, %swift.context** {{.*}}
334
350
// CHECK-NEXT: store %swift.error* null, %swift.error** %swifterror
335
351
// CHECK-NEXT: {{.*}} = bitcast i8* [[RESULT_BUFF]] to %swift.opaque*
336
- // CHECK-NEXT: {{.*}} = load i32, i32* getelementptr inbounds (%swift.async_func_pointer, %swift.async_func_pointer* bitcast (void (%swift.context*, %T27distributed_actor_accessors12MyOtherActorC*)* @"$s27distributed_actor_accessors12MyOtherActorC5emptyyyFTE" to %swift.async_func_pointer*) , i32 0, i32 0 )
352
+ // CHECK-NEXT: {{.*}} = load i32, i32* getelementptr inbounds (%swift.async_func_pointer, %swift.async_func_pointer* @"$s27distributed_actor_accessors12MyOtherActorC5emptyyyFTETu" , i32 0, i32 1 )
0 commit comments