Skip to content

Commit 1d7bc6c

Browse files
committed
[ownership] Change is_escaping_closure to accept any ownership as an operand instead of requiring guaranteed.
This is a point use that even makes sense for owned values.
1 parent 1f7acb6 commit 1d7bc6c

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

lib/SIL/OperandOwnership.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,6 @@ NO_OPERAND_INST(Unwind)
150150
ValueOwnershipKind::OWNERSHIP, \
151151
UseLifetimeConstraint::USE_LIFETIME_CONSTRAINT); \
152152
}
153-
CONSTANT_OWNERSHIP_INST(Guaranteed, MustBeLive, IsEscapingClosure)
154153
CONSTANT_OWNERSHIP_INST(Guaranteed, MustBeLive, RefElementAddr)
155154
CONSTANT_OWNERSHIP_INST(Guaranteed, MustBeLive, OpenExistentialValue)
156155
CONSTANT_OWNERSHIP_INST(Guaranteed, MustBeLive, OpenExistentialBoxValue)
@@ -266,6 +265,7 @@ ACCEPTS_ANY_OWNERSHIP_INST(ExistentialMetatype)
266265
ACCEPTS_ANY_OWNERSHIP_INST(ValueMetatype)
267266
ACCEPTS_ANY_OWNERSHIP_INST(UncheckedOwnershipConversion)
268267
ACCEPTS_ANY_OWNERSHIP_INST(ValueToBridgeObject)
268+
ACCEPTS_ANY_OWNERSHIP_INST(IsEscapingClosure)
269269
#undef ACCEPTS_ANY_OWNERSHIP_INST
270270

271271
// Trivial if trivial typed, otherwise must accept owned?

test/SIL/ownership-verifier/use_verifier.sil

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1135,3 +1135,24 @@ bb0(%0 : @owned $Builtin.NativeObject, %1 : @owned $Builtin.NativeObject):
11351135
%9999 = tuple()
11361136
return %9999 : $()
11371137
}
1138+
1139+
sil [ossa] @owned_partial_apply_is_escaping_closure : $@convention(thin) () -> () {
1140+
bb0:
1141+
%0 = function_ref @no_arg_or_output_function : $@convention(thin) () -> ()
1142+
%1 = partial_apply %0() : $@convention(thin) () -> ()
1143+
%2 = is_escaping_closure %1 : $@callee_owned () -> ()
1144+
%3 = begin_borrow %1 : $@callee_owned () -> ()
1145+
%4 = is_escaping_closure %3 : $@callee_owned () -> ()
1146+
end_borrow %3 : $@callee_owned () -> ()
1147+
destroy_value %1 : $@callee_owned () -> ()
1148+
1149+
%5 = partial_apply [callee_guaranteed] %0() : $@convention(thin) () -> ()
1150+
%6 = is_escaping_closure %5 : $@callee_guaranteed () -> ()
1151+
%7 = begin_borrow %5 : $@callee_guaranteed () -> ()
1152+
%8 = is_escaping_closure %7 : $@callee_guaranteed () -> ()
1153+
end_borrow %7 : $@callee_guaranteed () -> ()
1154+
destroy_value %5 : $@callee_guaranteed () -> ()
1155+
1156+
%9999 = tuple()
1157+
return %9999 : $()
1158+
}

0 commit comments

Comments
 (0)