Skip to content

Commit 1853234

Browse files
Merge pull request #37735 from aschwaighofer/fix_await_async_continuation_5.5-0514
[5.5-05142021] IRGen: Add the `swiftasync` attribute to the resume function call for await_async_continuation
2 parents 1a1c215 + 3b8184f commit 1853234

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
@@ -4895,8 +4895,11 @@ IRGenFunction::getFunctionPointerForResumeIntrinsic(llvm::Value *resume) {
48954895
auto *fnTy = llvm::FunctionType::get(
48964896
IGM.VoidTy, {IGM.Int8PtrTy},
48974897
false /*vaargs*/);
4898+
auto attrs = IGM.constructInitialAttributes();
4899+
attrs = attrs.addParamAttribute(IGM.getLLVMContext(), 0,
4900+
llvm::Attribute::SwiftAsync);
48984901
auto signature =
4899-
Signature(fnTy, IGM.constructInitialAttributes(), IGM.SwiftAsyncCC);
4902+
Signature(fnTy, attrs, IGM.SwiftAsyncCC);
49004903
auto fnPtr = FunctionPointer(
49014904
FunctionPointer::Kind::Function,
49024905
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)