Skip to content

[SIL.rst] Add docs for copy_unowned_value and copy_unmanaged_value. #26842

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions docs/SIL.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2802,6 +2802,21 @@ It is expected that the strong reference count of the object is one.
Furthermore, no other thread may increment the strong reference count during
execution of this instruction.

copy_unowned_value
``````````````````
::

sil-instruction ::= 'copy_unowned_value' sil-operand

%1 = copy_unowned_value %0 : $@unowned T
// %1 will be a strong @owned value of type $T.
// $T must be a reference type

Asserts that the strong reference count of the heap object referenced by ``%0``
is still positive, then increments the reference count and returns a new strong
reference to ``%0``. The intention is that this instruction is used as a "safe
ownership conversion" from ``unowned`` to ``strong``.

strong_retain_unowned
`````````````````````
::
Expand Down Expand Up @@ -3712,6 +3727,21 @@ This instruction has the same local semantics as ``retain_value`` but:
The intention is that this instruction is used to implement unmanaged
constructs.

copy_unmanaged_value
``````````````````````

::

sil-instruction ::= 'copy_unmanaged_value' sil-value

%1 = copy_unmanaged_value %0 : $@sil_unmanaged A
// %1 will be a strong @owned $A.

This instruction has the same semantics as ``copy_value`` except that its input
is a trivial ``@sil_unmanaged`` type that doesn't require ref counting. This is
intended to be used semantically as a "conversion" like instruction from
``unmanaged`` to ``strong`` and thus should never be removed by the optimizer.

copy_value
``````````

Expand Down