@@ -22,6 +22,7 @@ sil [ossa] @getOwnedC : $@convention(thin) () -> (@owned C)
2222sil [ossa] @getOwnedB : $@convention(thin) () -> (@owned B)
2323sil [ossa] @takeOwnedC : $@convention(thin) (@owned C) -> ()
2424sil [ossa] @takeOwnedCTwice : $@convention(thin) (@owned C, @owned C) -> ()
25+ sil [ossa] @takeOwnedCAndGuaranteedC : $@convention(thin) (@owned C, @guaranteed C) -> ()
2526sil [ossa] @takeGuaranteedC : $@convention(thin) (@guaranteed C) -> ()
2627sil [ossa] @borrowB : $@convention(thin) (@guaranteed B) -> ()
2728sil [ossa] @takeGuaranteedAnyObject : $@convention(thin) (@guaranteed AnyObject) -> ()
@@ -1016,3 +1017,33 @@ entry(%instance : @owned $C):
10161017 %retval = tuple ()
10171018 return %retval : $()
10181019}
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