Skip to content

Commit 82ae1d1

Browse files
committed
[SIL.rst] Cleanup docs on explicit_copy_value.
There really isn't a point in repeating the verbage from copy_value. So I removed that and just referred back to the copy_value documentation and focused instead on what makes explicit_copy_value different semantically from copy_value, how it is used to work around the invariant in Canonical SIL that move only typed values can not be copied. This is useful for: 1. Implementing an explicit copy for no implicit copy types. 2. When the move checker errors since it can't produce a move only solution for a value, we change all of the copies into explicit_copy_value. We need some sort of copy to ensure later once we are in Canonical SIL, Ownership SSA is correct /and/ we maintain the no copy of move only typed values in Canonical SIL.
1 parent 4a81bca commit 82ae1d1

File tree

1 file changed

+9
-18
lines changed

1 file changed

+9
-18
lines changed

Diff for: docs/SIL.rst

+9-18
Original file line numberDiff line numberDiff line change
@@ -5594,27 +5594,18 @@ explicit_copy_value
55945594

55955595
%1 = explicit_copy_value %0 : $A
55965596

5597-
Performs a copy of a loadable value as if by the value's type lowering and
5598-
returns the copy. The returned copy semantically is a value that is completely
5599-
independent of the operand. In terms of specific types:
5600-
5601-
1. For trivial types, this is equivalent to just propagating through the trivial
5602-
value.
5603-
2. For reference types, this is equivalent to performing a ``strong_retain``
5604-
operation and returning the reference.
5605-
3. For ``@unowned`` types, this is equivalent to performing an
5606-
``unowned_retain`` and returning the operand.
5607-
4. For aggregate types, this is equivalent to recursively performing a
5608-
``copy_value`` on its components, forming a new aggregate from the copied
5609-
components, and then returning the new aggregate.
5610-
5611-
In ownership qualified functions, a ``explicit_copy_value`` produces a +1 value
5612-
that must be consumed at most once along any path through the program.
5613-
5614-
When move only variable checking is performed, ``explicit_copy_value`` is
5597+
This is exactly the same instruction semantically as `copy_value`_ with the
5598+
exception that when move only checking is performed, `explicit_copy_value`_ is
56155599
treated as an explicit copy asked for by the user that should not be rewritten
56165600
and should be treated as a non-consuming use.
56175601

5602+
This is used for two things:
5603+
5604+
1. Implementing a copy builtin for no implicit copy types.
5605+
2. To enable the move checker, once it has emitted an error diagnostic, to still
5606+
produce valid Ownership SSA SIL at the end of the guaranteed optimization
5607+
pipeline when we enter the Canonical SIL stage.
5608+
56185609
move_value
56195610
``````````
56205611

0 commit comments

Comments
 (0)