@@ -3502,33 +3502,47 @@ program. Until ``end_borrow``, it is illegal to invalidate or store to ``%0``.
3502
3502
begin_borrow
3503
3503
````````````
3504
3504
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.
3506
3521
3507
3522
end_borrow
3508
3523
``````````
3509
3524
3510
3525
::
3511
3526
3512
- sil-instruction ::= 'end_borrow' sil-value 'from' sil-value : sil-type, sil-type
3527
+ sil-instruction ::= 'end_borrow' sil-operand
3513
3528
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
3520
3532
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:
3526
3538
3527
3539
1. If ``%0 `` is an address, ``%0 `` can not be written to.
3528
3540
2. If ``%0 `` is a non-trivial value, ``%0 `` can not be destroyed.
3529
3541
3530
3542
We require that ``%1 `` and ``%0 `` have the same type ignoring SILValueCategory.
3531
3543
3544
+ This instruction is only valid in functions in Ownership SSA form.
3545
+
3532
3546
assign
3533
3547
``````
3534
3548
::
0 commit comments