@@ -1964,39 +1964,118 @@ destroy the value, such as `release_value`, `strong_release`,
19641964### mark_dependence
19651965
19661966```
1967- sil-instruction :: 'mark_dependence' '[nonescaping]'? sil-operand 'on' sil-operand
1967+ sil-instruction :: 'mark_dependence' mark-dep-option? sil-operand 'on' sil-operand
1968+ mark-dep-option ::= '[nonescaping]'
1969+ mark-dep-option ::= '[unresolved]'
19681970
19691971%2 = mark_dependence %value : $*T on %base : $Builtin.NativeObject
19701972```
19711973
19721974` %base ` must not be identical to ` %value ` .
19731975
1974- Indicates that the validity of ` %value ` depends on the value of ` %base ` .
1976+ The value of the result depends on the value of ` %base ` .
19751977Operations that would destroy ` %base ` must not be moved before any
1976- instructions which depend on the result of this instruction, exactly as
1978+ instructions that depend on the result of this instruction, exactly as
19771979if the address had been directly derived from that operand (e.g. using
19781980` ref_element_addr ` ).
19791981
1980- The result is the forwarded value of ` %value ` . ` %value ` may be an
1981- address, but it could be an address in a non-obvious form, such as a
1982- Builtin.RawPointer or a struct containing the same.
1983-
1984- ` %base ` may have either object or address type. In the latter case, the
1985- dependency is on the current value stored in the address.
1986-
1987- The optional ` nonescaping ` attribute indicates that no value derived
1988- from ` %value ` escapes the lifetime of ` %base ` . As with escaping
1989- ` mark_dependence ` , all values transitively forwarded from ` %value `
1990- must be destroyed within the lifetime of ` base ` . Unlike escaping
1991- ` mark_dependence ` , this must be statically verifiable. Additionally,
1992- unlike escaping ` mark_dependence ` , nonescaping ` mark_dependence ` may
1993- produce a value of non-` Escapable ` type. A non-` Escapable `
1994- ` mark_dependence ` extends the lifetime of ` %base ` into copies of
1995- ` %value ` and values transitively forwarded from those copies. If the
1996- ` mark_dependence ` forwards an address, then it extends the lifetime
1997- through loads from that address. Unlike escaping ` mark_dependence ` , no
1998- value derived from ` %value ` may have a bitwise escape (conversion to
1999- UnsafePointer) or pointer escape (unknown use).
1982+ The result is the forwarded value of ` %value ` . If ` %value ` is an
1983+ address, then result is also an address, and the semantics are the
1984+ same as the non-address form: the dependency is on any value derived
1985+ from the resulting address. The value could also be a
1986+ Builtin.RawPointer or a struct containing the same, in which case,
1987+ pointed-to values have a dependency if they are derived from this
1988+ instruction's result. Note that in-memory values are only dependent on
1989+ base if they are derived from this instruction's result. In this
1990+ example, the load of ` %dependent_value ` depends on ` %base ` , but the
1991+ load of ` %independent_value ` does not:
1992+
1993+ ```
1994+ %dependent_address = mark_dependence %original_address on %base
1995+ %dependent_value = load [copy] %dependent_address
1996+ %independent_value = load %original_address
1997+ destroy_value %base
1998+ ```
1999+
2000+ ` %base ` may have either object or address type. If it is an address,
2001+ then the dependency is on the current value stored at the address.
2002+
2003+ The optional ` nonescaping ` attribute indicates that the lifetime
2004+ guarantee is statically verifiable via a def-use walk starting at this
2005+ instruction's result. No value derived from a nonescaping
2006+ ` mark_dependence ` may have a bitwise escape (conversion to
2007+ UnsafePointer) or pointer escape (unknown use). The ` unresolved `
2008+ attribute indicates that this verification is required but has not yet
2009+ been diagnosed.
2010+
2011+ ` mark_dependence ` may only have a non-` Escapable ` result if it also
2012+ has a ` nonescaping ` or ` unresolved ` attribute. A non-` Escapable `
2013+ ` mark_dependence ` extends the lifetime of ` %base ` through copies of
2014+ ` %value ` and values transitively forwarded from those copies. If
2015+ ` %value ` is an address, then that includes loads from the
2016+ address. None of those values may be used by a bitwise escape
2017+ (conversion to UnsafePointer) or pointer escape (unknown use). In this
2018+ example, the apply depends on ` %base ` because ` %value ` has a
2019+ non-` Escapable ` type:
2020+
2021+ ```
2022+ %dependent_address = mark_dependence [nonescaping] %value : %*NonescapableType on %base
2023+ %dependent_value = load %dependent_address
2024+ %copied_value = copy_value %dependent_value
2025+ apply %f(%dependent_value)
2026+ destroy_value %base
2027+ ```
2028+
2029+ ### mark_dependence_addr
2030+
2031+ ```
2032+ sil-instruction :: 'mark_dependence_addr' mark-dep-option? sil-operand 'on' sil-operand
2033+ mark-dep-option ::= '[nonescaping]'
2034+ mark-dep-option ::= '[unresolved]'
2035+
2036+ mark_dependence_addr [nonescaping] %address : $*T on %base : $Builtin.NativeObject
2037+ ```
2038+
2039+ The in-memory value at ` %address ` depends on the value of ` %base ` .
2040+ Operations that would destroy ` %base ` must not be moved before any
2041+ instructions that depend on that value, exactly as if the location at
2042+ ` %address ` aliases ` %base ` on all paths reachable from this instruction.
2043+
2044+ In this example, the load of ` %dependent_value ` depends on ` %base ` :
2045+
2046+ ```
2047+ mark_dependence_addr %address on %base
2048+ %dependent_value = load [copy] %address
2049+ destroy_value %base
2050+ ```
2051+
2052+ ` %base ` may have either object or address type. If it is an address,
2053+ then the dependency is on the current value stored at the address.
2054+
2055+ The optional ` nonescaping ` attribute indicates that the lifetime
2056+ guarantee is statically verifiable via a data flow over all paths
2057+ reachable from this instruction considering all addresses that may
2058+ alias with ` %address ` . No aliasing address may be used by a bitwise
2059+ escape (conversion to UnsafePointer) or pointer escape (unknown
2060+ use). The ` unresolved ` attribute indicates that this verification is
2061+ required but has not yet been diagnosed.
2062+
2063+ ` mark_dependence_addr ` may only have a non-` Escapable ` ` %address ` if
2064+ it also has a ` nonescaping ` or ` unresolved ` attribute. A
2065+ non-` Escapable ` ` mark_dependence_addr ` extends the lifetime of ` %base `
2066+ through values loaded from the memory location at ` %address ` and
2067+ through any transitively forwarded or copied values. None of those
2068+ values may be used by a bitwise escape (conversion to UnsafePointer)
2069+ or pointer escape (unknown use). In this example, the apply depends on
2070+ ` %base ` because ` %address ` has a non-` Escapable ` type:
2071+
2072+ ```
2073+ mark_dependence_addr [nonescaping] %address : %*NonescapableType on %base
2074+ %dependent_value = load %address
2075+ %copied_value = copy_value %dependent_value
2076+ apply %f(%dependent_value)
2077+ destroy_value %base
2078+ ```
20002079
20012080### is_unique
20022081
0 commit comments