File tree Expand file tree Collapse file tree 2 files changed +18
-2
lines changed
test/SIL/ownership-verifier Expand file tree Collapse file tree 2 files changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -844,8 +844,12 @@ OperandOwnershipKindMap OperandOwnershipKindClassifier::visitCallee(
844
844
if (substCalleeType->isNoEscape ())
845
845
return Map::compatibilityMap (ValueOwnershipKind::Trivial,
846
846
UseLifetimeConstraint::MustBeLive);
847
- return Map::compatibilityMap (ValueOwnershipKind::Guaranteed,
848
- UseLifetimeConstraint::MustBeLive);
847
+ // We want to accept guaranteed/owned in this position since we
848
+ // treat the use of an owned parameter as an instantaneously
849
+ // borrowed value for the duration of the call.
850
+ return Map::compatibilityMap (
851
+ {{ValueOwnershipKind::Guaranteed, UseLifetimeConstraint::MustBeLive},
852
+ {ValueOwnershipKind::Owned, UseLifetimeConstraint::MustBeLive}});
849
853
}
850
854
851
855
llvm_unreachable (" Unhandled ParameterConvention in switch." );
Original file line number Diff line number Diff line change @@ -1112,3 +1112,15 @@ bb0k(%0 : @owned $Builtin.NativeObject):
1112
1112
return %9999 : $()
1113
1113
}
1114
1114
1115
+ sil @owned_partial_apply_used_as_callee_guaranteed : $@convention(thin) () -> () {
1116
+ bb0:
1117
+ %0 = function_ref @allocate_object : $@convention(thin) () -> @owned Builtin.NativeObject
1118
+ %1 = partial_apply %0() : $@convention(thin) () -> @owned Builtin.NativeObject
1119
+ %2 = convert_function %1 : $@callee_owned () -> @owned Builtin.NativeObject to $@callee_guaranteed () -> @owned Builtin.NativeObject
1120
+ %3 = apply %2() : $@callee_guaranteed () -> @owned Builtin.NativeObject
1121
+ destroy_value %3 : $Builtin.NativeObject
1122
+ destroy_value %2 : $@callee_guaranteed () -> @owned Builtin.NativeObject
1123
+ %9999 = tuple()
1124
+ return %9999 : $()
1125
+ }
1126
+
You can’t perform that action at this time.
0 commit comments