@@ -66,6 +66,14 @@ sil_global private @g1_token : $Builtin.Word
66
66
sil_global [let] @g2 : $Int32
67
67
sil_global private @g2_token : $Builtin.Word
68
68
69
+ // CHECK-LABEL: sil_global [let] @g3 : $Optional<UnsafeMutablePointer<Int>>
70
+ sil_global [let] @g3 : $Optional<UnsafeMutablePointer<Int>>
71
+ sil_global private @g3_token : $Builtin.Word
72
+
73
+ // CHECK-LABEL: sil_global [let] @g4 : $Optional<UnsafeMutablePointer<Int>>
74
+ sil_global [let] @g4 : $Optional<UnsafeMutablePointer<Int>>
75
+ sil_global private @g4_token : $Builtin.Word
76
+
69
77
70
78
// CHECK-LABEL: sil [global_init_once_fn] [ossa] @globalinit_trivialglobal_func :
71
79
// CHECK-NOT: alloc_global
@@ -151,3 +159,33 @@ bb0:
151
159
return %6 : $()
152
160
}
153
161
162
+ // CHECK-LABEL: sil [global_init_once_fn] [ossa] @globalinit_enum :
163
+ // CHECK-NOT: alloc_global
164
+ // CHECK-NOT: store
165
+ // CHECK: } // end sil function 'globalinit_enum'
166
+ sil [global_init_once_fn] [ossa] @globalinit_enum : $@convention(c) () -> () {
167
+ bb0:
168
+ alloc_global @g3
169
+ %2 = global_addr @g3 : $*Optional<UnsafeMutablePointer<Int>>
170
+ %3 = enum $Optional<UnsafeMutablePointer<Int>>, #Optional.none!enumelt
171
+ store %3 to [trivial] %2 : $*Optional<UnsafeMutablePointer<Int>>
172
+ %5 = tuple ()
173
+ return %5 : $()
174
+ }
175
+
176
+ // CHECK-LABEL: sil [global_init_once_fn] [ossa] @globalinit_enum_inttoptr :
177
+ // CHECK-NOT: alloc_global
178
+ // CHECK-NOT: store
179
+ // CHECK: } // end sil function 'globalinit_enum_inttoptr'
180
+ sil [global_init_once_fn] [ossa] @globalinit_enum_inttoptr : $@convention(c) () -> () {
181
+ bb0:
182
+ alloc_global @g4
183
+ %2 = global_addr @g4 : $*Optional<UnsafeMutablePointer<Int>>
184
+ %4 = integer_literal $Builtin.Word, 1111638594
185
+ %5 = builtin "inttoptr_Word"(%4 : $Builtin.Word) : $Builtin.RawPointer
186
+ %6 = struct $UnsafeMutablePointer<Int> (%5 : $Builtin.RawPointer)
187
+ %7 = enum $Optional<UnsafeMutablePointer<Int>>, #Optional.some!enumelt, %6 : $UnsafeMutablePointer<Int>
188
+ store %7 to [trivial] %2 : $*Optional<UnsafeMutablePointer<Int>>
189
+ %10 = tuple ()
190
+ return %10 : $()
191
+ }
0 commit comments