mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
In https://github.com/apple/swift/pull/65417 , support for promoting moved-from `load [copy]`s was added. At that time, the existing logic was generalized so that the check for whether writes the loaded-from address occurred: rather than checking whether the writes occurred in the live-range of the `load [copy]`, it was generalized to check whether writes occurred in the live range of the "original" value which was either the `load [copy]` or the `move_value`. That opened a hole for writes that occurred between the `load [copy]` and the `move_value`: ``` %v = load [copy] %a %u = load [take] %a %m = move_value %v ``` Here, this is fixed by checking both the live-range of the "original" and also (supposing the original is different from the `load [copy]`) also the live range of the `load [copy]`. This required changing the list of consuming uses passed to the `LinearLifetimeChecker::usesNotContainedWithinLifetime` to include not just the `destroy_value`s but also the "unknown" consuming uses (i.e. those that are not forwarding). This change only affects arguments (and specifically only `@inout` arguments since promotion for `@in` arguments isn't supported) because a totally different code path is followed for `alloc_stack`s which regards `load [take]`s as an "init" of the address (concretely, `getSingleInitAllocStackUse` returns `truea for the above example if `%a` is an `alloc_stack`). rdar://108745323
8.0 KiB
8.0 KiB