Skip to content

Commit 8f40288

Browse files
committed
SILGen: Dynamic, curry, foreign thunks should be serializable
This fixes a crash when referencing partially-applied methods from @_inlineable functions. Also, curry thunks for private methods do not need shared linkage; private is sufficient.
1 parent f09610e commit 8f40288

28 files changed

+168
-91
lines changed

lib/AST/Decl.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1878,11 +1878,15 @@ static bool isVersionedInternalDecl(const ValueDecl *VD) {
18781878
if (VD->getAttrs().hasAttribute<VersionedAttr>())
18791879
return true;
18801880

1881-
if (auto *fn = dyn_cast<FuncDecl>(VD))
1882-
if (auto *ASD = fn->getAccessorStorageDecl())
1881+
if (auto *FD = dyn_cast<FuncDecl>(VD))
1882+
if (auto *ASD = FD->getAccessorStorageDecl())
18831883
if (ASD->getAttrs().hasAttribute<VersionedAttr>())
18841884
return true;
18851885

1886+
if (auto *EED = dyn_cast<EnumElementDecl>(VD))
1887+
if (EED->getParentEnum()->getAttrs().hasAttribute<VersionedAttr>())
1888+
return true;
1889+
18861890
return false;
18871891
}
18881892

lib/SIL/SILDeclRef.cpp

Lines changed: 45 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -430,24 +430,35 @@ SILLinkage SILDeclRef::getLinkage(ForDefinition_t forDefinition) const {
430430
return SILLinkage::Shared;
431431
moduleContext = moduleContext->getParent();
432432
}
433-
434-
// Currying and calling convention thunks have shared linkage.
435-
if (isThunk())
436-
// If a function declares a @_cdecl name, its native-to-foreign thunk
437-
// is exported with the visibility of the function.
438-
if (!isNativeToForeignThunk() || !d->getAttrs().hasAttribute<CDeclAttr>())
439-
return SILLinkage::Shared;
440-
441-
// Enum constructors are essentially the same as thunks, they are
433+
434+
// Enum constructors and curry thunks either have private or shared
435+
// linkage, dependings are essentially the same as thunks, they are
442436
// emitted by need and have shared linkage.
443-
if (isEnumElement())
437+
if (isEnumElement() || isCurried) {
438+
switch (d->getEffectiveAccess()) {
439+
case Accessibility::Private:
440+
case Accessibility::FilePrivate:
441+
return (forDefinition
442+
? SILLinkage::Private
443+
: SILLinkage::PrivateExternal);
444+
445+
default:
446+
return SILLinkage::Shared;
447+
}
448+
}
449+
450+
// Calling convention thunks have shared linkage.
451+
if (isForeignToNativeThunk())
444452
return SILLinkage::Shared;
445453

446-
// Declarations imported from Clang modules have shared linkage.
447-
const SILLinkage ClangLinkage = SILLinkage::Shared;
454+
// If a function declares a @_cdecl name, its native-to-foreign thunk
455+
// is exported with the visibility of the function.
456+
if (isNativeToForeignThunk() && !d->getAttrs().hasAttribute<CDeclAttr>())
457+
return SILLinkage::Shared;
448458

459+
// Declarations imported from Clang modules have shared linkage.
449460
if (isClangImported())
450-
return ClangLinkage;
461+
return SILLinkage::Shared;
451462

452463
// Otherwise, we have external linkage.
453464
switch (d->getEffectiveAccess()) {
@@ -529,18 +540,30 @@ IsSerialized_t SILDeclRef::isSerialized() const {
529540
if (auto closure = getAbstractClosureExpr())
530541
dc = closure->getLocalContext();
531542
else {
543+
auto *d = getDecl();
532544
dc = getDecl()->getInnermostDeclContext();
533545

534-
// Enum case constructors are serialized if the enum is @_versioned
535-
// or public.
546+
// Enum element constructors are serialized if the enum is
547+
// @_versioned or public.
536548
if (isEnumElement())
537-
if (cast<EnumDecl>(dc)->getEffectiveAccess() >= Accessibility::Public)
549+
if (d->getEffectiveAccess() >= Accessibility::Public)
538550
return IsSerialized;
539551

552+
// Currying thunks are serialized if referenced from an inlinable
553+
// context -- Sema's semantic checks ensure the serialization of
554+
// such a thunk is valid, since it must in turn reference a public
555+
// symbol, or dispatch via class_method or witness_method.
556+
if (isCurried)
557+
if (d->getEffectiveAccess() >= Accessibility::Public)
558+
return IsSerializable;
559+
560+
if (isForeignToNativeThunk())
561+
return IsSerializable;
562+
540563
// The allocating entry point for designated initializers are serialized
541564
// if the class is @_versioned or public.
542565
if (kind == SILDeclRef::Kind::Allocator) {
543-
auto *ctor = cast<ConstructorDecl>(getDecl());
566+
auto *ctor = cast<ConstructorDecl>(d);
544567
if (ctor->isDesignatedInit() &&
545568
ctor->getDeclContext()->getAsClassOrClassExtensionContext()) {
546569
if (ctor->getEffectiveAccess() >= Accessibility::Public &&
@@ -550,6 +573,11 @@ IsSerialized_t SILDeclRef::isSerialized() const {
550573
}
551574
}
552575

576+
// Declarations imported from Clang modules are serialized if
577+
// referenced from an inlineable context.
578+
if (isClangImported())
579+
return IsSerializable;
580+
553581
// Otherwise, ask the AST if we're inside an @_inlineable context.
554582
if (dc->getResilienceExpansion() == ResilienceExpansion::Minimal)
555583
return IsSerialized;

lib/SIL/SILModule.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -347,9 +347,7 @@ SILFunction *SILModule::getOrCreateFunction(SILLocation loc,
347347
IsTransparent_t IsTrans = constant.isTransparent()
348348
? IsTransparent
349349
: IsNotTransparent;
350-
IsSerialized_t IsSer = constant.isSerialized()
351-
? IsSerialized
352-
: IsNotSerialized;
350+
IsSerialized_t IsSer = constant.isSerialized();
353351

354352
EffectsKind EK = constant.hasEffectsAttribute()
355353
? constant.getEffectsAttribute()

lib/SILGen/SILGenThunk.cpp

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,9 @@ SILFunction *SILGenModule::getDynamicThunk(SILDeclRef constant,
3838
// Mangle the constant with a _TTD header.
3939
auto name = constant.mangle(SILDeclRef::ManglingKind::DynamicThunk);
4040

41-
IsSerialized_t isSerialized = IsNotSerialized;
42-
if (makeModuleFragile)
43-
isSerialized = IsSerialized;
44-
if (constant.isSerialized())
45-
isSerialized = IsSerialized;
4641
auto F = M.getOrCreateFunction(constant.getDecl(), name, SILLinkage::Shared,
47-
constantInfo.getSILType().castTo<SILFunctionType>(),
48-
IsBare, IsTransparent, isSerialized, IsThunk);
42+
constantInfo.SILFnType, IsBare, IsTransparent,
43+
IsSerializable, IsThunk);
4944

5045
if (F->empty()) {
5146
// Emit the thunk if we haven't yet.

lib/SILGen/SILGenType.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -640,7 +640,9 @@ SILGenModule::emitProtocolWitness(ProtocolConformance *conformance,
640640
IsSerialized_t isSerialized = IsNotSerialized;
641641
if (makeModuleFragile)
642642
isSerialized = IsSerialized;
643-
if (witnessRef.isSerialized())
643+
if (witnessRef.isSerialized() &&
644+
(hasSharedVisibility(linkage) ||
645+
hasPublicVisibility(linkage)))
644646
isSerialized = IsSerialized;
645647

646648
auto *f = M.createFunction(

test/ClangImporter/static_inline.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
// RUN: %FileCheck < %t/test.sil %s
77
// RUN: %target-swift-frontend -parse-as-library -module-name=test -O -emit-ir %t/test.sil -import-objc-header %S/Inputs/static_inline.h | %FileCheck --check-prefix=CHECK-IR %s
88

9-
// CHECK: sil shared [clang c_inline_func] @c_inline_func : $@convention(c) (Int32) -> Int32
9+
// CHECK: sil shared [serializable] [clang c_inline_func] @c_inline_func : $@convention(c) (Int32) -> Int32
1010

1111
// CHECK-IR-LABEL: define{{.*}} i32 @_T04test6testits5Int32VAD1x_tF(i32)
1212
// CHECK-IR: = add {{.*}}, 27

test/SILGen/c_materializeForSet_linkage.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ extension NSReferencePoint: Pointable {}
1616
// Make sure synthesized materializeForSet and its callbacks have shared linkage
1717
// for properties imported from Clang
1818

19-
// CHECK-LABEL: sil shared [transparent] [serialized] @_T0SC7NSPointV1xSffm
20-
// CHECK-LABEL: sil shared [transparent] [serialized] @_T0SC7NSPointV1ySffm
19+
// CHECK-LABEL: sil shared [transparent] [serializable] @_T0SC7NSPointV1xSffm
20+
// CHECK-LABEL: sil shared [transparent] [serializable] @_T0SC7NSPointV1ySffm
2121

22-
// CHECK-LABEL: sil shared @_T0So16NSReferencePointC1xSffmytfU_
23-
// CHECK-LABEL: sil shared @_T0So16NSReferencePointC1xSffm
22+
// CHECK-LABEL: sil shared [serializable] @_T0So16NSReferencePointC1xSffmytfU_
23+
// CHECK-LABEL: sil shared [serializable] @_T0So16NSReferencePointC1xSffm
2424

25-
// CHECK-LABEL: sil shared @_T0So16NSReferencePointC1ySffmytfU_
26-
// CHECK-LABEL: sil shared @_T0So16NSReferencePointC1ySffm
25+
// CHECK-LABEL: sil shared [serializable] @_T0So16NSReferencePointC1ySffmytfU_
26+
// CHECK-LABEL: sil shared [serializable] @_T0So16NSReferencePointC1ySffm

test/SILGen/cf.swift

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

6666
extension CCImpedance: Impedance {}
6767

68-
// CHECK-LABEL: sil hidden [transparent] [serialized] [thunk] @_T0SC11CCImpedanceV2cf9ImpedanceA2cDP4real9ComponentQzfgTW
69-
// CHECK-LABEL: sil shared [transparent] [serialized] @_T0SC11CCImpedanceV4realSdfg
70-
// CHECK-LABEL: sil hidden [transparent] [serialized] [thunk] @_T0SC11CCImpedanceV2cf9ImpedanceA2cDP4imag9ComponentQzfgTW
71-
// CHECK-LABEL: sil shared [transparent] [serialized] @_T0SC11CCImpedanceV4imagSdfg
68+
// CHECK-LABEL: sil hidden [transparent] [thunk] @_T0SC11CCImpedanceV2cf9ImpedanceA2cDP4real9ComponentQzfgTW
69+
// CHECK-LABEL: sil shared [transparent] [serializable] @_T0SC11CCImpedanceV4realSdfg
70+
// CHECK-LABEL: sil hidden [transparent] [thunk] @_T0SC11CCImpedanceV2cf9ImpedanceA2cDP4imag9ComponentQzfgTW
71+
// CHECK-LABEL: sil shared [transparent] [serializable] @_T0SC11CCImpedanceV4imagSdfg
7272

7373
class MyMagnetism : CCMagnetismModel {
7474
// CHECK-LABEL: sil hidden [thunk] @_T02cf11MyMagnetismC15getRefrigerator{{[_0-9a-zA-Z]*}}FTo : $@convention(objc_method) (MyMagnetism) -> @autoreleased CCRefrigerator

test/SILGen/cf_members.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -202,37 +202,37 @@ public func foo(_ x: Double) {
202202
}
203203
// CHECK: } // end sil function '_T010cf_members3foo{{[_0-9a-zA-Z]*}}F'
204204

205-
// CHECK-LABEL: sil shared [thunk] @_T0SC7Struct1VABSd5value_tcfCTO
205+
// CHECK-LABEL: sil shared [serializable] [thunk] @_T0SC7Struct1VABSd5value_tcfCTO
206206
// CHECK: bb0([[X:%.*]] : $Double, [[SELF:%.*]] : $@thin Struct1.Type):
207207
// CHECK: [[CFUNC:%.*]] = function_ref @IAMStruct1CreateSimple
208208
// CHECK: [[RET:%.*]] = apply [[CFUNC]]([[X]])
209209
// CHECK: return [[RET]]
210210

211-
// CHECK-LABEL: sil shared [thunk] @_T0SC7Struct1V9translateABSd7radians_tFTO
211+
// CHECK-LABEL: sil shared [serializable] [thunk] @_T0SC7Struct1V9translateABSd7radians_tFTO
212212
// CHECK: bb0([[X:%.*]] : $Double, [[SELF:%.*]] : $Struct1):
213213
// CHECK: store [[SELF]] to [trivial] [[TMP:%.*]] :
214214
// CHECK: [[CFUNC:%.*]] = function_ref @IAMStruct1Rotate
215215
// CHECK: [[RET:%.*]] = apply [[CFUNC]]([[TMP]], [[X]])
216216
// CHECK: return [[RET]]
217217

218-
// CHECK-LABEL: sil shared [thunk] @_T0SC7Struct1V5scaleABSdFTO
218+
// CHECK-LABEL: sil shared [serializable] [thunk] @_T0SC7Struct1V5scaleABSdFTO
219219
// CHECK: bb0([[X:%.*]] : $Double, [[SELF:%.*]] : $Struct1):
220220
// CHECK: [[CFUNC:%.*]] = function_ref @IAMStruct1Scale
221221
// CHECK: [[RET:%.*]] = apply [[CFUNC]]([[SELF]], [[X]])
222222
// CHECK: return [[RET]]
223223

224-
// CHECK-LABEL: sil shared [thunk] @_T0SC7Struct1V12staticMethods5Int32VyFZTO
224+
// CHECK-LABEL: sil shared [serializable] [thunk] @_T0SC7Struct1V12staticMethods5Int32VyFZTO
225225
// CHECK: bb0([[SELF:%.*]] : $@thin Struct1.Type):
226226
// CHECK: [[CFUNC:%.*]] = function_ref @IAMStruct1StaticMethod
227227
// CHECK: [[RET:%.*]] = apply [[CFUNC]]()
228228
// CHECK: return [[RET]]
229229

230-
// CHECK-LABEL: sil shared [thunk] @_T0SC7Struct1V13selfComesLastySd1x_tFTO
230+
// CHECK-LABEL: sil shared [serializable] [thunk] @_T0SC7Struct1V13selfComesLastySd1x_tFTO
231231
// CHECK: bb0([[X:%.*]] : $Double, [[SELF:%.*]] : $Struct1):
232232
// CHECK: [[CFUNC:%.*]] = function_ref @IAMStruct1SelfComesLast
233233
// CHECK: apply [[CFUNC]]([[X]], [[SELF]])
234234

235-
// CHECK-LABEL: sil shared [thunk] @_T0SC7Struct1V14selfComesThirdys5Int32V1a_Sf1bSd1xtFTO
235+
// CHECK-LABEL: sil shared [serializable] [thunk] @_T0SC7Struct1V14selfComesThirdys5Int32V1a_Sf1bSd1xtFTO
236236
// CHECK: bb0([[X:%.*]] : $Int32, [[Y:%.*]] : $Float, [[Z:%.*]] : $Double, [[SELF:%.*]] : $Struct1):
237237
// CHECK: [[CFUNC:%.*]] = function_ref @IAMStruct1SelfComesThird
238238
// CHECK: apply [[CFUNC]]([[X]], [[Y]], [[SELF]], [[Z]])

test/SILGen/dynamic.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ protocol Proto {
7676
// TODO: dynamic initializing ctor must be objc dispatched
7777
// CHECK-LABEL: sil hidden @_T07dynamic3{{[_0-9a-zA-Z]*}}fC
7878
// CHECK: function_ref @_T07dynamic3{{[_0-9a-zA-Z]*}}fcTD
79-
// CHECK-LABEL: sil shared [transparent] [thunk] @_T07dynamic3{{[_0-9a-zA-Z]*}}fcTD
79+
// CHECK-LABEL: sil shared [transparent] [serializable] [thunk] @_T07dynamic3{{[_0-9a-zA-Z]*}}fcTD
8080
// CHECK: class_method [volatile] {{%.*}} : $Foo, #Foo.init!initializer.1.foreign :
8181

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

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

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

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

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

141141
// Superclass dispatch

test/SILGen/extensions_objc.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ func extensionMethodCurrying(_ x: Foo) {
3131

3232
// CHECK-LABEL: sil shared [thunk] @_T015extensions_objc3FooC3kayyyFTc
3333
// CHECK: function_ref @_T015extensions_objc3FooC3kayyyFTD
34-
// CHECK-LABEL: sil shared [transparent] [thunk] @_T015extensions_objc3FooC3kayyyFTD
34+
// CHECK-LABEL: sil shared [transparent] [serializable] [thunk] @_T015extensions_objc3FooC3kayyyFTD
3535
// CHECK: bb0([[SELF:%.*]] : $Foo):
3636
// CHECK: [[SELF_COPY:%.*]] = copy_value [[SELF]]
3737
// CHECK: class_method [volatile] [[SELF_COPY]] : $Foo, #Foo.kay!1.foreign

test/SILGen/external_definitions.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ hasNoPrototype()
2525
// CHECK: apply [[NOPROTO]]()
2626

2727
// -- Constructors for imported Ansible
28-
// CHECK-LABEL: sil shared @_T0So7AnsibleC{{[_0-9a-zA-Z]*}}fC : $@convention(method) (@in Optional<Any>, @thick Ansible.Type) -> @owned Optional<Ansible>
28+
// CHECK-LABEL: sil shared [serializable] @_T0So7AnsibleC{{[_0-9a-zA-Z]*}}fC : $@convention(method) (@in Optional<Any>, @thick Ansible.Type) -> @owned Optional<Ansible>
2929

3030

3131
// -- Constructors for imported NSObject
32-
// CHECK-LABEL: sil shared @_T0So8NSObjectC{{[_0-9a-zA-Z]*}}fC : $@convention(method) (@thick NSObject.Type) -> @owned NSObject
32+
// CHECK-LABEL: sil shared [serializable] @_T0So8NSObjectC{{[_0-9a-zA-Z]*}}fC : $@convention(method) (@thick NSObject.Type) -> @owned NSObject
3333

3434
// -- Native Swift thunk for NSAnse
3535
// CHECK: sil shared [serialized] [thunk] @_T0SC6NSAnseSQySo7AnsibleCGADFTO : $@convention(thin) (@owned Optional<Ansible>) -> @owned Optional<Ansible> {
@@ -41,5 +41,5 @@ hasNoPrototype()
4141
// CHECK: }
4242

4343
// -- Constructor for imported Ansible was unused, should not be emitted.
44-
// CHECK-NOT: sil shared @_T0So7AnsibleC{{[_0-9a-zA-Z]*}}fC : $@convention(method) (@thick Ansible.Type) -> @owned Ansible
44+
// CHECK-NOT: sil {{.*}} @_T0So7AnsibleC{{[_0-9a-zA-Z]*}}fC : $@convention(method) (@thick Ansible.Type) -> @owned Ansible
4545

test/SILGen/foreign_errors.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,12 +148,12 @@ extension NSObject {
148148
}
149149

150150
let fn = ErrorProne.fail
151-
// CHECK-LABEL: sil shared [thunk] @_T0So10ErrorProneC4failyyKFZTcTO : $@convention(thin) (@thick ErrorProne.Type) -> @owned @callee_owned () -> @error Error
151+
// CHECK-LABEL: sil shared [serializable] [thunk] @_T0So10ErrorProneC4failyyKFZTcTO : $@convention(thin) (@thick ErrorProne.Type) -> @owned @callee_owned () -> @error Error
152152
// CHECK: [[T0:%.*]] = function_ref @_T0So10ErrorProneC4failyyKFZTO : $@convention(method) (@thick ErrorProne.Type) -> @error Error
153153
// CHECK-NEXT: [[T1:%.*]] = partial_apply [[T0]](%0)
154154
// CHECK-NEXT: return [[T1]]
155155

156-
// CHECK-LABEL: sil shared [thunk] @_T0So10ErrorProneC4failyyKFZTO : $@convention(method) (@thick ErrorProne.Type) -> @error Error {
156+
// CHECK-LABEL: sil shared [serializable] [thunk] @_T0So10ErrorProneC4failyyKFZTO : $@convention(method) (@thick ErrorProne.Type) -> @error Error {
157157
// CHECK: [[SELF:%.*]] = thick_to_objc_metatype %0 : $@thick ErrorProne.Type to $@objc_metatype ErrorProne.Type
158158
// CHECK: [[METHOD:%.*]] = class_method [volatile] [[T0]] : $@objc_metatype ErrorProne.Type, #ErrorProne.fail!1.foreign : (ErrorProne.Type) -> () throws -> (), $@convention(objc_method) (Optional<AutoreleasingUnsafeMutablePointer<Optional<NSError>>>, @objc_metatype ErrorProne.Type) -> ObjCBool
159159
// CHECK: [[TEMP:%.*]] = alloc_stack $Optional<NSError>

test/SILGen/guaranteed_self.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,7 @@ class D: C {
388388
super.init()
389389
}
390390

391-
// CHECK-LABEL: sil shared [transparent] [thunk] @_T015guaranteed_self1DC3foo{{[_0-9a-zA-Z]*}}FTD : $@convention(method) (Int, @guaranteed D) -> ()
391+
// CHECK-LABEL: sil shared [transparent] [serializable] [thunk] @_T015guaranteed_self1DC3foo{{[_0-9a-zA-Z]*}}FTD : $@convention(method) (Int, @guaranteed D) -> ()
392392
// CHECK: bb0({{.*}} [[SELF:%.*]]):
393393
// CHECK: [[SELF_COPY:%.*]] = copy_value [[SELF]]
394394
// CHECK: destroy_value [[SELF_COPY]]
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// RUN: %target-swift-frontend -emit-silgen -import-objc-header %S/Inputs/array_typedef.h %s | %FileCheck %s
22

3-
// CHECK-LABEL: sil shared [transparent] [serialized] @_T0SC4NameV{{[_0-9a-zA-Z]*}}fC : $@convention(method) (UInt8, UInt8, UInt8, UInt8, @thin Name.Type) -> Name
3+
// CHECK-LABEL: sil shared [transparent] [serializable] @_T0SC4NameV{{[_0-9a-zA-Z]*}}fC : $@convention(method) (UInt8, UInt8, UInt8, UInt8, @thin Name.Type) -> Name
44
func useImportedArrayTypedefInit() -> Name {
55
return Name(name: (0, 0, 0, 0))
66
}

test/SILGen/inlineable_attribute.swift

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,21 @@ public struct HasInitializers {
5656

5757
@_inlineable public init() {}
5858
}
59+
60+
public class Horse {
61+
public func gallop() {}
62+
}
63+
64+
// CHECK-LABEL: sil [serialized] @_T020inlineable_attribute15talkAboutAHorseyAA5HorseC1h_tF : $@convention(thin) (@owned Horse) -> () {
65+
// CHECK: function_ref @_T020inlineable_attribute5HorseC6gallopyyFTc
66+
// CHECK: return
67+
// CHECK: }
68+
69+
// CHECK-LABEL: sil shared [serializable] [thunk] @_T020inlineable_attribute5HorseC6gallopyyFTc : $@convention(thin) (@owned Horse) -> @owned @callee_owned () -> () {
70+
// CHECK: class_method
71+
// CHECK: return
72+
// CHECK: }
73+
74+
@_inlineable public func talkAboutAHorse(h: Horse) {
75+
_ = h.gallop
76+
}

0 commit comments

Comments
 (0)