[6.3] Fix InteriorUseWalker: consider partial_apply [on_stack] an escape #85953
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes a bug in MandatoryDestroyHoisting where a captured value is destroyed
before a copy of the closure.
On-stack closures can be copied, and all copied uses must be within the borrow
scope of the captured operand. This is just like any other non-Escapable value,
so treat it as such by checking
Value.mayEscaperather thanType.Escapable.Originally, I wanted to make it illegal to copy of partial_apply [on_stack], but
it looks like we still allow it.
I would rather not complicate any logic yet with special handling for this
case. To fix any performance concerns, we might be able to simplify the
representation instead by banning copy_value on on-stack closures.
Fixes rdar://165850554 swift-frontend crash: While running "CopyPropagation" -
Invalid SIL provided to OSSACompleteLifetime?!)
--- CCC ---
Explanation: Fixes a bug in liveness utilities to handle copies of on-stack closures
Scope: Miscompilation at -Onone exposed by the recently added MandatoryDestroyHoisting pass
Radar/SR Issue: rdar://165850554 crash - "CopyPropagation" - Invalid SIL provided to OSSACompleteLifetime?!
main PR: #85934
Risk: Low. This one-line change makes liveness conservative for on-stack closures. This could block optimization in theory, but the pass in question is new, and improving optimization requires a larger change to the SIL representation.
Testing: Added SIL unit test.
Reviewer: Meghana Gupta
(cherry picked from commit f7c3c6f)