@@ -1194,3 +1194,35 @@ bb4:
1194
1194
%v = tuple ()
1195
1195
return %v : $()
1196
1196
}
1197
+
1198
+
1199
+ sil [ossa] @move_closure_callee : $@convention(thin) (@guaranteed { var Builtin.Int32 }) -> () {
1200
+ bb0(%box : @closureCapture @guaranteed ${ var Builtin.Int32 }):
1201
+ %13 = integer_literal $Builtin.Int32, 13
1202
+ %addr = project_box %box : ${ var Builtin.Int32 }, 0
1203
+ store %13 to [trivial] %addr : $*Builtin.Int32
1204
+ %retval = tuple ()
1205
+ return %retval : $()
1206
+ }
1207
+
1208
+ // CHECK-LABEL: sil [ossa] @move_closure : {{.*}} {
1209
+ // CHECK: [[SPECIALIZED_CLOSURE:%[^,]+]] = function_ref @$s19move_closure_calleeTf0s_n : $@convention(thin) (@inout_aliasable Builtin.Int32) -> ()
1210
+ // CHECK: partial_apply [callee_guaranteed] [[SPECIALIZED_CLOSURE]]
1211
+ // CHECK-LABEL: } // end sil function 'move_closure'
1212
+ sil [ossa] @move_closure : $@convention(thin) () -> Builtin.Int32 {
1213
+ bb0:
1214
+ %box = alloc_box ${ var Builtin.Int32 }
1215
+ %addr = project_box %box : ${ var Builtin.Int32 }, 0
1216
+ %42 = integer_literal $Builtin.Int32, 42
1217
+ store %42 to [trivial] %addr : $*Builtin.Int32
1218
+ %callee = function_ref @move_closure_callee : $@convention(thin) (@guaranteed { var Builtin.Int32 }) -> ()
1219
+ %box_copy = copy_value %box : ${ var Builtin.Int32 }
1220
+ mark_function_escape %addr : $*Builtin.Int32
1221
+ %closure = partial_apply [callee_guaranteed] %callee(%box_copy) : $@convention(thin) (@guaranteed { var Builtin.Int32 }) -> ()
1222
+ %closure_move = move_value %closure : $@callee_guaranteed () -> ()
1223
+ apply %closure_move() : $@callee_guaranteed () -> ()
1224
+ destroy_value %closure_move : $@callee_guaranteed () -> ()
1225
+ %value = load [trivial] %addr : $*Builtin.Int32
1226
+ destroy_value %box : ${ var Builtin.Int32 }
1227
+ return %value : $Builtin.Int32
1228
+ }
0 commit comments