@@ -488,3 +488,63 @@ bb0(%0 : @guaranteed ${ var Int }, %1 : @guaranteed ${ var Int }):
488
488
%8 = apply %7(%0, %1) : $@convention(thin) (@guaranteed { var Int }, @guaranteed { var Int }) -> Int
489
489
return %8 : $Int
490
490
}
491
+
492
+ class C {}
493
+
494
+ sil @getC : $@convention(thin) () -> (@owned C)
495
+
496
+ sil [ossa] @borrow_c_box : $@convention(thin) (@guaranteed { var C }) -> () {
497
+ entry(%box : @guaranteed ${var C}):
498
+ %retval = tuple ()
499
+ return %retval : $()
500
+ }
501
+
502
+ // CHECK-LABEL: sil [ossa] @test_copy_applied : {{.*}} {
503
+ // CHECK: [[CLOSURE:%[^,]+]] = partial_apply
504
+ // CHECK: [[COPY:%[^,]+]] = copy_value [[CLOSURE]]
505
+ // CHECK: destroy_value [[CLOSURE]]
506
+ // CHECK: apply [[COPY]]()
507
+ // CHECK: destroy_addr
508
+ // CHECK: dealloc_stack
509
+ // CHECK-LABEL: } // end sil function 'test_copy_applied'
510
+ sil [ossa] @test_copy_applied : $@convention(thin) () -> () {
511
+ bb0:
512
+ %box = alloc_box ${ var C }, var, name "x"
513
+ %addr = project_box %box : ${ var C }, 0
514
+ %getC = function_ref @getC : $@convention(thin) () -> (@owned C)
515
+ %c = apply %getC() : $@convention(thin) () -> (@owned C)
516
+ store %c to [init] %addr : $*C
517
+
518
+ %borrow_int_box = function_ref @borrow_c_box : $@convention(thin) (@guaranteed { var C }) -> ()
519
+ %closure = partial_apply [callee_guaranteed] %borrow_int_box(%box) : $@convention(thin) (@guaranteed { var C }) -> ()
520
+ %copy = copy_value %closure : $@callee_guaranteed () -> ()
521
+ destroy_value %closure : $@callee_guaranteed () -> ()
522
+ apply %copy() : $@callee_guaranteed () -> ()
523
+ destroy_value %copy : $@callee_guaranteed () -> ()
524
+ %retval = tuple ()
525
+ return %retval : $()
526
+ }
527
+
528
+ // CHECK-LABEL: sil [ossa] @test_move_applied : {{.*}} {
529
+ // CHECK: [[CLOSURE:%[^,]+]] = partial_apply
530
+ // CHECK: [[MOVE:%[^,]+]] = move_value [[CLOSURE]]
531
+ // CHECK: apply [[MOVE]]()
532
+ // CHECK: destroy_addr
533
+ // CHECK: dealloc_stack
534
+ // CHECK-LABEL: } // end sil function 'test_move_applied'
535
+ sil [ossa] @test_move_applied : $@convention(thin) () -> () {
536
+ bb0:
537
+ %box = alloc_box ${ var C }, var, name "x"
538
+ %addr = project_box %box : ${ var C }, 0
539
+ %getC = function_ref @getC : $@convention(thin) () -> (@owned C)
540
+ %c = apply %getC() : $@convention(thin) () -> (@owned C)
541
+ store %c to [init] %addr : $*C
542
+
543
+ %borrow_int_box = function_ref @borrow_c_box : $@convention(thin) (@guaranteed { var C }) -> ()
544
+ %closure = partial_apply [callee_guaranteed] %borrow_int_box(%box) : $@convention(thin) (@guaranteed { var C }) -> ()
545
+ %move = move_value %closure : $@callee_guaranteed () -> ()
546
+ apply %move() : $@callee_guaranteed () -> ()
547
+ destroy_value %move : $@callee_guaranteed () -> ()
548
+ %retval = tuple ()
549
+ return %retval : $()
550
+ }
0 commit comments