[6.2] [NFC] LifetimeDependence computeAddressRange comments and test case #84660
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.
LifetimeDependenceDiagnostics: extend temp alloc to unreachable.
When a non-Escapable value depends on the address of a trivial value, we use a
special computeAddressableRange analysis to compute the trivial value's
scope. Extend that analysis to include unreachable paths.
Fixes this pattern:
where inlineStorage is a trivial type defined in the user module. This
does not reproduce directly with InlineArray, but it is a problem for
user modules that have their own trivial wrapper around an InlineArray.
Fixes rdar://161630684 (Incorrect diagnostic: error: lifetime-dependent value escapes its scope)
(cherry picked from commit 98b7d59)
--- CCC ---
Explanation: Fix a lifetime diagnostic regression that incorrectly
reports an escaping span in the following pattern:
Scope: The diagnostic fires in code that uses both experimental
features: AddressableTypes & Lifetimes. It occurs when users create a
wrapper around an InlineArray and try to return a span from that
wrapper. We've seen two cases of this in the wild. A previous bug fix
was over-conservative resulting an a conservative diagnostic.
Radar/SR Issue: rdar://161630684 (Incorrect diagnostic: error: lifetime-dependent value escapes its scope)
main PR: #84641
Risk: Low. This adds an extra check in the utility that computes
liveness for lifetime dependence diagnostics. This check only affects
temporary on-stack copies that have an addressable dependency.
Testing: Added source and SIL unit tests.
Reviewer: Meghana Gupta