Skip to content

[5.9][Serialization] Only read the underlying type of an opaque type if the function is inlinable #65296

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 2 commits into from
Apr 20, 2023

Conversation

xymus
Copy link
Contributor

@xymus xymus commented Apr 19, 2023

The underlying type of an opaque type is defined inside the function body, as such its knowledge needs to be spread in a similar manner. Clients of a resilient module using opaque types don't need access to the underlying type unless it's used for an inlinable function. Plus, the underlying type can reference internal details which can lead to crashes when they reference implementation-only dependencies. To realign this behavior, let's only read the underlying type when the opaque type is on an inlinable function.

Bringing in to 5.9 as this issue has been affecting swift-api-extract and other workarounds aren't enough.

rdar://105128784

Cherry-pick of #64991

xymus added 2 commits April 19, 2023 12:49
…nlinable

Clients of a resilient module using opaque types don't need access to
the underlying type unless it's used in an inlinable context. Plus, the
underlying type can reference internal details which can lead to crashes
when they reference implementation-only dependencies. To clean up this
behavior, let's only serialize the underlying type if used by an
inlinable function.

rdar://105128784
When reading a swiftmodule that's part of the main module the compiler
should have access to all internal details. In that case, read the
underlying type to opaque types.

This was caught by `SILOptimizer/specialize_opaque_result_types2.sil`
which has a merge-module like behavior reading it sib files as input.
@xymus xymus requested a review from a team as a code owner April 19, 2023 20:12
@xymus
Copy link
Contributor Author

xymus commented Apr 19, 2023

@swift-ci Please test

Copy link
Contributor

@nkcsgexi nkcsgexi left a comment

Choose a reason for hiding this comment

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

Makes sense to me since this is the behavior of textual interfaces already.

@xymus
Copy link
Contributor Author

xymus commented Apr 20, 2023

@swift-ci Please test macOS

@xymus xymus merged commit d7e1ea4 into swiftlang:release/5.9 Apr 20, 2023
@xymus xymus deleted the serial-opaque-types-5.9 branch April 20, 2023 16:41
@AnthonyLatsis AnthonyLatsis added the 🍒 release cherry pick Flag: Release branch cherry picks label May 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🍒 release cherry pick Flag: Release branch cherry picks
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants