Skip to content

Commit d4be3e8

Browse files
committed
[PtrAuth] Adopt AsyncContextResume schema.
1 parent af25d75 commit d4be3e8

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

include/swift/AST/IRGenOptions.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,9 @@ struct PointerAuthOptions : clang::PointerAuthOptions {
140140

141141
/// The parent async context stored within a child async context.
142142
PointerAuthSchema AsyncContextParent;
143+
144+
/// The function to call to resume running in the parent context.
145+
PointerAuthSchema AsyncContextResume;
143146
};
144147

145148
enum class JITDebugArtifact : unsigned {

lib/IRGen/GenCall.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2374,8 +2374,7 @@ class AsyncCallEmission final : public CallEmission {
23742374
llvm::Intrinsic::coro_async_resume, {});
23752375
auto fnVal = currentResumeFn;
23762376
// Sign the pointer.
2377-
// TODO: use a distinct schema.
2378-
if (auto schema = IGF.IGM.getOptions().PointerAuth.AsyncContextParent) {
2377+
if (auto schema = IGF.IGM.getOptions().PointerAuth.AsyncContextResume) {
23792378
Address fieldAddr =
23802379
fieldLayout.project(IGF, this->context, /*offsets*/ llvm::None);
23812380
auto authInfo = PointerAuthInfo::emit(
@@ -4577,8 +4576,7 @@ void irgen::emitAsyncReturn(IRGenFunction &IGF, AsyncContextLayout &asyncLayout,
45774576
.loadAsCopy(IGF, returnToCallerAddr, fn);
45784577
llvm::Value *fnVal = fn.claimNext();
45794578

4580-
// TODO: use distinct schema
4581-
if (auto schema = IGF.IGM.getOptions().PointerAuth.AsyncContextParent) {
4579+
if (auto schema = IGF.IGM.getOptions().PointerAuth.AsyncContextResume) {
45824580
Address fieldAddr =
45834581
returnToCallerLayout.project(IGF, contextAddr, /*offsets*/ llvm::None);
45844582
auto authInfo = PointerAuthInfo::emit(IGF, schema, fieldAddr.getAddress(),

lib/IRGen/IRGen.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -692,6 +692,10 @@ static void setPointerAuthOptions(PointerAuthOptions &opts,
692692
opts.AsyncContextParent =
693693
PointerAuthSchema(codeKey, /*address*/ true, Discrimination::Constant,
694694
SpecialPointerAuthDiscriminators::AsyncContextParent);
695+
696+
opts.AsyncContextResume =
697+
PointerAuthSchema(codeKey, /*address*/ true, Discrimination::Constant,
698+
SpecialPointerAuthDiscriminators::AsyncContextResume);
695699
}
696700

697701
std::unique_ptr<llvm::TargetMachine>

0 commit comments

Comments
 (0)