@@ -978,3 +978,42 @@ bb0:
978
978
return %r : $()
979
979
}
980
980
981
+ sil @consume_and_borrow : $@convention(thin) (@owned Klass, @guaranteed Klass) -> ()
982
+ sil @borrow : $@convention(thin) (@guaranteed Klass) -> ()
983
+ sil @consume : $@convention(thin) (@owned Klass) -> ()
984
+ sil @get_klass : $@convention(thin) () -> @owned Klass
985
+
986
+ // CHECK-LABEL: sil hidden [ossa] @borrow_and_consume_copyable_test1 :
987
+ // CHECK-NOT: copy_value
988
+ // CHECK-LABEL: } // end sil function 'borrow_and_consume_copyable_test1'
989
+ sil hidden [ossa] @borrow_and_consume_copyable_test1 : $@convention(thin) () -> () {
990
+ bb0:
991
+ %0 = function_ref @get_klass : $@convention(thin) () -> @owned Klass
992
+ %1 = apply %0() : $@convention(thin) () -> @owned Klass
993
+ %2 = move_value [var_decl] %1
994
+ %3 = copy_value %2
995
+ %4 = function_ref @borrow : $@convention(thin) (@guaranteed Klass) -> ()
996
+ %5 = apply %4(%2) : $@convention(thin) (@guaranteed Klass) -> ()
997
+ %6 = function_ref @consume : $@convention(thin) (@owned Klass) -> ()
998
+ %7 = apply %6(%3) : $@convention(thin) (@owned Klass) -> ()
999
+ destroy_value %2
1000
+ %9 = tuple ()
1001
+ return %9
1002
+ }
1003
+
1004
+ // CHECK-LABEL: sil hidden [ossa] @borrow_and_consume_copyable_test2 :
1005
+ // CHECK: copy_value
1006
+ // CHECK-LABEL: } // end sil function 'borrow_and_consume_copyable_test2'
1007
+ sil hidden [ossa] @borrow_and_consume_copyable_test2 : $@convention(thin) () -> () {
1008
+ bb0:
1009
+ %0 = function_ref @get_klass : $@convention(thin) () -> @owned Klass
1010
+ %1 = apply %0() : $@convention(thin) () -> @owned Klass
1011
+ %2 = move_value [var_decl] %1
1012
+ %3 = copy_value %2
1013
+ %4 = function_ref @consume_and_borrow : $@convention(thin) (@owned Klass, @guaranteed Klass) -> ()
1014
+ %5 = apply %4(%3, %2) : $@convention(thin) (@owned Klass, @guaranteed Klass) -> ()
1015
+ destroy_value %2
1016
+ %7 = tuple ()
1017
+ return %7
1018
+ }
1019
+
0 commit comments