@@ -2385,7 +2385,7 @@ void irgen::emitBlockHeader(IRGenFunction &IGF,
23852385
23862386llvm::Function *IRGenFunction::getOrCreateResumePrjFn () {
23872387 auto name = " __swift_async_resume_project_context" ;
2388- return cast<llvm::Function>(IGM.getOrCreateHelperFunction (
2388+ auto Fn = cast<llvm::Function>(IGM.getOrCreateHelperFunction (
23892389 name, IGM.Int8PtrTy , {IGM.Int8PtrTy },
23902390 [&](IRGenFunction &IGF) {
23912391 auto it = IGF.CurFn ->arg_begin ();
@@ -2398,9 +2398,29 @@ llvm::Function *IRGenFunction::getOrCreateResumePrjFn() {
23982398 PointerAuthInfo::emit (IGF, schema, addr, PointerAuthEntity ());
23992399 callerContext = emitPointerAuthAuth (IGF, callerContext, authInfo);
24002400 }
2401+ // TODO: remove this once all platforms support lowering the intrinsic.
2402+ // At the time of this writing only arm64 supports it.
2403+ if (IGM.TargetInfo .canUseSwiftAsyncContextAddrIntrinsic ()) {
2404+ auto contextLocationInExtendedFrame =
2405+ Address (Builder.CreateIntrinsicCall (
2406+ llvm::Intrinsic::swift_async_context_addr, {}),
2407+ IGM.getPointerAlignment ());
2408+ // On arm64e we need to sign this pointer address discriminated
2409+ // with 0xc31a and process dependent key.
2410+ if (auto schema = IGF.IGM .getOptions ()
2411+ .PointerAuth .AsyncContextExtendedFrameEntry ) {
2412+ auto authInfo = PointerAuthInfo::emit (
2413+ IGF, schema, contextLocationInExtendedFrame.getAddress (),
2414+ PointerAuthEntity ());
2415+ callerContext = emitPointerAuthSign (IGF, callerContext, authInfo);
2416+ }
2417+ Builder.CreateStore (callerContext, contextLocationInExtendedFrame);
2418+ }
24012419 Builder.CreateRet (callerContext);
24022420 },
24032421 false /* isNoInline*/ ));
2422+ Fn->addFnAttr (llvm::Attribute::AlwaysInline);
2423+ return Fn;
24042424}
24052425llvm::Function *
24062426IRGenFunction::createAsyncDispatchFn (const FunctionPointer &fnPtr,
0 commit comments