[6.2] Improve LocalVariableUtils.gatherKnownLifetimeUses; dead ends #82797
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.
Add a fake use for dead-end blocks. This allows gatherKnownLifetimeUses to be
used for local liveness by considering an "unreachable" instruction to generate
liveness. This is important when liveness is used as a boundary within which
access scopes may be extended. Otherwise, we are unable to extend access scopes
into dead-end blocks.
Fixes rdar://154406790 (Lifetime-dependent variable 'X' escapes its
scope but only if actor/class is final)
(cherry picked from commit 239255b)
--- CCC ---
Explanation: Fixes lifetime dependence access scope extension into "unreachable" code blocks.
Scope: This is required in order to pass Span/MutableSpan into a function that may throw.
let bufferSpan = array.mutableSpan
try! mayThrow(bufferSpan)
Otherwise, diagnostics report that the span escapes the array's access.
Radar/SR Issue: rdar://154406790 (Lifetime-dependent variable 'X' escapes its scope but only if actor/class is final)
main PR: #82796
Risk: Low. This adds a single condition to a utility that computes liveness. It improves the accuracy of that utility in an obvious way. That utility is only used by lifetime dependene diagnostics.
Testing: Added source and SIL unit tests.
Reviewer: Nate Chandler