@@ -841,12 +841,44 @@ bb0(%0 : $*C, %1 : $*C):
841
841
sil_global hidden [let] @globalC : $C
842
842
sil_global hidden @globalCVar : $C
843
843
844
+ // CHECK-LABEL: @testGlobalLet
845
+ // CHECK: PAIR #1.
846
+ // CHECK-NEXT: %3 = apply %2() : $@convention(thin) () -> ()
847
+ // CHECK-NEXT: %0 = global_addr @globalC : $*C
848
+ // CHECK-NEXT: r=1,w=0
849
+ sil hidden @testGlobalLet : $@convention(thin) () -> () {
850
+ bb0:
851
+ %0 = global_addr @globalC : $*C
852
+ %1 = load %0 : $*C
853
+ %2 = function_ref @nouser_func : $@convention(thin) () -> ()
854
+ %3 = apply %2() : $@convention(thin) () -> ()
855
+ %4 = function_ref @read_C : $@convention(thin) (@in_guaranteed C) -> ()
856
+ %5 = apply %4(%0) : $@convention(thin) (@in_guaranteed C) -> ()
857
+ %8 = tuple ()
858
+ return %8 : $()
859
+ }
860
+
844
861
// CHECK-LABEL: @testInitGlobalLet
845
862
// CHECK: PAIR #0.
846
863
// CHECK-NEXT: %2 = apply %1(%0) : $@convention(thin) () -> @out C
847
864
// CHECK-NEXT: %0 = global_addr @globalC : $*C
848
865
// CHECK-NEXT: r=1,w=1
849
- sil hidden @testInitGlobalLet : $@convention(thin) () -> () {
866
+ sil hidden [global_init_once_fn] @testInitGlobalLet : $@convention(thin) () -> () {
867
+ bb0:
868
+ %0 = global_addr @globalC : $*C
869
+ %1 = function_ref @init_C : $@convention(thin) () -> @out C
870
+ %2 = apply %1(%0) : $@convention(thin) () -> @out C
871
+ %3 = load %0 : $*C
872
+ %8 = tuple ()
873
+ return %8 : $()
874
+ }
875
+
876
+ // CHECK-LABEL: @main
877
+ // CHECK: PAIR #0.
878
+ // CHECK-NEXT: %2 = apply %1(%0) : $@convention(thin) () -> @out C
879
+ // CHECK-NEXT: %0 = global_addr @globalC : $*C
880
+ // CHECK-NEXT: r=1,w=1
881
+ sil [global_init_once_fn] @main : $@convention(thin) () -> () {
850
882
bb0:
851
883
%0 = global_addr @globalC : $*C
852
884
%1 = function_ref @init_C : $@convention(thin) () -> @out C
@@ -885,6 +917,25 @@ bb0:
885
917
return %1 : $Builtin.RawPointer
886
918
}
887
919
920
+ // CHECK-LABEL: @testGlobalViaAddressorLet
921
+ // CHECK: PAIR #2.
922
+ // CHECK-NEXT: %5 = apply %4() : $@convention(thin) () -> ()
923
+ // CHECK-NEXT: %2 = pointer_to_address %1 : $Builtin.RawPointer to [strict] $*C
924
+ // CHECK-NEXT: r=1,w=0
925
+ sil @testGlobalViaAddressorLet : $@convention(thin) () -> () {
926
+ bb0:
927
+ %0 = function_ref @addressor_of_globalC : $@convention(thin) () -> Builtin.RawPointer
928
+ %1 = apply %0() : $@convention(thin) () -> Builtin.RawPointer
929
+ %2 = pointer_to_address %1 : $Builtin.RawPointer to [strict] $*C
930
+ %3 = load %2 : $*C
931
+ %4 = function_ref @nouser_func : $@convention(thin) () -> ()
932
+ %5 = apply %4() : $@convention(thin) () -> ()
933
+ %6 = function_ref @read_C : $@convention(thin) (@in_guaranteed C) -> ()
934
+ %7 = apply %6(%2) : $@convention(thin) (@in_guaranteed C) -> ()
935
+ %8 = tuple ()
936
+ return %8 : $()
937
+ }
938
+
888
939
// CHECK-LABEL: @testGlobalViaAddressorVar
889
940
// CHECK: PAIR #2.
890
941
// CHECK-NEXT: %5 = apply %4() : $@convention(thin) () -> ()
0 commit comments