Skip to content

[cxx-interop] Avoid querying layout of dependent types during symbolic import #81228

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

Conversation

j-hui
Copy link
Contributor

@j-hui j-hui commented May 1, 2025

In #80786, we started importing certain padded fields as opaque blobs.
Part of this logic involved querying those fields' ASTRecordLayout.
However, dependent types (which are imported symbolically) do not have
an ASTRecordLayout, so calling Clang's getASTRecordLayout() would lead
to an assertion error for class templates where a no_unique_address
field is some kind of dependent C++ record type.

This PR includes a patch that avoids the field padding check during symbolic import mode
because that check is only relevant for codegen anyway.

This PR also includes some small test case updates to increase coverage of padded fields other than std::optional.

rdar://150067288

@j-hui
Copy link
Contributor Author

j-hui commented May 1, 2025

@swift-ci please test

@j-hui
Copy link
Contributor Author

j-hui commented May 1, 2025

I'm also going to re-enable the benchmarks that were disabled in #81145.

j-hui added 2 commits April 30, 2025 18:36
…c import

In swiftlang#80786, we started importing certain padded fields as opaque blobs.
Part of this logic involved querying those fields' ASTRecordLayout.
However, dependent types (which are imported symbolically) do not have
an ASTRecordLayout, so calling Clang's getASTRecordLayout() would lead
to an assertion error for class templates where a no_unique_address
field is some kind of dependent C++ record type.

This patch avoids the field padding check during symbolic import mode
because that check is only relevant for codegen anyway.

rdar://150067288
@j-hui j-hui force-pushed the fix-ast-layout-dependent-types branch from 4818e7e to ff596d5 Compare May 1, 2025 01:37
@j-hui j-hui requested a review from eeckstein as a code owner May 1, 2025 01:37
@j-hui
Copy link
Contributor Author

j-hui commented May 1, 2025

@swift-ci please test

@j-hui
Copy link
Contributor Author

j-hui commented May 1, 2025

@swift-ci please benchmark

@j-hui
Copy link
Contributor Author

j-hui commented May 1, 2025

@swift-ci please benchmark linux platform

Copy link
Contributor

@egorzhdan egorzhdan left a comment

Choose a reason for hiding this comment

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

Awesome, thanks!

@j-hui j-hui merged commit 34be8f9 into swiftlang:main May 1, 2025
6 checks passed
Copy link
Contributor

@Xazax-hun Xazax-hun left a comment

Choose a reason for hiding this comment

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

Looks great! Thanks for fixing this in my absence!

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