@@ -90,6 +90,8 @@ sil @use_anyobject_guaranteed : $@convention(thin) (@guaranteed AnyObject) -> ()
9090sil @use_generic_obj_guaranteed : $@convention(thin) <τ_0_0> (@guaranteed τ_0_0) -> ()
9191sil [ossa] @unknown : $@convention(thin) () -> ()
9292sil [ossa] @get_myint : $@convention(thin) () -> (MyInt)
93+ sil [ossa] @use_closure : $@convention(thin) (@guaranteed @callee_guaranteed () -> ()) -> ()
94+ sil [ossa] @useC : $@convention(thin) (@guaranteed C) -> ()
9395
9496enum KlassNativeObjEither {
9597case lhs(Klass)
@@ -5414,3 +5416,40 @@ bb1(%10 : @owned $Optional<@callee_guaranteed () -> ()>, %11 : @guaranteed $Opti
54145416 %12 = tuple ()
54155417 return %12 : $()
54165418}
5419+
5420+ // CHECK-LABEL: sil [ossa] @remove_borrow_of_thin_function :
5421+ // CHECK: [[F:%.*]] = function_ref @unknown
5422+ // CHECK: [[T:%.*]] = thin_to_thick_function [[F]]
5423+ // CHECK-NOT: begin_borrow
5424+ // CHECK: apply %{{[0-9]+}}([[T]])
5425+ // CHECK: apply %0()
5426+ // CHECK-LABEL: } // end sil function 'remove_borrow_of_thin_function'
5427+ sil [ossa] @remove_borrow_of_thin_function : $@convention(thin) () -> () {
5428+ bb0:
5429+ %0 = function_ref @unknown : $@convention(thin) () -> ()
5430+ %1 = thin_to_thick_function %0 to $@callee_guaranteed () -> ()
5431+ %2 = begin_borrow %1
5432+ %3 = function_ref @use_closure : $@convention(thin) (@guaranteed @callee_guaranteed () -> ()) -> ()
5433+ %4 = apply %3(%2) : $@convention(thin) (@guaranteed @callee_guaranteed () -> ()) -> ()
5434+ %5 = apply %2(): $@callee_guaranteed () -> ()
5435+ end_borrow %2
5436+ %r = tuple ()
5437+ return %r
5438+ }
5439+
5440+ // CHECK-LABEL: sil [ossa] @remove_borrow_of_owned :
5441+ // CHECK-NOT: begin_borrow
5442+ // CHECK: apply %1(%0)
5443+ // CHECK-NEXT: destroy_value %0
5444+ // CHECK: } // end sil function 'remove_borrow_of_owned'
5445+ sil [ossa] @remove_borrow_of_owned : $@convention(thin) (@owned C) -> () {
5446+ bb0(%0 : @owned $C):
5447+ %1 = begin_borrow %0 : $C
5448+ %2 = function_ref @useC : $@convention(thin) (@guaranteed C) -> ()
5449+ %3 = apply %2(%1) : $@convention(thin) (@guaranteed C) -> ()
5450+ end_borrow %1 : $C
5451+ destroy_value %0: $C
5452+ %6 = tuple ()
5453+ return %6 : $()
5454+ }
5455+
0 commit comments