Skip to content

Commit 9792ef8

Browse files
committed
[NFC] Add notes on self argument of borrow accessor being non-lexical
1 parent cc5bfc5 commit 9792ef8

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

docs/SIL/Ownership.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -814,6 +814,11 @@ SILValue. Instead, it constrains the lifetime of an addressable
814814
variable. Since the constraint is applied to the in-memory
815815
representation, no additional lexical SILValue is required.
816816
817+
The `self` function argument in a borrow accessor is not lexical.
818+
`self` is already borrowed for the duration of the borrow accessor and the
819+
dependency between borrowed return value and `self` will be represented in SIL,
820+
making lexical lifetime unnecessary.
821+
817822
### Deinit Barriers
818823
819824
Deinit barriers (see Instruction.isDeinitBarrier(_:)) are instructions

lib/SILOptimizer/Utils/SILInliner.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -769,6 +769,8 @@ Scope scopeForArgument(Scope nonlexicalScope, SILValue callArg, unsigned index,
769769
}
770770

771771
// Use non-lexical scope for functions returning @guaranteed results.
772+
// TODO: Represent the SILFunctionArgument of borrow accessors as non-lexical
773+
// during SILGen.
772774
if (callee->getConventions().hasGuaranteedResult()) {
773775
return nonlexicalScope;
774776
}

0 commit comments

Comments
 (0)