Skip to content

Commit 07f5735

Browse files
committed
Give SILToken Guaranteed ownership.
The begin_apply token represents the borrow scope of all owned and guaranteed call arguments. Although SILToken is (currently) trivially typed, it must have guaranteed ownership so end_apply and abort_apply will be recognized as lifetime-ending uses.
1 parent 56f05da commit 07f5735

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

lib/SIL/IR/OperandOwnership.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,11 @@ OPERAND_OWNERSHIP(ForwardingBorrow, OpenExistentialValue)
259259
OPERAND_OWNERSHIP(ForwardingBorrow, OpenExistentialBoxValue)
260260

261261
OPERAND_OWNERSHIP(EndBorrow, EndBorrow)
262+
263+
// The begin_apply token represents the borrow scope of all owned and guaranteed
264+
// call arguments. Although SILToken is (currently) trivially typed, it must
265+
// have guaranteed ownership so end_apply and abort_apply will be recognized
266+
// as lifetime-ending uses.
262267
OPERAND_OWNERSHIP(EndBorrow, EndApply)
263268
OPERAND_OWNERSHIP(EndBorrow, AbortApply)
264269

lib/SIL/IR/SILInstructions.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,11 @@ BeginApplyInst::create(SILDebugLocation loc, SILValue callee,
482482
}
483483

484484
resultTypes.push_back(SILType::getSILTokenType(F.getASTContext()));
485-
resultOwnerships.push_back(OwnershipKind::None);
485+
// The begin_apply token represents the borrow scope of all owned and
486+
// guaranteed call arguments. Although SILToken is (currently) trivially
487+
// typed, it must have guaranteed ownership so end_apply and abort_apply will
488+
// be recognized as lifetime-ending uses.
489+
resultOwnerships.push_back(OwnershipKind::Guaranteed);
486490

487491
SmallVector<SILValue, 32> typeDependentOperands;
488492
collectTypeDependentOperands(typeDependentOperands, openedArchetypes, F,

0 commit comments

Comments
 (0)