@@ -28,6 +28,16 @@ sil @use_big_struct : $@convention(thin) (BigStruct) -> ()
28
28
29
29
sil @takeClosure : $@convention(thin) (@guaranteed @noescape @callee_guaranteed () -> ()) -> ()
30
30
31
+ typealias Invocation = @convention(thin) (BigStruct) -> ()
32
+
33
+ struct InvocationWrapper {
34
+ let invocation: Invocation
35
+ }
36
+
37
+ sil_global hidden [let] @invocation : $InvocationWrapper
38
+
39
+ sil @invocationClosure : $@convention(thin) (BigStruct) -> ()
40
+
31
41
// CHECK-LABEL: sil_global @globalWithClosureInStruct : $ContainsClosure = {
32
42
// CHECK: %0 = function_ref @make_big_struct : $@convention(thin) () -> @out BigStruct
33
43
// CHECK-NEXT: %1 = thin_to_thick_function %0 : $@convention(thin) () -> @out BigStruct to $@callee_guaranteed () -> @out BigStruct
@@ -158,3 +168,18 @@ bb0(%0 : @closureCapture $BigStruct):
158
168
%2 = tuple ()
159
169
return %2 : $()
160
170
}
171
+
172
+ // Test a rewritten function_ref stored in a struct property.
173
+ // CHECK-LABEL: sil [global_init_once_fn] @test_invocation : $@convention(c) (Builtin.RawPointer) -> () {
174
+ // CHECK: [[F:%[0-9]+]] = function_ref @invocationClosure : $@convention(thin) (@in_guaranteed BigStruct) -> ()
175
+ // CHECK: = struct $InvocationWrapper ([[F]] : $@convention(thin) (@in_guaranteed BigStruct) -> ())
176
+ sil [global_init_once_fn] @test_invocation : $@convention(c) (Builtin.RawPointer) -> () {
177
+ bb0(%0 : $Builtin.RawPointer):
178
+ alloc_global @invocation
179
+ %g = global_addr @invocation : $*InvocationWrapper
180
+ %f = function_ref @invocationClosure : $@convention(thin) (BigStruct) -> ()
181
+ %s = struct $InvocationWrapper (%f : $@convention(thin) (BigStruct) -> ())
182
+ store %s to %g : $*InvocationWrapper
183
+ %r = tuple ()
184
+ return %r : $()
185
+ }
0 commit comments