Skip to content

IRGen: Use the clang type descriminator for TaskContinuationFunction* #60748

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions include/swift/ABI/MetadataValues.h
Original file line number Diff line number Diff line change
Expand Up @@ -1428,6 +1428,9 @@ namespace SpecialPointerAuthDiscriminators {
/// Swift async context parameter stored in the extended frame info.
const uint16_t SwiftAsyncContextExtendedFrameEntry = 0xc31a; // = 49946

// C type TaskContinuationFunction* descriminator.
const uint16_t ClangTypeTaskContinuationFunction = 0x2abe; // = 10942

/// Dispatch integration.
const uint16_t DispatchInvokeFunction = 0xf493; // = 62611

Expand Down
3 changes: 3 additions & 0 deletions include/swift/AST/IRGenOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,9 @@ struct PointerAuthOptions : clang::PointerAuthOptions {
/// Extended existential type shapes in flight.
PointerAuthSchema ExtendedExistentialTypeShape;

// The c type descriminator for TaskContinuationFunction*.
PointerAuthSchema ClangTypeTaskContinuationFunction;

/// Non-unique extended existential type shapes in flight.
PointerAuthSchema NonUniqueExtendedExistentialTypeShape;
};
Expand Down
4 changes: 3 additions & 1 deletion lib/IRGen/GenCall.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2730,8 +2730,10 @@ class AsyncCallEmission final : public CallEmission {
auto signedResumeFn = currentResumeFn;
// Sign the task resume function with the C function pointer schema.
if (auto schema = IGF.IGM.getOptions().PointerAuth.FunctionPointers) {
// TODO: use the Clang type for TaskContinuationFunction*
// Use the Clang type for TaskContinuationFunction*
// to make this work with type diversity.
schema =
IGF.IGM.getOptions().PointerAuth.ClangTypeTaskContinuationFunction;
auto authInfo =
PointerAuthInfo::emit(IGF, schema, nullptr, PointerAuthEntity());
signedResumeFn = emitPointerAuthSign(IGF, signedResumeFn, authInfo);
Expand Down
3 changes: 2 additions & 1 deletion lib/IRGen/GenFunc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2469,8 +2469,9 @@ llvm::Function *IRGenFunction::createAsyncSuspendFn() {

// Sign the task resume function with the C function pointer schema.
if (auto schema = IGM.getOptions().PointerAuth.FunctionPointers) {
// TODO: use the Clang type for TaskContinuationFunction*
// Use the Clang type for TaskContinuationFunction*
// to make this work with type diversity.
schema = IGM.getOptions().PointerAuth.ClangTypeTaskContinuationFunction;
auto authInfo = PointerAuthInfo::emit(suspendIGF, schema, nullptr,
PointerAuthEntity());
resumeFunction = emitPointerAuthSign(suspendIGF, resumeFunction, authInfo);
Expand Down
4 changes: 4 additions & 0 deletions lib/IRGen/IRGen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -994,6 +994,10 @@ static void setPointerAuthOptions(PointerAuthOptions &opts,
Discrimination::Constant,
SpecialPointerAuthDiscriminators
::NonUniqueExtendedExistentialTypeShape);

opts.ClangTypeTaskContinuationFunction = PointerAuthSchema(
codeKey, /*address*/ false, Discrimination::Constant,
SpecialPointerAuthDiscriminators::ClangTypeTaskContinuationFunction);
}

std::unique_ptr<llvm::TargetMachine>
Expand Down