@@ -22,6 +22,7 @@ sil [ossa] @getOwnedC : $@convention(thin) () -> (@owned C)
22
22
sil [ossa] @getOwnedB : $@convention(thin) () -> (@owned B)
23
23
sil [ossa] @takeOwnedC : $@convention(thin) (@owned C) -> ()
24
24
sil [ossa] @takeOwnedCTwice : $@convention(thin) (@owned C, @owned C) -> ()
25
+ sil [ossa] @takeOwnedCAndGuaranteedC : $@convention(thin) (@owned C, @guaranteed C) -> ()
25
26
sil [ossa] @takeGuaranteedC : $@convention(thin) (@guaranteed C) -> ()
26
27
sil [ossa] @borrowB : $@convention(thin) (@guaranteed B) -> ()
27
28
sil [ossa] @takeGuaranteedAnyObject : $@convention(thin) (@guaranteed AnyObject) -> ()
@@ -1016,3 +1017,33 @@ entry(%instance : @owned $C):
1016
1017
%retval = tuple ()
1017
1018
return %retval : $()
1018
1019
}
1020
+
1021
+ // CHECK-LABEL: sil [ossa] @forward_owned_lexical_value_to_callee : {{.*}} {
1022
+ // CHECK-NOT: copy_value
1023
+ // CHECK-LABEL: } // end sil function 'forward_owned_lexical_value_to_callee'
1024
+ sil [ossa] @forward_owned_lexical_value_to_callee : $@convention(thin) (@owned C) -> () {
1025
+ entry(%instance : @owned $C):
1026
+ %copy = copy_value %instance : $C
1027
+ %consume = function_ref @takeOwnedC : $@convention(thin) (@owned C) -> ()
1028
+ apply %consume(%copy) : $@convention(thin) (@owned C) -> ()
1029
+ destroy_value %instance : $C
1030
+ %retval = tuple ()
1031
+ return %retval : $()
1032
+ }
1033
+
1034
+ // CHECK-LABEL: sil [ossa] @cantForwardBecauseBorrowing : {{.*}} {
1035
+ // CHECK: {{bb[0-9]+}}([[INSTANCE:%[^,]+]] :
1036
+ // CHECK: [[COPY:%[^,]+]] = copy_value [[INSTANCE]]
1037
+ // CHECK: [[CONSUME_AND_BORROW:%[^,]+]] = function_ref @takeOwnedCAndGuaranteedC
1038
+ // CHECK: apply [[CONSUME_AND_BORROW]]([[COPY]], [[INSTANCE]])
1039
+ // CHECK: destroy_value [[INSTANCE]]
1040
+ // CHECK-LABEL: } // end sil function 'cantForwardBecauseBorrowing'
1041
+ sil [ossa] @cantForwardBecauseBorrowing :$@convention(thin) (@owned C) -> () {
1042
+ entry(%instance : @owned $C):
1043
+ %copy = copy_value %instance : $C
1044
+ %consumeAndBorrow = function_ref @takeOwnedCAndGuaranteedC : $@convention(thin) (@owned C, @guaranteed C) -> ()
1045
+ apply %consumeAndBorrow(%copy, %instance) : $@convention(thin) (@owned C, @guaranteed C) -> ()
1046
+ destroy_value %instance : $C
1047
+ %retval = tuple ()
1048
+ return %retval : $()
1049
+ }
0 commit comments