|
25 | 25 |
|
26 | 26 | #include "Callee.h" |
27 | 27 | #include "Explosion.h" |
| 28 | +#include "GenPointerAuth.h" |
28 | 29 | #include "IRGenDebugInfo.h" |
29 | 30 | #include "IRGenFunction.h" |
30 | 31 | #include "IRGenModule.h" |
@@ -563,7 +564,13 @@ void IRGenFunction::emitGetAsyncContinuation(SILType resumeTy, |
563 | 564 | // TODO: add lifetime with matching lifetime in await_async_continuation |
564 | 565 | auto contResumeAddr = |
565 | 566 | Builder.CreateStructGEP(continuationContext.getAddress(), 0); |
566 | | - Builder.CreateStore(getAsyncContext(), |
| 567 | + llvm::Value *asyncContextValue = getAsyncContext(); |
| 568 | + if (auto schema = IGM.getOptions().PointerAuth.AsyncContextParent) { |
| 569 | + auto authInfo = PointerAuthInfo::emit(*this, schema, contResumeAddr, |
| 570 | + PointerAuthEntity()); |
| 571 | + asyncContextValue = emitPointerAuthSign(*this, asyncContextValue, authInfo); |
| 572 | + } |
| 573 | + Builder.CreateStore(asyncContextValue, |
567 | 574 | Address(contResumeAddr, pointerAlignment)); |
568 | 575 | auto contErrResultAddr = |
569 | 576 | Builder.CreateStructGEP(continuationContext.getAddress(), 2); |
@@ -607,15 +614,27 @@ void IRGenFunction::emitGetAsyncContinuation(SILType resumeTy, |
607 | 614 | assert(AsyncCoroutineCurrentResume == nullptr && |
608 | 615 | "Don't support nested get_async_continuation"); |
609 | 616 | AsyncCoroutineCurrentResume = coroResume; |
610 | | - Builder.CreateStore( |
611 | | - Builder.CreateBitOrPointerCast(coroResume, IGM.FunctionPtrTy), |
612 | | - Address(currTaskResumeTaskAddr, pointerAlignment)); |
| 617 | + llvm::Value *coroResumeValue = |
| 618 | + Builder.CreateBitOrPointerCast(coroResume, IGM.FunctionPtrTy); |
| 619 | + if (auto schema = IGM.getOptions().PointerAuth.TaskResumeFunction) { |
| 620 | + auto authInfo = PointerAuthInfo::emit(*this, schema, currTaskResumeTaskAddr, |
| 621 | + PointerAuthEntity()); |
| 622 | + coroResumeValue = emitPointerAuthSign(*this, coroResumeValue, authInfo); |
| 623 | + } |
| 624 | + Builder.CreateStore(coroResumeValue, |
| 625 | + Address(currTaskResumeTaskAddr, pointerAlignment)); |
613 | 626 | // currTask->ResumeContext = &continuation_context; |
614 | 627 | auto currTaskResumeCtxtAddr = Builder.CreateStructGEP(currTask, 5); |
615 | | - Builder.CreateStore( |
616 | | - Builder.CreateBitOrPointerCast(continuationContext.getAddress(), |
617 | | - IGM.SwiftContextPtrTy), |
618 | | - Address(currTaskResumeCtxtAddr, pointerAlignment)); |
| 628 | + llvm::Value *continuationContextValue = Builder.CreateBitOrPointerCast( |
| 629 | + continuationContext.getAddress(), IGM.SwiftContextPtrTy); |
| 630 | + if (auto schema = IGM.getOptions().PointerAuth.TaskResumeContext) { |
| 631 | + auto authInfo = PointerAuthInfo::emit(*this, schema, currTaskResumeCtxtAddr, |
| 632 | + PointerAuthEntity()); |
| 633 | + continuationContextValue = |
| 634 | + emitPointerAuthSign(*this, continuationContextValue, authInfo); |
| 635 | + } |
| 636 | + Builder.CreateStore(continuationContextValue, |
| 637 | + Address(currTaskResumeCtxtAddr, pointerAlignment)); |
619 | 638 |
|
620 | 639 | // Publish all the writes. |
621 | 640 | // continuation_context.awaitSynchronization =(atomic release) nullptr; |
|
0 commit comments