Skip to content

Commit 6a83e73

Browse files
committed
SILGen: Protocol witness thunks don't need public linkage
We used to give witness thunks public linkage if the conforming type and the protocol are public. This is completely unnecessary. If the conformance is fragile, the thunk should be [shared] [serialized], allowing the thunk to be serialized into callers after devirtualization. Otherwise for private protocols or resilient modules, witness thunks can just always be private. This should reduce the size of compiled binaries. There are two other mildly interesting consequences: 1) In the bridged cast tests, we now inline the witness thunks from the bridgeable conformances, which removes one level of indirection. 2) This uncovered a flaw in our accessibility checking model. Usually, we reject a witness that is less visible than the protocol; however, we fail to reject it in the case that it comes from an extension. This is because members of an extension can be declared 'public' even if the extended type is not public, and it appears that in this case the 'public' keyword has no effect. I would prefer it if a) 'public' generated a warning here, and b) the conformance also generated a warning. In Swift 4 mode, we could then make this kind of sillyness into an error. But for now, live with the broken behavior, and add a test to exercise it to ensure we don't crash. There are other places where this "allow public but ignore it, kinda, except respect it in some places" behavior causes problems. I don't know if it was intentional or just emergent behavior from general messiness in Sema. 3) In the TBD code, there is one less 'failure' because now that witness thunks are no longer public, TBDGen does not need to reason about them (except for the case #2 above, which will probably require a similar workaround in TBDGen as what I put into SILGen).
1 parent 8201eaa commit 6a83e73

36 files changed

+333
-267
lines changed

lib/SILGen/SILGen.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,7 @@ class LLVM_LIBRARY_VISIBILITY SILGenModule : public ASTVisitor<SILGenModule> {
317317
/// Emit a protocol witness entry point.
318318
SILFunction *emitProtocolWitness(ProtocolConformance *conformance,
319319
SILLinkage linkage,
320+
IsSerialized_t isSerialized,
320321
SILDeclRef requirement,
321322
SILDeclRef witnessRef,
322323
IsFreeFunctionWitness_t isFree,

lib/SILGen/SILGenType.cpp

Lines changed: 53 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -312,16 +312,34 @@ class SILGenConformance : public SILGenWitnessTable<SILGenConformance> {
312312
NormalProtocolConformance *Conformance;
313313
std::vector<SILWitnessTable::Entry> Entries;
314314
SILLinkage Linkage;
315+
IsSerialized_t Serialized;
315316

316317
SILGenConformance(SILGenModule &SGM, NormalProtocolConformance *C)
317318
// We only need to emit witness tables for base NormalProtocolConformances.
318319
: SGM(SGM), Conformance(C->getRootNormalConformance()),
319320
Linkage(getLinkageForProtocolConformance(Conformance,
320321
ForDefinition))
321322
{
322-
// Not all protocols use witness tables.
323-
if (!Lowering::TypeConverter::protocolRequiresWitnessTable(
324-
Conformance->getProtocol()))
323+
auto *proto = Conformance->getProtocol();
324+
325+
Serialized = IsNotSerialized;
326+
327+
// Serialize the witness table if we're serializing everything with
328+
// -sil-serialize-all.
329+
if (SGM.makeModuleFragile)
330+
Serialized = IsSerialized;
331+
332+
// Serialize the witness table if type has a fixed layout in all
333+
// resilience domains, and the conformance is externally visible.
334+
auto nominal = Conformance->getInterfaceType()->getAnyNominal();
335+
if (nominal->hasFixedLayout() &&
336+
proto->getEffectiveAccess() >= Accessibility::Public &&
337+
nominal->getEffectiveAccess() >= Accessibility::Public)
338+
Serialized = IsSerialized;
339+
340+
// Not all protocols use witness tables; in this case we just skip
341+
// all of emit() below completely.
342+
if (!Lowering::TypeConverter::protocolRequiresWitnessTable(proto))
325343
Conformance = nullptr;
326344
}
327345

@@ -333,19 +351,6 @@ class SILGenConformance : public SILGenWitnessTable<SILGenConformance> {
333351
auto *proto = Conformance->getProtocol();
334352
visitProtocolDecl(proto);
335353

336-
// Serialize the witness table in two cases:
337-
// 1) We're serializing everything
338-
// 2) The type has a fixed layout in all resilience domains, and the
339-
// conformance is externally visible
340-
IsSerialized_t isSerialized = IsNotSerialized;
341-
if (SGM.makeModuleFragile)
342-
isSerialized = IsSerialized;
343-
if (auto nominal = Conformance->getInterfaceType()->getAnyNominal())
344-
if (nominal->hasFixedLayout() &&
345-
proto->getEffectiveAccess() >= Accessibility::Public &&
346-
nominal->getEffectiveAccess() >= Accessibility::Public)
347-
isSerialized = IsSerialized;
348-
349354
// Check if we already have a declaration or definition for this witness
350355
// table.
351356
if (auto *wt = SGM.M.lookUpWitnessTable(Conformance, false)) {
@@ -358,7 +363,7 @@ class SILGenConformance : public SILGenWitnessTable<SILGenConformance> {
358363

359364
// If we have a declaration, convert the witness table to a definition.
360365
if (wt->isDeclaration()) {
361-
wt->convertToDefinition(Entries, isSerialized);
366+
wt->convertToDefinition(Entries, Serialized);
362367

363368
// Since we had a declaration before, its linkage should be external,
364369
// ensure that we have a compatible linkage for sanity. *NOTE* we are ok
@@ -375,7 +380,7 @@ class SILGenConformance : public SILGenWitnessTable<SILGenConformance> {
375380
}
376381

377382
// Otherwise if we have no witness table yet, create it.
378-
return SILWitnessTable::create(SGM.M, Linkage, isSerialized,
383+
return SILWitnessTable::create(SGM.M, Linkage, Serialized,
379384
Conformance, Entries);
380385
}
381386

@@ -427,9 +432,33 @@ class SILGenConformance : public SILGenWitnessTable<SILGenConformance> {
427432
return;
428433
}
429434

435+
auto witnessLinkage = witnessRef.getLinkage(ForDefinition);
436+
auto witnessSerialized = Serialized;
437+
if (witnessSerialized &&
438+
!hasPublicVisibility(witnessLinkage) &&
439+
!hasSharedVisibility(witnessLinkage)) {
440+
// FIXME: This should not happen, but it looks like visibility rules
441+
// for extension members are slightly bogus.
442+
//
443+
// We allow a 'public' member of an extension to witness a public
444+
// protocol requirement, even if the extended type is not public;
445+
// then SILGen gives the member private linkage, ignoring the more
446+
// visible accessibility it was given in the AST.
447+
witnessLinkage = SILLinkage::Public;
448+
witnessSerialized = (SGM.makeModuleFragile
449+
? IsSerialized
450+
: IsNotSerialized);
451+
} else {
452+
// This is the "real" rule; the above case should go away once we
453+
// figure out what's going on.
454+
witnessLinkage = (witnessSerialized
455+
? SILLinkage::Shared
456+
: SILLinkage::Private);
457+
}
458+
430459
SILFunction *witnessFn =
431-
SGM.emitProtocolWitness(Conformance, Linkage, requirementRef, witnessRef,
432-
isFree, witness);
460+
SGM.emitProtocolWitness(Conformance, witnessLinkage, witnessSerialized,
461+
requirementRef, witnessRef, isFree, witness);
433462
Entries.push_back(
434463
SILWitnessTable::MethodWitness{requirementRef, witnessFn});
435464
}
@@ -540,6 +569,7 @@ static bool maybeOpenCodeProtocolWitness(SILGenFunction &gen,
540569
SILFunction *
541570
SILGenModule::emitProtocolWitness(ProtocolConformance *conformance,
542571
SILLinkage linkage,
572+
IsSerialized_t isSerialized,
543573
SILDeclRef requirement,
544574
SILDeclRef witnessRef,
545575
IsFreeFunctionWitness_t isFree,
@@ -637,14 +667,6 @@ SILGenModule::emitProtocolWitness(ProtocolConformance *conformance,
637667
if (witnessRef.isAlwaysInline())
638668
InlineStrategy = AlwaysInline;
639669

640-
IsSerialized_t isSerialized = IsNotSerialized;
641-
if (makeModuleFragile)
642-
isSerialized = IsSerialized;
643-
if (witnessRef.isSerialized() &&
644-
(hasSharedVisibility(linkage) ||
645-
hasPublicVisibility(linkage)))
646-
isSerialized = IsSerialized;
647-
648670
auto *f = M.createFunction(
649671
linkage, nameBuffer, witnessSILFnType,
650672
genericEnv, SILLocation(witnessRef.getDecl()),
@@ -742,7 +764,9 @@ class SILGenDefaultWitnessTable
742764
SILDeclRef witnessRef,
743765
IsFreeFunctionWitness_t isFree,
744766
Witness witness) {
745-
SILFunction *witnessFn = SGM.emitProtocolWitness(nullptr, Linkage,
767+
SILFunction *witnessFn = SGM.emitProtocolWitness(nullptr,
768+
SILLinkage::Private,
769+
IsNotSerialized,
746770
requirementRef, witnessRef,
747771
isFree, witness);
748772
auto entry = SILDefaultWitnessTable::Entry(requirementRef, witnessFn);

test/IRGen/dependent_reabstraction.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ protocol A {
88
}
99

1010
struct X<Y> : A {
11-
// CHECK-LABEL: define hidden swiftcc void @_T023dependent_reabstraction1XVyxGAA1AAAlAaEP1by1BQzFTW(%swift.type** noalias nocapture dereferenceable({{.*}}), %T23dependent_reabstraction1XV* noalias nocapture swiftself, %swift.type* %Self, i8** %SelfWitnessTable)
11+
// CHECK-LABEL: define internal swiftcc void @_T023dependent_reabstraction1XVyxGAA1AAAlAaEP1by1BQzFTW(%swift.type** noalias nocapture dereferenceable({{.*}}), %T23dependent_reabstraction1XV* noalias nocapture swiftself, %swift.type* %Self, i8** %SelfWitnessTable)
1212
func b(_ b: X.Type) {
1313
let x: Any = b
1414
markUsed(b as X.Type)

test/IRGen/metadata_dominance.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,6 @@ func testMakeFoo(_ p: P) -> Foo.Type {
7979
// The protocol witness for metadata_dominance.P.makeFoo () -> metadata_dominance.Foo in
8080
// conformance metadata_dominance.Foo : metadata_dominance.P should not use the Self type
8181
// as the type of the object to be created. It should dynamically obtain the type.
82-
// CHECK-OPT-LABEL: define hidden swiftcc %T18metadata_dominance3FooC* @_T018metadata_dominance3FooCAA1PA2aDP04makeC0ACyFTW
82+
// CHECK-OPT-LABEL: define internal swiftcc %T18metadata_dominance3FooC* @_T018metadata_dominance3FooCAA1PA2aDP04makeC0ACyFTW
8383
// CHECK-OPT-NOT: tail call noalias %swift.refcounted* @swift_rt_swift_allocObject(%swift.type* %Self
8484

test/IRGen/objc_generic_protocol_conformance.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@ protocol P {
99

1010
extension Foo: P {}
1111

12-
// SIL-LABEL: sil hidden [transparent] [thunk] @_T0So3FooCyxG33objc_generic_protocol_conformance1PADs9AnyObjectRzlAdEP3fooyyFTW {{.*}} @pseudogeneric
13-
// IR-LABEL: define hidden swiftcc void @_T0So3FooCyxG33objc_generic_protocol_conformance1PADs9AnyObjectRzlAdEP3fooyyFTW(%TSo3FooC** noalias nocapture swiftself dereferenceable({{4|8}}), %swift.type*{{( %Self)?}}, i8**{{( %SelfWitnessTable)?}})
12+
// SIL-LABEL: sil private [transparent] [thunk] @_T0So3FooCyxG33objc_generic_protocol_conformance1PADs9AnyObjectRzlAdEP3fooyyFTW {{.*}} @pseudogeneric
13+
// IR-LABEL: define internal swiftcc void @_T0So3FooCyxG33objc_generic_protocol_conformance1PADs9AnyObjectRzlAdEP3fooyyFTW(%TSo3FooC** noalias nocapture swiftself dereferenceable({{4|8}}), %swift.type*{{( %Self)?}}, i8**{{( %SelfWitnessTable)?}})

test/SILGen/cf.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,9 @@ protocol Impedance {
6565

6666
extension CCImpedance: Impedance {}
6767

68-
// CHECK-LABEL: sil hidden [transparent] [thunk] @_T0SC11CCImpedanceV2cf9ImpedanceA2cDP4real9ComponentQzfgTW
68+
// CHECK-LABEL: sil private [transparent] [thunk] @_T0SC11CCImpedanceV2cf9ImpedanceA2cDP4real9ComponentQzfgTW
6969
// CHECK-LABEL: sil shared [transparent] [serializable] @_T0SC11CCImpedanceV4realSdfg
70-
// CHECK-LABEL: sil hidden [transparent] [thunk] @_T0SC11CCImpedanceV2cf9ImpedanceA2cDP4imag9ComponentQzfgTW
70+
// CHECK-LABEL: sil private [transparent] [thunk] @_T0SC11CCImpedanceV2cf9ImpedanceA2cDP4imag9ComponentQzfgTW
7171
// CHECK-LABEL: sil shared [transparent] [serializable] @_T0SC11CCImpedanceV4imagSdfg
7272

7373
class MyMagnetism : CCMagnetismModel {

test/SILGen/dependent_member_lowering.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ struct Foo<T>: P {
99
typealias A = T.Type
1010

1111
func f(_ t: T.Type) {}
12-
// CHECK-LABEL: sil hidden [transparent] [thunk] @_T025dependent_member_lowering3FooVyxGAA1PAAlAaEP1fy1AQzFTW : $@convention(witness_method) <τ_0_0> (@in @thick τ_0_0.Type, @in_guaranteed Foo<τ_0_0>) -> ()
12+
// CHECK-LABEL: sil private [transparent] [thunk] @_T025dependent_member_lowering3FooVyxGAA1PAAlAaEP1fy1AQzFTW : $@convention(witness_method) <τ_0_0> (@in @thick τ_0_0.Type, @in_guaranteed Foo<τ_0_0>) -> ()
1313
// CHECK: bb0(%0 : $*@thick τ_0_0.Type, %1 : $*Foo<τ_0_0>):
1414
}
1515
struct Bar<T>: P {
1616
typealias A = (Int) -> T
1717

1818
func f(_ t: @escaping (Int) -> T) {}
19-
// CHECK-LABEL: sil hidden [transparent] [thunk] @_T025dependent_member_lowering3BarVyxGAA1PAAlAaEP1fy1AQzFTW : $@convention(witness_method) <τ_0_0> (@in @callee_owned (@in Int) -> @out τ_0_0, @in_guaranteed Bar<τ_0_0>) -> ()
19+
// CHECK-LABEL: sil private [transparent] [thunk] @_T025dependent_member_lowering3BarVyxGAA1PAAlAaEP1fy1AQzFTW : $@convention(witness_method) <τ_0_0> (@in @callee_owned (@in Int) -> @out τ_0_0, @in_guaranteed Bar<τ_0_0>) -> ()
2020
// CHECK: bb0(%0 : $*@callee_owned (@in Int) -> @out τ_0_0, %1 : $*Bar<τ_0_0>):
2121
}

test/SILGen/dynamic.swift

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -89,51 +89,51 @@ protocol Proto {
8989
// Protocol witnesses use best appropriate dispatch
9090

9191
// Native witnesses use vtable dispatch:
92-
// CHECK-LABEL: sil hidden [transparent] [thunk] @_T07dynamic3FooCAA5ProtoA2aDP12nativeMethod{{[_0-9a-zA-Z]*}}FTW
92+
// CHECK-LABEL: sil private [transparent] [thunk] @_T07dynamic3FooCAA5ProtoA2aDP12nativeMethod{{[_0-9a-zA-Z]*}}FTW
9393
// CHECK: class_method {{%.*}} : $Foo, #Foo.nativeMethod!1 :
94-
// CHECK-LABEL: sil hidden [transparent] [thunk] @_T07dynamic3FooCAA5ProtoA2aDP10nativePropSifgTW
94+
// CHECK-LABEL: sil private [transparent] [thunk] @_T07dynamic3FooCAA5ProtoA2aDP10nativePropSifgTW
9595
// CHECK: class_method {{%.*}} : $Foo, #Foo.nativeProp!getter.1 :
96-
// CHECK-LABEL: sil hidden [transparent] [thunk] @_T07dynamic3FooCAA5ProtoA2aDP10nativePropSifsTW
96+
// CHECK-LABEL: sil private [transparent] [thunk] @_T07dynamic3FooCAA5ProtoA2aDP10nativePropSifsTW
9797
// CHECK: class_method {{%.*}} : $Foo, #Foo.nativeProp!setter.1 :
98-
// CHECK-LABEL: sil hidden [transparent] [thunk] @_T07dynamic3FooCAA5ProtoA2aDP9subscriptS2i6native_tcfgTW
98+
// CHECK-LABEL: sil private [transparent] [thunk] @_T07dynamic3FooCAA5ProtoA2aDP9subscriptS2i6native_tcfgTW
9999
// CHECK: class_method {{%.*}} : $Foo, #Foo.subscript!getter.1 :
100-
// CHECK-LABEL: sil hidden [transparent] [thunk] @_T07dynamic3FooCAA5ProtoA2aDP9subscriptS2i6native_tcfsTW
100+
// CHECK-LABEL: sil private [transparent] [thunk] @_T07dynamic3FooCAA5ProtoA2aDP9subscriptS2i6native_tcfsTW
101101
// CHECK: class_method {{%.*}} : $Foo, #Foo.subscript!setter.1 :
102102

103103
// @objc witnesses use vtable dispatch:
104-
// CHECK-LABEL: sil hidden [transparent] [thunk] @_T07dynamic3FooCAA5ProtoA2aDP10objcMethod{{[_0-9a-zA-Z]*}}FTW
104+
// CHECK-LABEL: sil private [transparent] [thunk] @_T07dynamic3FooCAA5ProtoA2aDP10objcMethod{{[_0-9a-zA-Z]*}}FTW
105105
// CHECK: class_method {{%.*}} : $Foo, #Foo.objcMethod!1 :
106-
// CHECK-LABEL: sil hidden [transparent] [thunk] @_T07dynamic3FooCAA5ProtoA2aDP8objcPropSifgTW
106+
// CHECK-LABEL: sil private [transparent] [thunk] @_T07dynamic3FooCAA5ProtoA2aDP8objcPropSifgTW
107107
// CHECK: class_method {{%.*}} : $Foo, #Foo.objcProp!getter.1 :
108-
// CHECK-LABEL: sil hidden [transparent] [thunk] @_T07dynamic3FooCAA5ProtoA2aDP8objcPropSifsTW
108+
// CHECK-LABEL: sil private [transparent] [thunk] @_T07dynamic3FooCAA5ProtoA2aDP8objcPropSifsTW
109109
// CHECK: class_method {{%.*}} : $Foo, #Foo.objcProp!setter.1 :
110-
// CHECK-LABEL: sil hidden [transparent] [thunk] @_T07dynamic3FooCAA5ProtoA2aDP9subscriptSis9AnyObject_p4objc_tcfgTW
110+
// CHECK-LABEL: sil private [transparent] [thunk] @_T07dynamic3FooCAA5ProtoA2aDP9subscriptSis9AnyObject_p4objc_tcfgTW
111111
// CHECK: class_method {{%.*}} : $Foo, #Foo.subscript!getter.1 :
112-
// CHECK-LABEL: sil hidden [transparent] [thunk] @_T07dynamic3FooCAA5ProtoA2aDP9subscriptSis9AnyObject_p4objc_tcfsTW
112+
// CHECK-LABEL: sil private [transparent] [thunk] @_T07dynamic3FooCAA5ProtoA2aDP9subscriptSis9AnyObject_p4objc_tcfsTW
113113
// CHECK: class_method {{%.*}} : $Foo, #Foo.subscript!setter.1 :
114114

115115
// Dynamic witnesses use objc dispatch:
116-
// CHECK-LABEL: sil hidden [transparent] [thunk] @_T07dynamic3FooCAA5ProtoA2aDP0A6Method{{[_0-9a-zA-Z]*}}FTW
116+
// CHECK-LABEL: sil private [transparent] [thunk] @_T07dynamic3FooCAA5ProtoA2aDP0A6Method{{[_0-9a-zA-Z]*}}FTW
117117
// CHECK: function_ref @_T07dynamic3FooC0A6Method{{[_0-9a-zA-Z]*}}FTD
118118
// CHECK-LABEL: sil shared [transparent] [serializable] [thunk] @_T07dynamic3FooC0A6Method{{[_0-9a-zA-Z]*}}FTD
119119
// CHECK: class_method [volatile] {{%.*}} : $Foo, #Foo.dynamicMethod!1.foreign :
120120

121-
// CHECK-LABEL: sil hidden [transparent] [thunk] @_T07dynamic3FooCAA5ProtoA2aDP0A4PropSifgTW
121+
// CHECK-LABEL: sil private [transparent] [thunk] @_T07dynamic3FooCAA5ProtoA2aDP0A4PropSifgTW
122122
// CHECK: function_ref @_T07dynamic3FooC0A4PropSifgTD
123123
// CHECK-LABEL: sil shared [transparent] [serializable] [thunk] @_T07dynamic3FooC0A4PropSifgTD
124124
// CHECK: class_method [volatile] {{%.*}} : $Foo, #Foo.dynamicProp!getter.1.foreign :
125125

126-
// CHECK-LABEL: sil hidden [transparent] [thunk] @_T07dynamic3FooCAA5ProtoA2aDP0A4PropSifsTW
126+
// CHECK-LABEL: sil private [transparent] [thunk] @_T07dynamic3FooCAA5ProtoA2aDP0A4PropSifsTW
127127
// CHECK: function_ref @_T07dynamic3FooC0A4PropSifsTD
128128
// CHECK-LABEL: sil shared [transparent] [serializable] [thunk] @_T07dynamic3FooC0A4PropSifsTD
129129
// CHECK: class_method [volatile] {{%.*}} : $Foo, #Foo.dynamicProp!setter.1.foreign :
130130

131-
// CHECK-LABEL: sil hidden [transparent] [thunk] @_T07dynamic3FooCAA5ProtoA2aDP9subscriptS2iAA_tcfgTW
131+
// CHECK-LABEL: sil private [transparent] [thunk] @_T07dynamic3FooCAA5ProtoA2aDP9subscriptS2iAA_tcfgTW
132132
// CHECK: function_ref @_T07dynamic3FooC9subscriptS2iAA_tcfgTD
133133
// CHECK-LABEL: sil shared [transparent] [serializable] [thunk] @_T07dynamic3FooC9subscriptS2iAA_tcfgTD
134134
// CHECK: class_method [volatile] {{%.*}} : $Foo, #Foo.subscript!getter.1.foreign :
135135

136-
// CHECK-LABEL: sil hidden [transparent] [thunk] @_T07dynamic3FooCAA5ProtoA2aDP9subscriptS2iAA_tcfsTW
136+
// CHECK-LABEL: sil private [transparent] [thunk] @_T07dynamic3FooCAA5ProtoA2aDP9subscriptS2iAA_tcfsTW
137137
// CHECK: function_ref @_T07dynamic3FooC9subscriptS2iAA_tcfsTD
138138
// CHECK-LABEL: sil shared [transparent] [serializable] [thunk] @_T07dynamic3FooC9subscriptS2iAA_tcfsTD
139139
// CHECK: class_method [volatile] {{%.*}} : $Foo, #Foo.subscript!setter.1.foreign :

test/SILGen/errors.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ protocol Doomed {
217217
func check() throws
218218
}
219219

220-
// CHECK-LABEL: sil hidden [transparent] [thunk] @_T06errors12DoomedStructVAA0B0A2aDP5checkyyKFTW : $@convention(witness_method) (@in_guaranteed DoomedStruct) -> @error Error
220+
// CHECK-LABEL: sil private [transparent] [thunk] @_T06errors12DoomedStructVAA0B0A2aDP5checkyyKFTW : $@convention(witness_method) (@in_guaranteed DoomedStruct) -> @error Error
221221
// CHECK: [[TEMP:%.*]] = alloc_stack $DoomedStruct
222222
// CHECK: copy_addr %0 to [initialization] [[TEMP]]
223223
// CHECK: [[SELF:%.*]] = load [trivial] [[TEMP]] : $*DoomedStruct
@@ -235,7 +235,7 @@ struct DoomedStruct : Doomed {
235235
func check() throws {}
236236
}
237237

238-
// CHECK-LABEL: sil hidden [transparent] [thunk] @_T06errors11DoomedClassCAA0B0A2aDP5checkyyKFTW : $@convention(witness_method) (@in_guaranteed DoomedClass) -> @error Error {
238+
// CHECK-LABEL: sil private [transparent] [thunk] @_T06errors11DoomedClassCAA0B0A2aDP5checkyyKFTW : $@convention(witness_method) (@in_guaranteed DoomedClass) -> @error Error {
239239
// CHECK: [[TEMP:%.*]] = alloc_stack $DoomedClass
240240
// CHECK: copy_addr %0 to [initialization] [[TEMP]]
241241
// CHECK: [[SELF:%.*]] = load [take] [[TEMP]] : $*DoomedClass
@@ -258,7 +258,7 @@ class DoomedClass : Doomed {
258258
func check() throws {}
259259
}
260260

261-
// CHECK-LABEL: sil hidden [transparent] [thunk] @_T06errors11HappyStructVAA6DoomedA2aDP5checkyyKFTW : $@convention(witness_method) (@in_guaranteed HappyStruct) -> @error Error
261+
// CHECK-LABEL: sil private [transparent] [thunk] @_T06errors11HappyStructVAA6DoomedA2aDP5checkyyKFTW : $@convention(witness_method) (@in_guaranteed HappyStruct) -> @error Error
262262
// CHECK: [[TEMP:%.*]] = alloc_stack $HappyStruct
263263
// CHECK: copy_addr %0 to [initialization] [[TEMP]]
264264
// CHECK: [[SELF:%.*]] = load [trivial] [[TEMP]] : $*HappyStruct
@@ -271,7 +271,7 @@ struct HappyStruct : Doomed {
271271
func check() {}
272272
}
273273

274-
// CHECK-LABEL: sil hidden [transparent] [thunk] @_T06errors10HappyClassCAA6DoomedA2aDP5checkyyKFTW : $@convention(witness_method) (@in_guaranteed HappyClass) -> @error Error
274+
// CHECK-LABEL: sil private [transparent] [thunk] @_T06errors10HappyClassCAA6DoomedA2aDP5checkyyKFTW : $@convention(witness_method) (@in_guaranteed HappyClass) -> @error Error
275275
// CHECK: [[TEMP:%.*]] = alloc_stack $HappyClass
276276
// CHECK: copy_addr %0 to [initialization] [[TEMP]]
277277
// CHECK: [[SELF:%.*]] = load [take] [[TEMP]] : $*HappyClass

test/SILGen/functions.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ protocol AlwaysInline {
391391
// CHECK-LABEL: sil hidden [always_inline] @_T09functions19AlwaysInlinedMemberV06alwaysC0{{[_0-9a-zA-Z]*}}F : $@convention(method) (AlwaysInlinedMember) -> () {
392392

393393
// protocol witness for functions.AlwaysInline.alwaysInlined <A : functions.AlwaysInline>(functions.AlwaysInline.Self)() -> () in conformance functions.AlwaysInlinedMember : functions.AlwaysInline in functions
394-
// CHECK-LABEL: sil hidden [transparent] [thunk] [always_inline] @_T09functions19AlwaysInlinedMemberVAA0B6InlineA2aDP06alwaysC0{{[_0-9a-zA-Z]*}}FTW : $@convention(witness_method) (@in_guaranteed AlwaysInlinedMember) -> () {
394+
// CHECK-LABEL: sil private [transparent] [thunk] [always_inline] @_T09functions19AlwaysInlinedMemberVAA0B6InlineA2aDP06alwaysC0{{[_0-9a-zA-Z]*}}FTW : $@convention(witness_method) (@in_guaranteed AlwaysInlinedMember) -> () {
395395
struct AlwaysInlinedMember : AlwaysInline {
396396
@inline(__always)
397397
func alwaysInlined() {}

0 commit comments

Comments
 (0)