Skip to content

[DCE] Don't delete instructions which consume escaping values. #80766

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 4 commits into from
Apr 12, 2025

Conversation

nate-chandler
Copy link
Contributor

When DCE deletes instructions as dead, if the instruction ends one of its operands lifetimes, it must insert a compensating lifetime end. When the def block of the value and the parent block of the instruction are different, it uses lifetime completion. Lifetime completion relies on complete liveness, which doesn't and can't exist for values with pointer escapes. The result is ending lifetimes too early.

Avoid this scenario by marking such instructions live.

In the fullness of time, it may be possible to track the deleted instruction's "location" even in the face of deletions of adjacent instructions and parent blocks and to insert the lifetime end at that location.

rdar://149007151

Copy link
Contributor

@atrick atrick left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM Thank you!

Might want to move your test into the right commit.

I'm reminded that we still need to speed up findPointerEscape

When DCE deletes instructions as dead, if the instruction ends one of
its operands lifetimes, it must insert a compensating lifetime end.
When the def block of the value and the parent block of the instruction
are different, it uses lifetime completion.  Lifetime completion relies
on complete liveness, which doesn't and can't exist for values with
pointer escapes.  The result is ending lifetimes too early.

Avoid this scenario by marking such instructions live.

In the fullness of time, it may be possible to track the deleted
instruction's "location" even in the face of deletions of adjacent
instructions and parent blocks and to insert the lifetime end at that
location.

rdar://149007151
@nate-chandler
Copy link
Contributor Author

@swift-ci please test

@nate-chandler
Copy link
Contributor Author

@swift-ci please benchmark

@nate-chandler
Copy link
Contributor Author

@swift-ci please test source compatibility

@nate-chandler
Copy link
Contributor Author

@swift-ci please test windows platform

@nate-chandler nate-chandler marked this pull request as ready for review April 12, 2025 15:31
@nate-chandler nate-chandler requested a review from jckarter as a code owner April 12, 2025 15:31
@nate-chandler nate-chandler merged commit 9cc1947 into swiftlang:main Apr 12, 2025
7 of 8 checks passed
@nate-chandler nate-chandler deleted the rdar149007151 branch April 12, 2025 15:31
@tbkka
Copy link
Contributor

tbkka commented Apr 21, 2025

This is the fix for #80731

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.

3 participants