@@ -3502,33 +3502,47 @@ program. Until ``end_borrow``, it is illegal to invalidate or store to ``%0``.
35023502begin_borrow
35033503````````````
35043504
3505- TODO
3505+ ::
3506+
3507+ sil-instruction ::= 'begin_borrow' sil-operand
3508+
3509+ %1 = begin_borrow %0 : $T
3510+
3511+ Given a value ``%0 `` with `Owned `_ or `Guaranteed `_ ownership, produces a new
3512+ same typed value with `Guaranteed `_ ownership: ``%1 ``. ``%1 `` is guaranteed to
3513+ have a lifetime ending use (e.x.: `end_borrow `_) along all paths that do not end
3514+ in `Dead End Blocks `_. This `begin_borrow `_ and the lifetime ending uses of
3515+ ``%1 `` are considered to be liveness requiring uses of ``%0 `` and as such in the
3516+ region in between this borrow and its lifetime ending use, ``%0 `` must be
3517+ live. This makes sense semantically since ``%1 `` is modeling a new value with a
3518+ dependent lifetime on ``%0 ``.
3519+
3520+ This instruction is only valid in functions in Ownership SSA form.
35063521
35073522end_borrow
35083523``````````
35093524
35103525::
35113526
3512- sil-instruction ::= 'end_borrow' sil-value 'from' sil-value : sil-type, sil-type
3527+ sil-instruction ::= 'end_borrow' sil-operand
35133528
3514- end_borrow %1 from %0 : $T, $T
3515- end_borrow %1 from %0 : $T, $*T
3516- end_borrow %1 from %0 : $*T, $T
3517- end_borrow %1 from %0 : $*T, $*T
3518- // We allow for end_borrow to be specified in between values and addresses
3519- // all of the same type T.
3529+ // somewhere earlier
3530+ // %1 = begin_borrow %0
3531+ end_borrow %1 : $T
35203532
3521- Ends the scope for which the SILValue ``%1 `` is borrowed from the SILValue
3522- ``%0 ``. Must be paired with at most 1 borrowing instruction (like
3523- `` load_borrow `` ) along any path through the program. In the region in between
3524- the borrow instruction and the `` end_borrow ``, the original SILValue can not be
3525- modified. This means that:
3533+ Ends the scope for which the ` Guaranteed `_ ownership possessing SILValue ``%1 ``
3534+ is borrowed from the SILValue ``%0 ``. Must be paired with at most 1 borrowing
3535+ instruction (like ` load_borrow `_, ` begin_borrow `_ ) along any path through the
3536+ program. In the region in between the borrow instruction and the `end_borrow `_,
3537+ the original SILValue can not be modified. This means that:
35263538
352735391. If ``%0 `` is an address, ``%0 `` can not be written to.
352835402. If ``%0 `` is a non-trivial value, ``%0 `` can not be destroyed.
35293541
35303542We require that ``%1 `` and ``%0 `` have the same type ignoring SILValueCategory.
35313543
3544+ This instruction is only valid in functions in Ownership SSA form.
3545+
35323546assign
35333547``````
35343548::
0 commit comments