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