@@ -462,7 +462,8 @@ static llvm::CallingConv::ID getFreestandingConvention(IRGenModule &IGM) {
462
462
// / Expand the requirements of the given abstract calling convention
463
463
// / into a "physical" calling convention.
464
464
llvm::CallingConv::ID irgen::expandCallingConv (IRGenModule &IGM,
465
- SILFunctionTypeRepresentation convention) {
465
+ SILFunctionTypeRepresentation convention,
466
+ bool isAsync) {
466
467
switch (convention) {
467
468
case SILFunctionTypeRepresentation::CFunctionPointer:
468
469
case SILFunctionTypeRepresentation::ObjCMethod:
@@ -474,6 +475,8 @@ llvm::CallingConv::ID irgen::expandCallingConv(IRGenModule &IGM,
474
475
case SILFunctionTypeRepresentation::Closure:
475
476
case SILFunctionTypeRepresentation::Thin:
476
477
case SILFunctionTypeRepresentation::Thick:
478
+ if (isAsync)
479
+ return IGM.SwiftAsyncCC ;
477
480
return getFreestandingConvention (IGM);
478
481
}
479
482
llvm_unreachable (" bad calling convention!" );
@@ -1849,7 +1852,8 @@ Signature SignatureExpansion::getSignature() {
1849
1852
(FnType->getLanguage () == SILFunctionLanguage::C) &&
1850
1853
" C function type without C function info" );
1851
1854
1852
- auto callingConv = expandCallingConv (IGM, FnType->getRepresentation ());
1855
+ auto callingConv =
1856
+ expandCallingConv (IGM, FnType->getRepresentation (), FnType->isAsync ());
1853
1857
1854
1858
Signature result;
1855
1859
result.Type = llvmType;
@@ -4823,7 +4827,7 @@ IRGenFunction::getFunctionPointerForResumeIntrinsic(llvm::Value *resume) {
4823
4827
IGM.VoidTy , {IGM.Int8PtrTy , IGM.Int8PtrTy , IGM.Int8PtrTy },
4824
4828
false /* vaargs*/ );
4825
4829
auto signature =
4826
- Signature (fnTy, IGM.constructInitialAttributes (), IGM.SwiftCC );
4830
+ Signature (fnTy, IGM.constructInitialAttributes (), IGM.SwiftAsyncCC );
4827
4831
auto fnPtr = FunctionPointer (
4828
4832
FunctionPointer::KindTy::Function,
4829
4833
Builder.CreateBitOrPointerCast (resume, fnTy->getPointerTo ()),
0 commit comments