Skip to content

5.9: [InstructionDeleter] Don't delete-as dead instructions which produce owned move-only values. #68111

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

nate-chandler
Copy link
Contributor

Description: Many passes use the InstructionDeleter, requesting that it try to delete an instruction if its dead. The deleter has a number of checks to determine what counts as "dead".

Among those checks is an early exit, affirming that an instruction which satisfies a few other conditions is indeed dead if it satisfies getSingleValueCopyOrCast. At least one instruction (move_value) satisfying that predicate may produce an owned move-only value. Such an instruction must not be deleted as dead.

Here, an additional condition is added prior to considering the getSingleValueCopyOrCast predicate; namely, whether the instruction produces an owned move-only value. If it does, the deleter determines that the instruction is not dead and does not delete it.
Risk: Low.
Scope: Narrow. The change only affects move-only values.
Original PR: #68108
Reviewed By: Andrew Trick ( @atrick )
Testing: Added a test.
Resolves: rdar://114351349

@nate-chandler
Copy link
Contributor Author

@swift-ci please test

@nate-chandler
Copy link
Contributor Author

Build failures are caused by lacking the overhaul to the SIL testing infrastructure on the release/5.9. Will raise a further patch to adapt.

Deleting instructions which produce such values could result in
shortening the lifetime of a move-only value.  This is illegal because
according to language rules, the lifetime of move-only values is fixed.

rdar://114351349
@nate-chandler nate-chandler force-pushed the cherrypick/release/5.9/rdar114351349 branch from 75a1669 to ec9adc8 Compare August 24, 2023 03:59
@nate-chandler
Copy link
Contributor Author

@swift-ci please test

@nate-chandler nate-chandler merged commit aba4e70 into swiftlang:release/5.9 Aug 24, 2023
@nate-chandler nate-chandler deleted the cherrypick/release/5.9/rdar114351349 branch August 24, 2023 19:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants