[5.10] Fix MemoryLifetimeVerifier to ignore thin functions. #70224
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.
SILGen optimizes creation of closure down a thin function when it has no captures:
ValueOwnership.cpp has a sketchy optimization that treat the result like a trivial type, even though it is not:
This creates a mismatch between the SILType and the SILValue ownership. This is not a coherent design--we have a similar problem with enums which is endlessly buggy--but reverting the decision will be hard. Instead, I'll hack the memory verifier to silence this case.
Fixes rdar://115735132 (Lifetime verifier error with opaque return type and closure)
(cherry picked from commit 047be39)
main PR: #70223
--- CCC ---
Explanation: SILGen optimizes closures with no captures to direct calls. OSSA optimizes direct calls to have owenrship "none". This creates a mismatch between the SILType and the SILValue ownership. This causes the memory verifier to diagnose an error when the memory is not deinitialized.
Scope: This only affects the non-production (asserts) compiler. The issue was introduced three years ago.
commit 8c5737d
Date: Fri Oct 23 15:12:18 2020 -0700
[ownership] Change thin_to_thick function to always produce a none value.
Issue: rdar://115735132 (Lifetime verifier error with opaque return type and closure)
Risk: Very low. Adds a single, very specific condition which used to trigger diagnostics by the memory verifier to now be ignored.
PR to main: #70223
Testing: Added regression test to the test suite.
Reviewer: @eeckstein