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

KeyPath thunk helpers are called from stdlib indirectly through
descriptor and its calling-convention in the caller side is SwiftCC.
However, the definition side expects C calling-convention, so they
can be broken on some architectures, that SwiftCC is not compatible
with C-CC on it.

This patch changes to use SwiftCC consistently on caller side and
definition side.
This doesn't have any effect on the ABI stable platforms because
SwiftCC is compatible with C-CC on them.
This commit is contained in:
Yuta Saito
2021-10-01 10:01:39 -07:00
parent c413f4089d
commit b5ae4d1397
2 changed files with 12 additions and 8 deletions

View File

@@ -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);
@@ -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)
@@ -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)
@@ -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);