Skip to content

Commit 7148de5

Browse files
authored
[SILGen] Don't force thunks for Clang declarations to be serialized (#17146)
They "may be serialized", not "must be serialized". Small compile-time win (and helps decrease the frequency of SIL bugs around mixing Swift versions).
1 parent 7d26fe0 commit 7148de5

File tree

3 files changed

+23
-3
lines changed

3 files changed

+23
-3
lines changed

lib/SILGen/SILGenThunk.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ void SILGenModule::emitForeignToNativeThunk(SILDeclRef thunk) {
211211
SILFunction *f = getFunction(thunk, ForDefinition);
212212
f->setThunk(IsThunk);
213213
if (thunk.asForeign().isClangGenerated())
214-
f->setSerialized(IsSerialized);
214+
f->setSerialized(IsSerializable);
215215
preEmitFunction(thunk, thunk.getDecl(), f, thunk.getDecl());
216216
PrettyStackTraceSILFunction X("silgen emitForeignToNativeThunk", f);
217217
SILGenFunction(*this, *f).emitForeignToNativeThunk(thunk);

test/SILGen/external_definitions.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ hasNoPrototype()
2929
// CHECK-LABEL: sil shared [serializable] @$SSo7AnsibleC{{[_0-9a-zA-Z]*}}fC : $@convention(method) (@in Optional<Any>, @thick Ansible.Type) -> @owned Optional<Ansible>
3030

3131
// -- Native Swift thunk for NSAnse
32-
// CHECK: sil shared [serialized] [thunk] @$SSo6NSAnseySo7AnsibleCSgADFTO : $@convention(thin) (@guaranteed Optional<Ansible>) -> @owned Optional<Ansible> {
32+
// CHECK: sil shared [serializable] [thunk] @$SSo6NSAnseySo7AnsibleCSgADFTO : $@convention(thin) (@guaranteed Optional<Ansible>) -> @owned Optional<Ansible> {
3333
// CHECK: bb0([[ARG0:%.*]] : @guaranteed $Optional<Ansible>):
3434
// CHECK: [[ARG0_COPY:%.*]] = copy_value [[ARG0]]
3535
// CHECK: [[FUNC:%.*]] = function_ref @NSAnse : $@convention(c) (Optional<Ansible>) -> @autoreleased Optional<Ansible>

test/SILGen/objc_subscript.swift

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
1-
// RUN: %target-swift-emit-silgen -enable-sil-ownership %s -emit-verbose-sil -enable-objc-interop -disable-objc-attr-requires-foundation-module | %FileCheck %s
1+
// RUN: %empty-directory(%t)
2+
// RUN: %build-silgen-test-overlays
3+
4+
// RUN: %target-swift-emit-silgen(mock-sdk: -sdk %S/Inputs -I %t) -enable-sil-ownership %s -emit-verbose-sil -disable-objc-attr-requires-foundation-module | %FileCheck %s
5+
6+
// REQUIRES: objc_interop
7+
8+
import gizmo
29

310
@objc class ObjCClass {}
411

@@ -38,3 +45,16 @@ class B : A {
3845
}
3946
}
4047
}
48+
49+
protocol SubscriptProto {
50+
subscript(i: Int) -> Any! { get }
51+
}
52+
extension Guisemeau: SubscriptProto {}
53+
54+
// CHECK-LABEL: sil private [transparent] [thunk] @$SSo9GuisemeauC14objc_subscript14SubscriptProtoA2cDPyypSgSicigTW
55+
// CHECK: function_ref @$SSo9GuisemeauCyypSgSicigTO
56+
// CHECK: end sil function '$SSo9GuisemeauC14objc_subscript14SubscriptProtoA2cDPyypSgSicigTW'
57+
58+
// CHECK-LABEL: sil shared [serializable] [thunk] @$SSo9GuisemeauCyypSgSicigTO
59+
// CHECK: objc_method {{%[0-9]+}} : $Guisemeau, #Guisemeau.subscript!getter.1.foreign : (Guisemeau) -> (Int) -> Any?, $@convention(objc_method) (Int, Guisemeau) -> @autoreleased Optional<AnyObject>
60+
// CHECK: end sil function '$SSo9GuisemeauCyypSgSicigTO'

0 commit comments

Comments
 (0)