Skip to content

[6.2] Handle a special case of borrowed from instruction in CopyToBorrowOptimization #80971

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

Merged
merged 1 commit into from
Apr 22, 2025

Conversation

meg-gupta
Copy link
Contributor

@meg-gupta meg-gupta commented Apr 21, 2025

Cherry-pick from #80733. This change is needed for analyzing performance annotations due to the changes to the stdlib in #80956.

In CopyToBorrowOptimization, a copy_value with a guaranteed operand can be optimized away if all uses of copy_value can be replaced by the guaranteed operand and if the guaranteed operand's scope outlives the copy_value liveness.

For this, it uses lookThroughForwardingInstructions. Until now, for borrowed from instructions this utility returned its singleForwardedOperand which is a phi and not handled in isFullyContainedIn.

If the borrowed from instruction has a single enclosing value, we can return this instead enabling more optimizations if it turns out to be handled by isFullyContainedIn .

@meg-gupta meg-gupta requested a review from a team as a code owner April 21, 2025 22:27
@meg-gupta meg-gupta requested a review from tbkka April 21, 2025 22:27
@meg-gupta
Copy link
Contributor Author

@swift-ci test

@meg-gupta meg-gupta mentioned this pull request Apr 21, 2025
@meg-gupta meg-gupta enabled auto-merge April 21, 2025 23:29
@meg-gupta meg-gupta merged commit 9e7257c into swiftlang:release/6.2 Apr 22, 2025
5 checks passed
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