Skip to content

Commit b35b7e6

Browse files
committed
Update comments
1 parent 8cd8e5b commit b35b7e6

File tree

1 file changed

+28
-9
lines changed

1 file changed

+28
-9
lines changed

test/SILOptimizer/package-cmo-keypath.swift

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,39 @@
1414

1515
//--- Lib.swift
1616
package protocol PkgProto {
17-
var pkgVar: String { get }
17+
/// Key path getter for a protocol property has a shared linkage as below, and a function referencing
18+
/// this getter (as well as this getter) should not be serialized in Package CMO, even if the `witness_method`
19+
/// in this getter has package or public access level.
20+
// key path getter for PkgProto.pkgVar : <A>A
21+
// sil shared [thunk] @$s3Lib8PkgProtoP6pkgVarSSvpAaBRzlxTK : $@convention(keypath_accessor_getter) <T where T : PkgProto> (@in_guaranteed T) -> @out String {
22+
// [%0: noescape **, write v**]
23+
// [%1: read v**, write v**, copy v**, destroy v**]
24+
// [global: read,write,copy,destroy,allocate,deinit_barrier]
25+
// // %0 // user: %4
26+
// // %1 // user: %3
27+
// bb0(%0 : $*String, %1 : $*T):
28+
// %2 = witness_method $T, #PkgProto.pkgVar!getter : <Self where Self : PkgProto> (Self) -> () -> String : $@convention(witness_method: PkgProto) <τ_0_0 where τ_0_0 : PkgProto> (@in_guaranteed τ_0_0) -> @owned String // user: %3
29+
// %3 = apply %2<T>(%1) : $@convention(witness_method: PkgProto) <τ_0_0 where τ_0_0 : PkgProto> (@in_guaranteed τ_0_0) -> @owned String // user: %4
30+
// store %3 to %0 : $*String // id: %4
31+
// %5 = tuple () // user: %6
32+
// return %5 : $() // id: %6
33+
// } // end sil function '$s3Lib8PkgProtoP6pkgVarSSvpAaBRzlxTK'
34+
var pkgVar: String { get }
35+
36+
// key path getter for PkgProto.pkgVar : <A>A
37+
// CHECK-NOT: sil [serialized_for_package] [thunk] [canonical] @$s3Lib8PkgProtoP6pkgVarSSvpAaBRzlxTK : $@convention(keypath_accessor_getter) <T where T : PkgProto> (@in_guaranteed T) -> @out String {
38+
// CHECK-NOT: witness_method $T, #PkgProto.pkgVar!getter : <Self where Self : PkgProto> (Self) -> () -> String : $@convention(witness_method: PkgProto) <τ_0_0 where τ_0_0 : PkgProto> (@in_guaranteed τ_0_0) -> @owned String // user: %3
39+
// CHECK-NOT: // end sil function '$s3Lib8PkgProtoP6pkgVarSSvpAaBRzlxTK'
1840
}
1941

2042
package struct Foo: PkgProto {
21-
package var pkgVar: String {
22-
return "Foo pkgVar"
23-
}
43+
package var pkgVar: String {
44+
return "Foo pkgVar"
45+
}
2446
}
2547

48+
/// testKeyPath references the keypath getter above, s3Lib8PkgProtoP6pkgVarSSvpAaBRzlxTK,
49+
/// and should not be serialized.
2650
// testKeyPath<A>(_:)
2751
// CHECK-NOT: sil package [serialized_for_package] [canonical] @$s3Lib11testKeyPathys0cD0CyxSSGSayxGAA8PkgProtoRzlF : $@convention(thin) <T where T : PkgProto> (@guaranteed Array<T>) -> @owned KeyPath<T, String> {
2852
// CHECK-NOT: keypath $KeyPath<T, String>, <τ_0_0 where τ_0_0 : PkgProto> (root $τ_0_0; gettable_property $String, id #PkgProto.pkgVar!getter : <Self where Self : PkgProto> (Self) -> () -> String, getter @$s3Lib8PkgProtoP6pkgVarSSvpAaBRzlxTK : $@convention(keypath_accessor_getter) <τ_0_0 where τ_0_0 : PkgProto> (@in_guaranteed τ_0_0) -> @out String) <T>
@@ -31,11 +55,6 @@ package func testKeyPath<T: PkgProto>(_ array: [T]) -> KeyPath<T, String> {
3155
return \T.pkgVar
3256
}
3357

34-
// key path getter for PkgProto.pkgVar : <A>A
35-
// CHECK-NOT: sil [serialized_for_package] [thunk] [canonical] @$s3Lib8PkgProtoP6pkgVarSSvpAaBRzlxTK : $@convention(keypath_accessor_getter) <T where T : PkgProto> (@in_guaranteed T) -> @out String {
36-
// CHECK-NOT: witness_method $T, #PkgProto.pkgVar!getter : <Self where Self : PkgProto> (Self) -> () -> String : $@convention(witness_method: PkgProto) <τ_0_0 where τ_0_0 : PkgProto> (@in_guaranteed τ_0_0) -> @owned String // user: %3
37-
// CHECK-NOT: // end sil function '$s3Lib8PkgProtoP6pkgVarSSvpAaBRzlxTK'
38-
3958
// CHECK: sil_witness_table package [serialized_for_package] Foo: PkgProto module Lib {
4059
// CHECK: method #PkgProto.pkgVar!getter: <Self where Self : PkgProto> (Self) -> () -> String : @$s3Lib3FooVAA8PkgProtoA2aDP6pkgVarSSvgTW
4160

0 commit comments

Comments
 (0)