Files
Elsa Keirouz b6d498dce2 [SIL] Add the value_to_address instruction
With opaque values on, an address-only value is an SSA object. It has no address
in SIL until AddressLowering assigns it storage, but some operations need the
address of a particular value, such as a lifetime dependence on an addressable
argument. Building a temporary with `store_borrow` for that gives an address
that differs from the value's own.

  %1 = value_to_address %0 : $T     // %0 is an object, %1 is $*T

`value_to_address` is the address of its operand's storage. It does not
allocate. AddressLowering resolves it to the address it assigned to the
operand, so the same operand always yields the same address, and removes it.
The instruction is only valid in opaque values mode, before AddressLowering.
Its operand is visited by visitInteriorPointerUse in OwnershipLiveness.swift.
Add `value_to_address` so that the uses of the address are followed as uses of
its operand's lifetime instead.

The operand has AnyInteriorPointer ownership: the uses of the address are uses
of the operand and must be within its lifetime. For a guaranteed operand the
ownership verifier checks this.

The verifier requires the operand to be a variable, so that a pass cannot
change which address is meant by inserting a copy. AddressLowering asserts that
the operand's storage is an alloc_stack, an indirect argument, or an address
returned or yielded by a callee, or a projection of one.
2026-11-23 12:06:05 +01:00
..