@@ -462,7 +462,8 @@ static llvm::CallingConv::ID getFreestandingConvention(IRGenModule &IGM) {
462462// / Expand the requirements of the given abstract calling convention
463463// / into a "physical" calling convention.
464464llvm::CallingConv::ID irgen::expandCallingConv (IRGenModule &IGM,
465- SILFunctionTypeRepresentation convention) {
465+ SILFunctionTypeRepresentation convention,
466+ bool isAsync) {
466467 switch (convention) {
467468 case SILFunctionTypeRepresentation::CFunctionPointer:
468469 case SILFunctionTypeRepresentation::ObjCMethod:
@@ -474,6 +475,8 @@ llvm::CallingConv::ID irgen::expandCallingConv(IRGenModule &IGM,
474475 case SILFunctionTypeRepresentation::Closure:
475476 case SILFunctionTypeRepresentation::Thin:
476477 case SILFunctionTypeRepresentation::Thick:
478+ if (isAsync)
479+ return IGM.SwiftAsyncCC ;
477480 return getFreestandingConvention (IGM);
478481 }
479482 llvm_unreachable (" bad calling convention!" );
@@ -1849,7 +1852,8 @@ Signature SignatureExpansion::getSignature() {
18491852 (FnType->getLanguage () == SILFunctionLanguage::C) &&
18501853 " C function type without C function info" );
18511854
1852- auto callingConv = expandCallingConv (IGM, FnType->getRepresentation ());
1855+ auto callingConv =
1856+ expandCallingConv (IGM, FnType->getRepresentation (), FnType->isAsync ());
18531857
18541858 Signature result;
18551859 result.Type = llvmType;
@@ -4808,7 +4812,7 @@ IRGenFunction::getFunctionPointerForResumeIntrinsic(llvm::Value *resume) {
48084812 IGM.VoidTy , {IGM.Int8PtrTy , IGM.Int8PtrTy , IGM.Int8PtrTy },
48094813 false /* vaargs*/ );
48104814 auto signature =
4811- Signature (fnTy, IGM.constructInitialAttributes (), IGM.SwiftCC );
4815+ Signature (fnTy, IGM.constructInitialAttributes (), IGM.SwiftAsyncCC );
48124816 auto fnPtr = FunctionPointer (
48134817 FunctionPointer::KindTy::Function,
48144818 Builder.CreateBitOrPointerCast (resume, fnTy->getPointerTo ()),
0 commit comments