Skip to content

Fix LifetimeDependenceInsertion: handle boxed indirect out arguments #81222

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
May 1, 2025

Conversation

atrick
Copy link
Contributor

@atrick atrick commented Apr 30, 2025

Correctly generate dependency tracking for functions that return a non-Escapable
existential, such as:

func getMutableSpanWithOpaqueReturn(_ array: inout [Int]) -> any PAny & ~Copyable & ~Escapable

Previously, dependency insertion assumed that @out storage always initialized an
alloc_stack. But existentials are always boxed.

First, add a diagnostic to catch any missing dependency insertions now that
we're past the bootstrapping phase.

Then, generalize handling of dependency insertion to handle any access base as
long as it has a recognizable address source.

Fixes rdar://150388126 (Missing mark_dependence for opaque lifetime dependent
value)

Correctly generate dependency tracking for functions that return a non-Escapable
existential, such as:

func getMutableSpanWithOpaqueReturn(_ array: inout [Int]) -> any PAny & ~Copyable & ~Escapable

Previously, dependency insertion assumed that @out storage always initialized an
alloc_stack. But existentials are always boxed.

First, add a diagnostic to catch any missing dependency insertions now that
we're past the bootstrapping phase.

Then, generalize handling of dependency insertion to handle any access base as
long as it has a recognizable address source.

Fixes rdar://150388126 (Missing mark_dependence for opaque lifetime dependent
value)
@atrick
Copy link
Contributor Author

atrick commented Apr 30, 2025

@swift-ci smoke test

@atrick atrick enabled auto-merge April 30, 2025 22:55
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

@atrick
Copy link
Contributor Author

atrick commented May 1, 2025

CI smoke test is block on
swiftpm/Tests/WorkspaceTests/WorkspaceTests.swift:16148:13: error: cannot find 'skipOnWindowsAsTestCurrentlyFails' in scope

@atrick
Copy link
Contributor Author

atrick commented May 1, 2025

@swift-ci smoke test linux

@atrick atrick merged commit 2a6a621 into swiftlang:main May 1, 2025
3 checks passed
@atrick atrick deleted the missing-markdep branch May 1, 2025 16: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