@@ -553,3 +553,39 @@ bb0:
553
553
%28 = tuple ()
554
554
return %28 : $()
555
555
}
556
+
557
+ sil [ossa] @closable : $@convention(thin) (@guaranteed { var Bar }) -> Builtin.Int64 {
558
+ entry(%box : @guaranteed ${ var Bar }):
559
+ %retval = integer_literal $Builtin.Int64, 0
560
+ return %retval : $Builtin.Int64
561
+ }
562
+
563
+ // Test that a dealloc_box is not regarded as a mutation which would obstruct promotion.
564
+ // CHECK-LABEL: sil [ossa] @with_dealloc_box : {{.*}} {
565
+ // CHECK: load [copy]
566
+ // CHECK-LABEL: } // end sil function 'with_dealloc_box'
567
+ sil [ossa] @with_dealloc_box : $@convention(thin) (@owned Bar) -> () {
568
+ entry(%idle_incoming : @owned $Bar):
569
+ %box = alloc_box ${ var Bar }
570
+ %box_borrow = begin_borrow [var_decl] %box : ${ var Bar }
571
+ %box_addr = project_box %box_borrow : ${ var Bar }, 0
572
+ store %idle_incoming to [init] %box_addr : $*Bar
573
+ %closable = function_ref @closable : $@convention(thin) (@guaranteed { var Bar }) -> Builtin.Int64
574
+ %box_copy = copy_value %box_borrow : ${ var Bar }
575
+ mark_function_escape %box_addr : $*Bar
576
+ %closure = partial_apply [callee_guaranteed] %closable(%box_copy) : $@convention(thin) (@guaranteed { var Bar }) -> Builtin.Int64
577
+ cond_br undef, exit, die
578
+
579
+ die:
580
+ destroy_value %closure : $@callee_guaranteed () -> Builtin.Int64
581
+ end_borrow %box_borrow : ${ var Bar }
582
+ dealloc_box %box : ${ var Bar }
583
+ unreachable
584
+
585
+ exit:
586
+ destroy_value %closure : $@callee_guaranteed () -> Builtin.Int64
587
+ end_borrow %box_borrow : ${ var Bar }
588
+ destroy_value %box : ${ var Bar }
589
+ %retval = tuple ()
590
+ return %retval :$()
591
+ }
0 commit comments