[5.6,SILOptimizer] Let visitTransitiveEndBorrows take SILValues. #41008
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.
5.6 Summary: Fix compiler crash during dead code elimination when handling patterns involving borrows of
unchecked_ownership_conversion
s.Explanation: When dealing with nested borrow scopes, dead code elimination must not shorten outer borrow scopes to end prior to the end of inner borrow scopes. To ensure that, the ends of outer borrow scopes are marked live, using the visitTransitiveEndBorrows which sees through reborrows.
Previously, that API took a BorrowedValue. BorrowedValue, however, has not been taught about one particular, exotic form of borrow scopes, namely those begun with
unchecked_ownership_conversion
instructions. The result was that a BorrowedValue couldn't be constructed from such instructions, and the value passed to visitTransitiveEndBorrows contained a null BorrowedValue.Here, rather than teaching BorrowedValue to deal with
unchecked_ownership_conversion
(the correct long-term solution), for now, loosen the restrictions on visitTransitiveEndBorrows so that it takes a SILValue rather than a BorrowedValue.Issue: rdar://87985420
Original PR: #41007
Testing: New regression tests, Swift CI
Reviewed by: Andrew Trick
Risk: Low.
Scope: Bug fix