@@ -3739,3 +3739,80 @@ bb0(%0 : $@thick SpecialEnum.Type):
3739
3739
%4 = struct $Bool (%3 : $Builtin.Int1)
3740
3740
return %4 : $Bool
3741
3741
}
3742
+
3743
+ struct IntTuple {
3744
+ @_hasStorage var t: (Int64, Int64)
3745
+ }
3746
+
3747
+ sil_global [let] @initialized_let_global : $Int64 = {
3748
+ %0 = integer_literal $Builtin.Int64, 27
3749
+ %initval = struct $Int64 (%0 : $Builtin.Int64)
3750
+ }
3751
+
3752
+ sil_global @initialized_var_global : $Int64 = {
3753
+ %0 = integer_literal $Builtin.Int64, 27
3754
+ %initval = struct $Int64 (%0 : $Builtin.Int64)
3755
+ }
3756
+
3757
+ sil_global [let] @initialized_tuple_global : $IntTuple = {
3758
+ %0 = integer_literal $Builtin.Int64, 27
3759
+ %1 = integer_literal $Builtin.Int64, 28
3760
+ %2 = struct $Int64 (%0 : $Builtin.Int64)
3761
+ %3 = struct $Int64 (%1 : $Builtin.Int64)
3762
+ %4 = tuple (%2 : $Int64, %3 : $Int64)
3763
+ %initval = struct $IntTuple (%4 : $(Int64, Int64))
3764
+ }
3765
+
3766
+ // CHECK-LABEL: sil @load_from_global_let
3767
+ // CHECK: [[I:%.*]] = integer_literal $Builtin.Int64, 27
3768
+ // CHECK: [[R:%.*]] = struct $Int64 ([[I]] : $Builtin.Int64)
3769
+ // CHECK: return [[R]]
3770
+ // CHECK: } // end sil function 'load_from_global_let'
3771
+ sil @load_from_global_let : $@convention(thin) () -> Int64 {
3772
+ bb0:
3773
+ %0 = global_addr @initialized_let_global : $*Int64
3774
+ %1 = load %0 : $*Int64
3775
+ return %1 : $Int64
3776
+ }
3777
+
3778
+ // CHECK-LABEL: sil @load_from_global_with_projections
3779
+ // CHECK: [[I:%.*]] = integer_literal $Builtin.Int64, 28
3780
+ // CHECK: return [[I]]
3781
+ // CHECK: } // end sil function 'load_from_global_with_projections'
3782
+ sil @load_from_global_with_projections : $@convention(thin) () -> Builtin.Int64 {
3783
+ bb0:
3784
+ %0 = global_addr @initialized_tuple_global : $*IntTuple
3785
+ %1 = struct_element_addr %0 : $*IntTuple, #IntTuple.t
3786
+ %2 = tuple_element_addr %1 : $*(Int64, Int64), 1
3787
+ %3 = struct_element_addr %2 : $*Int64, #Int64._value
3788
+ %4 = load %3 : $*Builtin.Int64
3789
+ return %4 : $Builtin.Int64
3790
+ }
3791
+
3792
+ // CHECK-LABEL: sil @load_from_global_without_projections
3793
+ // CHECK-DAG: [[I1:%.*]] = integer_literal $Builtin.Int64, 27
3794
+ // CHECK-DAG: [[I2:%.*]] = integer_literal $Builtin.Int64, 28
3795
+ // CHECK-DAG: [[S1:%.*]] = struct $Int64 ([[I1]] : $Builtin.Int64)
3796
+ // CHECK-DAG: [[S2:%.*]] = struct $Int64 ([[I2]] : $Builtin.Int64)
3797
+ // CHECK-DAG: [[T:%.*]] = tuple ([[S1]] : $Int64, [[S2]] : $Int64)
3798
+ // CHECK-DAG: [[IT:%.*]] = struct $IntTuple ([[T]] : $(Int64, Int64))
3799
+ // CHECK: return [[IT]]
3800
+ // CHECK: } // end sil function 'load_from_global_without_projections'
3801
+ sil @load_from_global_without_projections : $@convention(thin) () -> IntTuple {
3802
+ bb0:
3803
+ %0 = global_addr @initialized_tuple_global : $*IntTuple
3804
+ %1 = load %0 : $*IntTuple
3805
+ return %1 : $IntTuple
3806
+ }
3807
+
3808
+ // CHECK-LABEL: sil @load_from_global_var
3809
+ // CHECK: global_addr
3810
+ // CHECK-NEXT: load
3811
+ // CHECK-NEXT: return
3812
+ // CHECK: } // end sil function 'load_from_global_var'
3813
+ sil @load_from_global_var : $@convention(thin) () -> Int64 {
3814
+ bb0:
3815
+ %0 = global_addr @initialized_var_global : $*Int64
3816
+ %1 = load %0 : $*Int64
3817
+ return %1 : $Int64
3818
+ }
0 commit comments