Skip to content

Commit 7104cb1

Browse files
Merge pull request #36110 from aschwaighofer/irgen_adjust_to_async_suspend_context_index
Adjust to llvm change that requires suspend.async to specify the index of the async context
2 parents cd9887e + cb3703c commit 7104cb1

File tree

5 files changed

+7
-4
lines changed

5 files changed

+7
-4
lines changed

lib/IRGen/GenCall.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ llvm::CallInst *IRGenFunction::emitSuspendAsyncCall(ArrayRef<llvm::Value *> args
387387

388388
auto *calleeContext = Builder.CreateExtractValue(id,
389389
(unsigned)AsyncFunctionArgumentIndex::Context);
390-
llvm::Constant *projectFn = cast<llvm::Constant>(args[1])->stripPointerCasts();
390+
llvm::Constant *projectFn = cast<llvm::Constant>(args[2])->stripPointerCasts();
391391
// Get the caller context from the callee context.
392392
llvm::Value *context = Builder.CreateCall(projectFn, {calleeContext});
393393
context = Builder.CreateBitCast(context, IGM.SwiftContextPtrTy);
@@ -2548,6 +2548,7 @@ class AsyncCallEmission final : public CallEmission {
25482548
auto &Builder = IGF.Builder;
25492549
// Setup the suspend point.
25502550
SmallVector<llvm::Value *, 8> arguments;
2551+
arguments.push_back(IGM.getInt32(2)); // Index of swiftasync context.
25512552
arguments.push_back(currentResumeFn);
25522553
auto resumeProjFn = IGF.getOrCreateResumePrjFn();
25532554
arguments.push_back(

lib/IRGen/GenFunc.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2519,6 +2519,7 @@ void IRGenFunction::emitSuspensionPoint(llvm::Value *toExecutor,
25192519

25202520
// Setup the suspend point.
25212521
SmallVector<llvm::Value *, 8> arguments;
2522+
arguments.push_back(IGM.getInt32(2)); // swiftasync context index
25222523
arguments.push_back(asyncResume);
25232524
auto resumeProjFn = getOrCreateResumeFromSuspensionFn();
25242525
arguments.push_back(

lib/IRGen/IRGenFunction.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -687,6 +687,7 @@ void IRGenFunction::emitAwaitAsyncContinuation(
687687
{
688688
// Setup the suspend point.
689689
SmallVector<llvm::Value *, 8> arguments;
690+
arguments.push_back(IGM.getInt32(2)); // swiftasync context index
690691
arguments.push_back(AsyncCoroutineCurrentResume);
691692
auto resumeProjFn = getOrCreateResumePrjFn();
692693
arguments.push_back(

test/IRGen/async/get_async_continuation.sil

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ bb0:
8888
// CHECK: unreachable
8989

9090
// CHECK: await.async.maybe.resume:
91-
// CHECK: call { i8*, i8*, i8* } (i8*, i8*, ...) @llvm.coro.suspend.async{{.*}}({{.*}} @__swift_async_resume_project_context
91+
// CHECK: call { i8*, i8*, i8* } (i32, i8*, i8*, ...) @llvm.coro.suspend.async{{.*}}({{.*}} @__swift_async_resume_project_context
9292
// Abort if we are the first to arrive at the continuation point we must wait
9393
// on the await to arrive.
9494
// CHECK: [[first_at_sync_pt:%.*]] = cmpxchg {{(i64|i32)}}* [[synchronization_addr_before_await]], {{(i64|i32)}} 0, {{(i64|i32)}} 1 release acquire

test/IRGen/async/hop_to_executor.sil

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ final actor MyActor {
2626
// CHECK-arm64e: [[SIGNED_INT:%[0-9]+]] = call i64 @llvm.ptrauth.sign.i64(i64 [[RESUME_INT]], i32 0, i64 [[PTRAUTH_BLEND]])
2727
// CHECK-arm64e: [[SIGNED_RESUME:%[0-9]+]] = inttoptr i64 [[SIGNED_INT]] to i8*
2828
// CHECK: [[CAST_ACTOR:%[0-9]+]] = bitcast %T4test7MyActorC* [[ACTOR]] to %swift.executor*
29-
// CHECK-x86_64: call {{.*}} @llvm.coro.suspend.async{{.*}}(i8* [[RESUME]], i8* bitcast (i8* (i8*)* @__swift_async_resume_get_context to i8*), i8* bitcast (void (i8*, %swift.executor*, %swift.task*, %swift.executor*, %swift.context*)* @__swift_suspend_point to i8*), i8* [[RESUME]], %swift.executor* [[CAST_ACTOR]], %swift.task* [[TASK]], %swift.executor* {{%[0-9]+}}, %swift.context* {{%[0-9]+}})
30-
// CHECK-arm64e: call {{.*}} @llvm.coro.suspend.async{{.*}}(i8* [[RESUME]], i8* bitcast (i8* (i8*)* @__swift_async_resume_get_context to i8*), i8* bitcast (void (i8*, %swift.executor*, %swift.task*, %swift.executor*, %swift.context*)* @__swift_suspend_point to i8*), i8* [[SIGNED_RESUME]], %swift.executor* [[CAST_ACTOR]], %swift.task* [[TASK]], %swift.executor* {{%[0-9]+}}, %swift.context* {{%[0-9]+}})
29+
// CHECK-x86_64: call {{.*}} @llvm.coro.suspend.async{{.*}}(i32 2, i8* [[RESUME]], i8* bitcast (i8* (i8*)* @__swift_async_resume_get_context to i8*), i8* bitcast (void (i8*, %swift.executor*, %swift.task*, %swift.executor*, %swift.context*)* @__swift_suspend_point to i8*), i8* [[RESUME]], %swift.executor* [[CAST_ACTOR]], %swift.task* [[TASK]], %swift.executor* {{%[0-9]+}}, %swift.context* {{%[0-9]+}})
30+
// CHECK-arm64e: call {{.*}} @llvm.coro.suspend.async{{.*}}(i32 2, i8* [[RESUME]], i8* bitcast (i8* (i8*)* @__swift_async_resume_get_context to i8*), i8* bitcast (void (i8*, %swift.executor*, %swift.task*, %swift.executor*, %swift.context*)* @__swift_suspend_point to i8*), i8* [[SIGNED_RESUME]], %swift.executor* [[CAST_ACTOR]], %swift.task* [[TASK]], %swift.executor* {{%[0-9]+}}, %swift.context* {{%[0-9]+}})
3131
sil @test_simple : $@convention(method) @async (@guaranteed MyActor) -> () {
3232
bb0(%0 : $MyActor):
3333
hop_to_executor %0 : $MyActor

0 commit comments

Comments
 (0)