mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Given an aggregate addr `%agg` with trivial subobject addr `%triv` and
nontrivial subobject addr `%sub` which `%triv` is projected from,
```
Aggregate <- %agg
Subobject <- %sub
Trivial <- %triv
...
...
```
after `%sub` is destroyed, `%triv` is no longer initialized. As a
result, it's not valid to fold a destroy_addr of %agg into a sequence of
`load [copy]`s and `copy_addr`s if there's an access to `%triv` after
the `load [copy]`/`copy_addr` of `%sub` (or some intermediate
subobject).
In other words, transforming
```
copy_addr %sub
load [trivial] %triv
destroy_addr %agg
```
into
```
copy_addr [take] %sub
load [trivial] %triv
```
is invalid.
During destroy_addr folding, prevent that from happening by keeping
track of the trivial fields that have already been visited. If a
trivial field is seen more than once, then bail on folding. This is
the same as what is done for non-trivial fields except that there's no
requirement that all trivial fields be destroyed.
40 KiB
40 KiB