Skip to content

Conversation

@atrick
Copy link
Contributor

@atrick atrick commented Dec 9, 2025

Fixes a bug in MandatoryDestroyHoisting where a captured value is destroyed
before a copy of the closure.

On-stack closures can be copied, and all copied uses must be within the borrow
scope of the captured operand. This is just like any other non-Escapable value,
so treat it as such by checking Value.mayEscape rather than Type.Escapable.

Originally, I wanted to make it illegal to copy of partial_apply [on_stack], but
it looks like we still allow it.

I would rather not complicate any logic yet with special handling for this
case. To fix any performance concerns, we might be able to simplify the
representation instead by banning copy_value on on-stack closures.

Fixes rdar://165850554 swift-frontend crash: While running "CopyPropagation" -
Invalid SIL provided to OSSACompleteLifetime?!)

Fixes a bug in MandatoryDestroyHoisting where a captured value is destroyed
before a copy of the closure.

On-stack closures can be copied, and all copied uses must be within the borrow
scope of the captured operand. This is just like any other non-Escapable value,
so treat it as such by checking `Value.mayEscape` rather than `Type.Escapable`.

Originally, I wanted to make it illegal to copy of partial_apply [on_stack], but
it looks like we still allow it.

I would rather not complicate any logic yet with special handling for this
case. To fix any performance concerns, we might be able to simplify the
representation instead by banning copy_value on on-stack closures.

Fixes rdar://165850554 swift-frontend crash: While running "CopyPropagation" -
Invalid SIL provided to OSSACompleteLifetime?!)
@atrick atrick requested a review from eeckstein as a code owner December 9, 2025 22:39
@atrick
Copy link
Contributor Author

atrick commented Dec 9, 2025

@swift-ci test

@atrick
Copy link
Contributor Author

atrick commented Dec 9, 2025

@swift-ci benchmark

@atrick atrick requested a review from meg-gupta December 9, 2025 22:40
@atrick
Copy link
Contributor Author

atrick commented Dec 9, 2025

@swift-ci test linux

Copy link
Contributor

@meg-gupta meg-gupta left a comment

Choose a reason for hiding this comment

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

LGTM

@meg-gupta
Copy link
Contributor

@swift-ci test macOS platform

@atrick
Copy link
Contributor Author

atrick commented Dec 10, 2025

This has no impact on the benchmark scores

@atrick atrick enabled auto-merge December 10, 2025 20:32
@atrick
Copy link
Contributor Author

atrick commented Dec 10, 2025

TIMEOUT: lldb-api :: functionalities/tsan/swift-access-race/TestTsanSwiftAccessRace.py
😞

@atrick
Copy link
Contributor Author

atrick commented Dec 10, 2025

@swift-ci smoke test macOS

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