Skip to content

[IRGen] Emit keypath thunk helpers with swiftcc to match with the caller cc #39546

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
4 changes: 4 additions & 0 deletions lib/IRGen/GenKeyPath.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,7 @@ getLayoutFunctionForComputedComponent(IRGenModule &IGM,
auto layoutFn = llvm::Function::Create(fnTy,
llvm::GlobalValue::PrivateLinkage, "keypath_get_arg_layout", IGM.getModule());
layoutFn->setAttributes(IGM.constructInitialAttributes());
layoutFn->setCallingConv(IGM.SwiftCC);

{
IRGenFunction IGF(IGM, layoutFn);
Expand Down Expand Up @@ -383,6 +384,7 @@ getWitnessTableForComputedComponent(IRGenModule &IGM,
llvm::GlobalValue::PrivateLinkage, "keypath_destroy", IGM.getModule());
destroy = destroyFn;
destroyFn->setAttributes(IGM.constructInitialAttributes());
destroyFn->setCallingConv(IGM.SwiftCC);

IRGenFunction IGF(IGM, destroyFn);
if (IGM.DebugInfo)
Expand Down Expand Up @@ -432,6 +434,7 @@ getWitnessTableForComputedComponent(IRGenModule &IGM,
llvm::GlobalValue::PrivateLinkage, "keypath_copy", IGM.getModule());
copy = copyFn;
copyFn->setAttributes(IGM.constructInitialAttributes());
copyFn->setCallingConv(IGM.SwiftCC);

IRGenFunction IGF(IGM, copyFn);
if (IGM.DebugInfo)
Expand Down Expand Up @@ -545,6 +548,7 @@ getInitializerForComputedComponent(IRGenModule &IGM,
auto initFn = llvm::Function::Create(fnTy,
llvm::GlobalValue::PrivateLinkage, "keypath_arg_init", IGM.getModule());
initFn->setAttributes(IGM.constructInitialAttributes());
initFn->setCallingConv(IGM.SwiftCC);

{
IRGenFunction IGF(IGM, initFn);
Expand Down
16 changes: 8 additions & 8 deletions test/IRGen/default_function_ir_attributes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -119,35 +119,35 @@ func test_computed_key_path_sil_thunks() -> KeyPath<S, Int> {
}

// helper function: IR-generated key path getter
// CHECK-LABEL: define {{.*}} @keypath_get(
// CHECK-LABEL: define {{.*}} swiftcc {{.*}} @keypath_get(
// CHECK-SAME: [[ATTRS_SIMPLE]]

// helper function: IR-generated key path setter
// CHECK-LABEL: define {{.*}} @keypath_set(
// CHECK-LABEL: define {{.*}} swiftcc {{.*}} @keypath_set(
// CHECK-SAME: [[ATTRS_SIMPLE]]

// helper function: IR-generated key path arg layout accessor
// CHECK-LABEL: define {{.*}} @keypath_get_arg_layout(
// CHECK-LABEL: define {{.*}} swiftcc {{.*}} @keypath_get_arg_layout(
// CHECK-SAME: [[ATTRS_SIMPLE]]

// helper function: IR-generated key path destroy function
// CHECK-LABEL: define {{.*}} @keypath_destroy(
// CHECK-LABEL: define {{.*}} swiftcc {{.*}} @keypath_destroy(
// CHECK-SAME: [[ATTRS_SIMPLE]]

// helper function: IR-generated key path copy function
// CHECK-LABEL: define {{.*}} @keypath_copy(
// CHECK-LABEL: define {{.*}} swiftcc {{.*}} @keypath_copy(
// CHECK-SAME: [[ATTRS_SIMPLE]]

// helper function: IR-generated key path equals function
// CHECK-LABEL: define {{.*}} @keypath_equals(
// CHECK-LABEL: define {{.*}} swiftcc {{.*}} @keypath_equals(
// CHECK-SAME: [[ATTRS_SIMPLE]]

// helper function: IR-generated key path hash function
// CHECK-LABEL: define {{.*}} @keypath_hash(
// CHECK-LABEL: define {{.*}} swiftcc {{.*}} @keypath_hash(
// CHECK-SAME: [[ATTRS_SIMPLE]]

// helper function: IR-generated key path argument initializer
// CHECK-LABEL: define {{.*}} @keypath_arg_init(
// CHECK-LABEL: define {{.*}} swiftcc {{.*}} @keypath_arg_init(
// CHECK-SAME: [[ATTRS_SIMPLE]]

func test_computed_key_path_generic_thunks<T: P0 & Hashable>(value: T) -> KeyPath<S, Int> {
Expand Down