@@ -139,6 +139,7 @@ sil @use_2_64 : $@convention(thin) (Builtin.Int64, Builtin.Int64) -> ()
139139sil @use_a : $@convention(thin) (A) -> ()
140140sil @use_twofield : $@convention(thin) (TwoField) -> ()
141141sil @init_twofield : $@convention(thin) (@thin TwoField.Type) -> TwoField
142+ sil @consumeB : $@convention(thin) (@owned B) -> ()
142143
143144// We have a bug in the old projection code which this test case exposes.
144145// Make sure its handled properly in the new projection.
@@ -1492,3 +1493,41 @@ bb0:
14921493 dealloc_stack %1 : $*Optional<B>
14931494 return %3 : $Optional<B>
14941495}
1496+
1497+ // CHECK-LABEL: sil [ossa] @dont_take_in_borrow_scope :
1498+ // CHECK: load [copy]
1499+ // CHECK: end_borrow
1500+ // CHECK: load [take]
1501+ // CHECK-LABEL: } // end sil function 'dont_take_in_borrow_scope'
1502+ sil [ossa] @dont_take_in_borrow_scope : $@convention(thin) (@in B) -> () {
1503+ bb0(%0 : $*B):
1504+ %1 = load_borrow %0 : $*B
1505+ %2 = load [copy] %0 : $*B
1506+ %3 = function_ref @consumeB : $@convention(thin) (@owned B) -> ()
1507+ %4 = apply %3(%2) : $@convention(thin) (@owned B) -> ()
1508+ end_borrow %1 : $B
1509+ %6 = load [take] %0 : $*B
1510+ %7 = apply %3(%6) : $@convention(thin) (@owned B) -> ()
1511+ %8 = tuple ()
1512+ return %8 : $()
1513+ }
1514+
1515+ // CHECK-LABEL: sil [ossa] @copy_in_borrow_scope :
1516+ // CHECK: load [copy]
1517+ // CHECK: copy_value
1518+ // CHECK: end_borrow
1519+ // CHECK-NOT: load
1520+ // CHECK-LABEL: } // end sil function 'copy_in_borrow_scope'
1521+ sil [ossa] @copy_in_borrow_scope : $@convention(thin) (@inout B) -> () {
1522+ bb0(%0 : $*B):
1523+ %1 = load_borrow %0 : $*B
1524+ %2 = load [copy] %0 : $*B
1525+ %3 = function_ref @consumeB : $@convention(thin) (@owned B) -> ()
1526+ %4 = apply %3(%2) : $@convention(thin) (@owned B) -> ()
1527+ end_borrow %1 : $B
1528+ %6 = load [copy] %0 : $*B
1529+ %7 = apply %3(%6) : $@convention(thin) (@owned B) -> ()
1530+ %8 = tuple ()
1531+ return %8 : $()
1532+ }
1533+
0 commit comments