Skip to content

Commit 952ed06

Browse files
Merge pull request swiftlang#37729 from aschwaighofer/fix_await_async_continuation_5.5
[5.5] IRGen: Add the `swiftasync` attribute to the resume function call for await_async_continuation
2 parents 976d23d + 1aaf03c commit 952ed06

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

lib/IRGen/GenCall.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4914,8 +4914,11 @@ IRGenFunction::getFunctionPointerForResumeIntrinsic(llvm::Value *resume) {
49144914
auto *fnTy = llvm::FunctionType::get(
49154915
IGM.VoidTy, {IGM.Int8PtrTy},
49164916
false /*vaargs*/);
4917+
auto attrs = IGM.constructInitialAttributes();
4918+
attrs = attrs.addParamAttribute(IGM.getLLVMContext(), 0,
4919+
llvm::Attribute::SwiftAsync);
49174920
auto signature =
4918-
Signature(fnTy, IGM.constructInitialAttributes(), IGM.SwiftAsyncCC);
4921+
Signature(fnTy, attrs, IGM.SwiftAsyncCC);
49194922
auto fnPtr = FunctionPointer(
49204923
FunctionPointer::Kind::Function,
49214924
Builder.CreateBitOrPointerCast(resume, fnTy->getPointerTo()),

test/IRGen/async/get_async_continuation.sil

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ bb0:
7373
// CHECK: unreachable
7474

7575
// CHECK: await.async.resume:
76-
// CHECK: call { i8* } (i32, i8*, i8*, ...) @llvm.coro.suspend.async{{.*}}({{.*}} @__swift_async_resume_project_context
76+
// CHECK: call { i8* } (i32, i8*, i8*, ...) @llvm.coro.suspend.async{{.*}}({{.*}} @__swift_async_resume_project_context{{.*}}@__swift_suspend_dispatch_1
7777
// CHECK: [[result_addr_addr:%.*]] = getelementptr inbounds %swift.continuation_context, %swift.continuation_context* [[cont_context]], i32 0, i32 3
7878
// CHECK: [[result_addr:%.*]] = load %swift.opaque*, %swift.opaque** [[result_addr_addr]]
7979
// CHECK: [[typed_result_addr:%.*]] = bitcast %swift.opaque* [[result_addr]] to i32*
@@ -83,6 +83,12 @@ bb0:
8383
// CHECK: [[result_bb]]:
8484
// CHECK: phi i32 [ [[result_value]], %await.async.resume ]
8585

86+
87+
// CHECK: define {{.*}} void @__swift_suspend_dispatch_1(i8* %0, i8* %1)
88+
// CHECK-NOT: define
89+
// CHECK: tail call swift{{(tail)?}}cc void %{{.*}}(i8* swiftasync %1)
90+
// CHECK-NEXT: ret void
91+
8692
sil @async_continuation : $@async () -> () {
8793
entry:
8894
%c = get_async_continuation Builtin.Int32

0 commit comments

Comments
 (0)