@@ -2385,7 +2385,7 @@ void irgen::emitBlockHeader(IRGenFunction &IGF,
2385
2385
2386
2386
llvm::Function *IRGenFunction::getOrCreateResumePrjFn () {
2387
2387
auto name = " __swift_async_resume_project_context" ;
2388
- return cast<llvm::Function>(IGM.getOrCreateHelperFunction (
2388
+ auto Fn = cast<llvm::Function>(IGM.getOrCreateHelperFunction (
2389
2389
name, IGM.Int8PtrTy , {IGM.Int8PtrTy },
2390
2390
[&](IRGenFunction &IGF) {
2391
2391
auto it = IGF.CurFn ->arg_begin ();
@@ -2398,9 +2398,29 @@ llvm::Function *IRGenFunction::getOrCreateResumePrjFn() {
2398
2398
PointerAuthInfo::emit (IGF, schema, addr, PointerAuthEntity ());
2399
2399
callerContext = emitPointerAuthAuth (IGF, callerContext, authInfo);
2400
2400
}
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
+ }
2401
2419
Builder.CreateRet (callerContext);
2402
2420
},
2403
2421
false /* isNoInline*/ ));
2422
+ Fn->addFnAttr (llvm::Attribute::AlwaysInline);
2423
+ return Fn;
2404
2424
}
2405
2425
llvm::Function *
2406
2426
IRGenFunction::createAsyncDispatchFn (const FunctionPointer &fnPtr,
0 commit comments