|
| 1 | +// RUN: %empty-directory(%t) |
| 2 | +// RUN: split-file %s %t |
| 3 | + |
| 4 | +// RUN: %target-build-swift -module-name=Lib -package-name Pkg -I%t -emit-silgen %t/Lib.swift -o %t/Lib-nonres.sil |
| 5 | +// RUN: %FileCheck %s --check-prefix=CHECK-NONRES < %t/Lib-nonres.sil |
| 6 | +// RUN: %target-build-swift -module-name=Lib -package-name Pkg -I%t -emit-silgen -O -wmo %t/Lib.swift | %FileCheck %s --check-prefix=CHECK-NONRES |
| 7 | +// RUN: %target-build-swift -module-name=Lib -package-name Pkg -I%t -emit-silgen %t/Lib.swift -enable-library-evolution -o %t/Lib-res.sil |
| 8 | +// RUN: %FileCheck %s < %t/Lib-res.sil |
| 9 | +// RUN: %target-build-swift -module-name=Lib -package-name Pkg -I%t -emit-silgen %t/Lib.swift -enable-library-evolution -O -wmo | %FileCheck %s |
| 10 | +// RUN: %target-build-swift -module-name=Lib -package-name Pkg -I%t -emit-silgen %t/Lib.swift -enable-library-evolution -Xfrontend -experimental-allow-non-resilient-access -Xfrontend -experimental-package-cmo -O -wmo | %FileCheck %s |
| 11 | + |
| 12 | +// RUN: %target-build-swift -module-name=Lib -package-name Pkg -I%t -emit-module %t/Lib.swift -enable-library-evolution -Xfrontend -experimental-allow-non-resilient-access -Xfrontend -experimental-package-cmo -O -wmo -o %t/Lib.swiftmodule |
| 13 | +// RUN: %target-build-swift -module-name=Client -package-name Pkg -I%t -emit-silgen %t/Client.swift -I %t | %FileCheck %s --check-prefix=CHECK-CLIENT |
| 14 | + |
| 15 | +//--- Client.swift |
| 16 | +import Lib |
| 17 | +public func client() { |
| 18 | + /// Should not be calling S.x.unsafeMutableAddressor when accessing resilient global var; |
| 19 | + /// instead, should be calling the opaque getter. |
| 20 | + // CHECK-CLIENT-NOT: s3Lib1SV1xSSvau |
| 21 | + // CHECK-CLIENT: function_ref @$s3Lib1SV1xSSvgZ |
| 22 | + print(S.x) |
| 23 | +} |
| 24 | + |
| 25 | +//--- Lib.swift |
| 26 | +public struct S { |
| 27 | + public static var x = "hello world" |
| 28 | +} |
| 29 | + |
| 30 | +// one-time initialization token for x |
| 31 | +// CHECK-NONRES: sil_global private @$s3Lib1SV1x_Wz : $Builtin.Word |
| 32 | +// CHECK: sil_global private @$s3Lib1SV1x_Wz : $Builtin.Word |
| 33 | + |
| 34 | +// static S.x |
| 35 | +// CHECK-NONRES: sil_global @$s3Lib1SV1xSSvpZ : $String |
| 36 | +// CHECK: sil_global private @$s3Lib1SV1xSSvpZ : $String |
| 37 | + |
| 38 | +// one-time initialization function for x |
| 39 | +// CHECK-NONRES: sil private [global_init_once_fn] [ossa] @$s3Lib1SV1x_WZ : $@convention(c) (Builtin.RawPointer) -> () { |
| 40 | +// CHECK: sil private [global_init_once_fn] [ossa] @$s3Lib1SV1x_WZ : $@convention(c) (Builtin.RawPointer) -> () { |
| 41 | + |
| 42 | +// S.x.unsafeMutableAddressor |
| 43 | +// CHECK-NONRES: sil [global_init] [ossa] @$s3Lib1SV1xSSvau : $@convention(thin) () -> Builtin.RawPointer { |
| 44 | +// CHECK: sil hidden [global_init] [ossa] @$s3Lib1SV1xSSvau : $@convention(thin) () -> Builtin.RawPointer { |
| 45 | +// CHECK: global_addr @$s3Lib1SV1x_Wz |
| 46 | +// CHECK: address_to_pointer |
| 47 | +// function_ref one-time initialization function for x |
| 48 | +// CHECK: function_ref @$s3Lib1SV1x_WZ |
| 49 | +// CHECK: global_addr @$s3Lib1SV1xSSvpZ |
| 50 | +// CHECK: address_to_pointer |
| 51 | + |
| 52 | +// static S.x.getter |
| 53 | +// CHECK-NONRES: sil [transparent] [serialized] [ossa] @$s3Lib1SV1xSSvgZ : $@convention(method) (@thin S.Type) -> @owned String { |
| 54 | +// CHECK: sil [ossa] @$s3Lib1SV1xSSvgZ : $@convention(method) (@thin S.Type) -> @owned String { |
0 commit comments