Skip to content

Commit 84ba636

Browse files
authored
Merge pull request #70363 from tshortli/silgen-skip-non-exportable-property-wrapper-backing-inits
SILGen: Skip emitting non-exportable property wrapper backing inits
2 parents 026d3f0 + 5b95737 commit 84ba636

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

lib/SILGen/SILGen.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1666,6 +1666,9 @@ emitStoredPropertyInitialization(PatternBindingDecl *pbd, unsigned i) {
16661666

16671667
void SILGenModule::
16681668
emitPropertyWrapperBackingInitializer(VarDecl *var) {
1669+
if (M.getOptions().SkipNonExportableDecls)
1670+
return;
1671+
16691672
auto initInfo = var->getPropertyWrapperInitializerInfo();
16701673

16711674
if (initInfo.hasInitFromWrappedValue()) {

test/SILGen/skip_non_exportable_decls.swift

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,17 @@ public var publicGlobalVar = 1
9292
// CHECK: sil shared [serialized]{{.*}} @$s4Test023inlinableFuncWithNestedC0yyFyycyXEfU_ : $@convention(thin) () -> @owned @callee_guaranteed () -> () {
9393
// CHECK: sil shared [serialized]{{.*}} @$s4Test023inlinableFuncWithNestedC0yyFyycyXEfU_6$deferL_yyF : $@convention(thin) () -> () {
9494

95+
@propertyWrapper
96+
public struct PublicWrapper<T> {
97+
// CHECK: sil [transparent] [serialized]{{.*}} @$s4Test13PublicWrapperV12wrappedValuexvg : $@convention(method) <T> (@in_guaranteed PublicWrapper<T>) -> @out T {
98+
// CHECK: sil [transparent] [serialized]{{.*}} @$s4Test13PublicWrapperV12wrappedValuexvs : $@convention(method) <T> (@in T, @inout PublicWrapper<T>) -> () {
99+
// CHECK: sil [transparent] [serialized]{{.*}} @$s4Test13PublicWrapperV12wrappedValuexvM : $@yield_once @convention(method) <T> (@inout PublicWrapper<T>) -> @yields @inout T {
100+
public var wrappedValue: T
101+
102+
// CHECK: sil{{.*}} @$s4Test13PublicWrapperV12wrappedValueACyxGx_tcfC : $@convention(method) <T> (@in T, @thin PublicWrapper<T>.Type) -> @out PublicWrapper<T> {
103+
public init(wrappedValue: T) { self.wrappedValue = wrappedValue }
104+
}
105+
95106
private class PrivateClass {
96107
// CHECK-NO-SKIP: sil private{{.*}} @$s4Test12PrivateClass33_CFB3F9DC47F5EF9E1D08B58758351A08LLCfd : $@convention(method) (@guaranteed PrivateClass) -> @owned Builtin.NativeObject {
97108
// CHECK-SKIP-NOT: s4Test12PrivateClass33_CFB3F9DC47F5EF9E1D08B58758351A08LLCfd
@@ -124,6 +135,13 @@ public class PublicClass {
124135
// CHECK: sil [transparent] [serialized]{{.*}} @$s4Test11PublicClassC9publicVarSivM : $@yield_once @convention(method) (@guaranteed PublicClass) -> @yields @inout Int {
125136
public var publicVar = 1
126137

138+
// CHECK-NO-SKIP: sil{{.*}} @$s4Test11PublicClassC16publicWrappedVarSivpfP : $@convention(thin) (Int) -> PublicWrapper<Int> {
139+
// CHECK-SKIP-NOT: s4Test11PublicClassC16publicWrappedVarSivpfP
140+
// CHECK: sil{{.*}} @$s4Test11PublicClassC16publicWrappedVarSivg : $@convention(method) (@guaranteed PublicClass) -> Int {
141+
// CHECK: sil{{.*}} @$s4Test11PublicClassC16publicWrappedVarSivs : $@convention(method) (Int, @guaranteed PublicClass) -> () {
142+
// CHECK: sil{{.*}} @$s4Test11PublicClassC16publicWrappedVarSivM : $@yield_once @convention(method) (@guaranteed PublicClass) -> @yields @inout Int {
143+
@PublicWrapper public var publicWrappedVar = publicGlobalVar
144+
127145
// CHECK-NO-SKIP: sil hidden{{.*}} @$s4Test11PublicClassC14internalMethodyyF : $@convention(method) (@guaranteed PublicClass) -> () {
128146
// CHECK-SKIP-NOT: s4Test11PublicClassC14internalMethodyyF
129147
internal func internalMethod() {}
@@ -166,6 +184,9 @@ extension PublicClass {
166184
// CHECK-NEXT: #PublicClass.publicVar!getter
167185
// CHECK-NEXT: #PublicClass.publicVar!setter
168186
// CHECK-NEXT: #PublicClass.publicVar!modify
187+
// CHECK-NEXT: #PublicClass.publicWrappedVar!getter
188+
// CHECK-NEXT: #PublicClass.publicWrappedVar!setter
189+
// CHECK-NEXT: #PublicClass.publicWrappedVar!modify
169190
// CHECK-NO-SKIP-NEXT: #PublicClass.internalMethod
170191
// CHECK-SKIP-NOT: #PublicClass.internalMethod
171192
// CHECK-NO-SKIP-NEXT: #PublicClass.init!allocator

0 commit comments

Comments
 (0)