Skip to content

Commit 61f4d6f

Browse files
committed
SIL: Pass SubstFlags::PreservePackExpansionLevel in a few places
Fixes rdar://problem/111219086.
1 parent 1646085 commit 61f4d6f

File tree

2 files changed

+28
-6
lines changed

2 files changed

+28
-6
lines changed

include/swift/SIL/SILCloner.h

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -195,9 +195,9 @@ class SILCloner : protected SILInstructionVisitor<ImplClass> {
195195
if (Subs.hasLocalArchetypes()) {
196196
// If we found a type containing a local archetype, substitute
197197
// open existentials throughout the substitution map.
198-
Subs = Subs.subst(QueryTypeSubstitutionMapOrIdentity{
199-
LocalArchetypeSubs},
200-
MakeAbstractConformanceForGenericType());
198+
Subs = Subs.subst(QueryTypeSubstitutionMapOrIdentity{LocalArchetypeSubs},
199+
MakeAbstractConformanceForGenericType(),
200+
SubstFlags::PreservePackExpansionLevel);
201201
}
202202
}
203203

@@ -220,7 +220,9 @@ class SILCloner : protected SILInstructionVisitor<ImplClass> {
220220
return Ty.subst(
221221
Builder.getModule(),
222222
QueryTypeSubstitutionMapOrIdentity{LocalArchetypeSubs},
223-
MakeAbstractConformanceForGenericType());
223+
MakeAbstractConformanceForGenericType(),
224+
CanGenericSignature(),
225+
SubstFlags::PreservePackExpansionLevel);
224226
}
225227
SILType getOpType(SILType Ty) {
226228
Ty = getTypeInClonedContext(Ty);
@@ -239,7 +241,8 @@ class SILCloner : protected SILInstructionVisitor<ImplClass> {
239241

240242
return ty.subst(
241243
QueryTypeSubstitutionMapOrIdentity{LocalArchetypeSubs},
242-
MakeAbstractConformanceForGenericType()
244+
MakeAbstractConformanceForGenericType(),
245+
SubstFlags::PreservePackExpansionLevel
243246
)->getCanonicalType();
244247
}
245248

@@ -352,7 +355,8 @@ class SILCloner : protected SILInstructionVisitor<ImplClass> {
352355
conformance.subst(ty,
353356
QueryTypeSubstitutionMapOrIdentity{
354357
LocalArchetypeSubs},
355-
MakeAbstractConformanceForGenericType());
358+
MakeAbstractConformanceForGenericType(),
359+
SubstFlags::PreservePackExpansionLevel);
356360
}
357361

358362
return asImpl().remapConformance(getASTTypeInClonedContext(ty),
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// RUN: %target-swift-frontend -emit-sil -O %s | %FileCheck %s
2+
3+
@_optimize(none)
4+
public func callee<T, each X>(_: T, _: repeat each X) {}
5+
6+
@_transparent
7+
public func caller<each X>(_ x: repeat each X) {
8+
repeat callee(each x, repeat each x)
9+
}
10+
11+
public func outerCaller<each X>(_ x: repeat each X) {
12+
caller(repeat each x)
13+
}
14+
15+
// CHECK-LABEL: sil @$s28variadic_generics_sil_cloner11outerCalleryyxxQpRvzlF : $@convention(thin) <each X> (@pack_guaranteed Pack{repeat each X}) -> () {
16+
// CHECK: [[CALLEE:%.*]] = function_ref @$s28variadic_generics_sil_cloner6calleeyyx_q_q_QptRv_r0_lF : $@convention(thin) <τ_0_0, each τ_0_1> (@in_guaranteed τ_0_0, @pack_guaranteed Pack{repeat each τ_0_1}) -> ()
17+
// CHECK: apply [[CALLEE]]<@pack_element("{{.*}}") each X, Pack{repeat each X}>(
18+
// CHECK: // end sil function '$s28variadic_generics_sil_cloner11outerCalleryyxxQpRvzlF'

0 commit comments

Comments
 (0)