Skip to content

ASTMangler: Fix mangling of SILFunctionType with @pack conventions [5.9] #65561

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
6 changes: 3 additions & 3 deletions lib/AST/ASTMangler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1097,9 +1097,9 @@ static char getParamConvention(ParameterConvention conv) {
case ParameterConvention::Direct_Owned: return 'x';
case ParameterConvention::Direct_Unowned: return 'y';
case ParameterConvention::Direct_Guaranteed: return 'g';
case ParameterConvention::Pack_Owned: return 'x';
case ParameterConvention::Pack_Inout: return 'y';
case ParameterConvention::Pack_Guaranteed: return 'g';
case ParameterConvention::Pack_Owned: return 'v';
case ParameterConvention::Pack_Inout: return 'm';
case ParameterConvention::Pack_Guaranteed: return 'p';
}
llvm_unreachable("bad parameter convention");
}
Expand Down
2 changes: 1 addition & 1 deletion lib/Demangling/Demangler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2068,7 +2068,7 @@ NodePointer Demangler::demangleImplParamConvention(Node::Kind ConvKind) {
case 'y': attr = "@unowned"; break;
case 'v': attr = "@pack_owned"; break;
case 'p': attr = "@pack_guaranteed"; break;
case 'm': attr = "@pack_guaranteed"; break;
case 'm': attr = "@pack_inout"; break;
default:
pushBack();
return nullptr;
Expand Down
4 changes: 4 additions & 0 deletions test/DebugInfo/variadic-generics-closure.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// RUN: %target-swift-frontend -emit-ir %s -g | %FileCheck %s

// CHECK: !{{[0-9]+}} = !DICompositeType(tag: DW_TAG_structure_type, name: "$sxxQp_QSiIgp_D", {{.*}})
public func f<each Input>(builder: (repeat each Input) -> ()) {}
6 changes: 3 additions & 3 deletions test/SILGen/variadic-generic-reabstraction.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,13 @@ func forwardAndReabstractFunctionPack<each T>(functions: repeat (each T) -> Bool

// CHECK-LABEL: sil{{.*}} @$s4main22passConcreteToVariadic2fnyS2i_SStXE_tF :
// CHECK: [[COPY:%.*]] = copy_value %0 : $@noescape @callee_guaranteed (Int, @guaranteed String) -> Int
// CHECK: [[THUNK:%.*]] = function_ref @$sSiSSSiIgygd_Si_SSQSiSiIeggd_TR
// CHECK: [[THUNK:%.*]] = function_ref @$sSiSSSiIgygd_Si_SSQSiSiIegpd_TR
// CHECK: partial_apply [callee_guaranteed] [[THUNK]]([[COPY]])
func passConcreteToVariadic(fn: (Int, String) -> Int) {
takesVariadicFunction(function: fn)
}

// CHECK-LABEL: sil{{.*}} @$sSiSSSiIgygd_Si_SSQSiSiIeggd_TR :
// CHECK-LABEL: sil{{.*}} @$sSiSSSiIgygd_Si_SSQSiSiIegpd_TR :
// CHECK: bb0(%0 : $*Pack{Int, String}, %1 : @guaranteed $@noescape @callee_guaranteed (Int, @guaranteed String) -> Int):
// CHECK-NEXT: [[INT_INDEX:%.*]] = scalar_pack_index 0 of $Pack{Int, String}
// CHECK-NEXT: [[INT_ADDR:%.*]] = pack_element_get [[INT_INDEX]] of %0 : $*Pack{Int, String}
Expand All @@ -74,7 +74,7 @@ func passConcreteToVariadic(fn: (Int, String) -> Int) {
// FIXME: we aren't preserving that the argument is owned
// CHECK-LABEL: sil{{.*}} @$s4main27passConcreteToOwnedVariadic2fnyS2i_SStXE_tF :
// CHECK: [[COPY:%.*]] = copy_value %0 : $@noescape @callee_guaranteed (Int, @guaranteed String) -> Int
// CHECK: [[THUNK:%.*]] = function_ref @$sSiSSSiIgygd_Si_SSQSiSiIeggd_TR
// CHECK: [[THUNK:%.*]] = function_ref @$sSiSSSiIgygd_Si_SSQSiSiIegpd_TR
// CHECK: partial_apply [callee_guaranteed] [[THUNK]]([[COPY]])
func passConcreteToOwnedVariadic(fn: (Int, String) -> Int) {
takesVariadicOwnedFunction(function: fn)
Expand Down