Skip to content

[6.0] Fix lifetime dependence in the presence of pointer escapes. #72597

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 16 commits into from
Mar 27, 2024

Conversation

atrick
Copy link
Contributor

@atrick atrick commented Mar 26, 2024

--- CCC ---

Explanation: Fix lifetime dependence in the presence of pointer escapes.

Scope: This fixes common patterns exposed by generic ~Escapable types.

Radar/SR Issue: rdar://124564951 (Compiler crash when evaluating pointer escape in autoclosure; LifetimeDepenenceScopeFixup; Fatal error: check findPointerEscape() before computing interior liveness.)

Original PR: #72407

Risk: Changes the SIL representation of closure captures by adding a flag. This could expose bugs in downstream passes. This risk is mitigated in a subsequent PR: #72513

Testing: Unit tests added.

Reviewer: @meg-gupta

atrick added 16 commits March 26, 2024 11:03
Add PartialApplyInst.hasNoescapeCapture
Add PartialApplyInst.mayEscape

Refactor DiagnoseInvalidEscapingCaptures. This may change functionality because tuples containing a noescape closure are now correctly recognized. Although I'm not sure such tupes can ever be captured directly.

(cherry picked from commit aa208bb)
To fix LifetimeDependenceScopeFixup in the presense of pointer escapes.

(cherry picked from commit bdabc21)
(cherry picked from commit 009bc58)
(cherry picked from commit 352724e)
(cherry picked from commit 00fbf4f)
(cherry picked from commit 73e28df)
Fixes rdar://124564951 (Compiler crash when evaluating pointer escape
in autoclosure; LifetimeDepenenceScopeFixup; Fatal error: check
findPointerEscape() before computing interior liveness.)

(cherry picked from commit f1fbbcd)
(cherry picked from commit e77fff3)
It is safe to do so because the on_stack transformation already checks that the closure has a single known apply use.

(cherry picked from commit 2e82db8)
Treat mark_dependence [nonescaping] as a dependent value even if the dependence base does not have a recognizable
scope (e.g. a multiply-defined alloc_stack). This happens because ClosureLifetimeFixup creates redundant mark_dependence
instructions for partial_apply captures. We constantly need to work around this broken representation of nonescaping closures.

(cherry picked from commit 3e7d9db)
@atrick atrick requested a review from meg-gupta March 26, 2024 20:04
@atrick atrick requested a review from a team as a code owner March 26, 2024 20:04
@atrick
Copy link
Contributor Author

atrick commented Mar 26, 2024

@swift-ci test

@atrick atrick merged commit c1af20b into swiftlang:release/6.0 Mar 27, 2024
@atrick atrick deleted the 60-pointer-escape-bailout branch March 27, 2024 05:19
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