Skip to content

[5.9][move-only] Do not attempt to lazily deserialize the moveonly deinit table in IRGen. #66525

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
Jun 13, 2023

Conversation

gottesmm
Copy link
Contributor

@gottesmm gottesmm commented Jun 10, 2023

• Description: [move-only] Do not attempt to lazily deserialize the moveonly deinit table in IRGen
• Risk: This changes IRGen to no longer attempt to lazily deserialize the moveonly deinit table. The reason that we need to do this is that SIL functions are serialized in canonical SIL before they have their final ABI adjusted for large function arguments. If we lazily deserialize in IRGen, then we may pull in a deinit for a large type without its proper final ABI resulting in us miscompiling when attempting to access fields. Specifically, the deinit (the callee) will expect to be passed a pointer but the caller will pass the arguments ins register.
• Original PR: #66505
• Reviewed By: @jckarter
• Testing: Added regression tests and execution tests that exercised this code path.
• Resolves: rdar://110496872


SIL Functions are serialized in canonical SIL before they have their final ABI adjusted for large function arguments. Large function argument ABI is adjusted to be indirect as part of the transition from canonical SIL to lowered SIL. This means that if we deserialize a function from another module in canonical SIL and attempt to call it in IRGen we will call it with the wrong ABI implying if we reference any fields of the type in the deinit we will most likely crash (among other potential issues).

This patch fixes the issue by changing IRGen to not lazily deserialize the moveonly deinit table and its associated functions. Instead if we do not have our table already deserialized, we just call the function's deinit via the destroy value deinit table.

rdar://110496872
(cherry picked from commit b2a52ff)

Replace this paragraph with a description of your changes and rationale. Provide links to external references/discussions if appropriate.

Resolves #NNNNN, fix apple/llvm-project#MMMMM.

…table in IRGen.

SIL Functions are serialized in canonical SIL before they have their final ABI
adjusted for large function arguments. Large function argument ABI is adjusted
to be indirect as part of the transition from canonical SIL to lowered SIL. This
means that if we deserialize a function from another module in canonical SIL and
attempt to call it in IRGen we will call it with the wrong ABI implying if we
reference any fields of the type in the deinit we will most likely crash (among
other potential issues).

This patch fixes the issue by changing IRGen to not lazily deserialize the
moveonly deinit table and its associated functions. Instead if we do not have
our table already deserialized, we just call the function's deinit via the
destroy value deinit table.

rdar://110496872
(cherry picked from commit b2a52ff)
@gottesmm gottesmm requested a review from jckarter June 10, 2023 03:53
@gottesmm gottesmm requested a review from a team as a code owner June 10, 2023 03:53
@gottesmm
Copy link
Contributor Author

@swift-ci test

@gottesmm gottesmm changed the title [move-only] Do not attempt to lazily deserialize the moveonly deinit table in IRGen. [5.9][move-only] Do not attempt to lazily deserialize the moveonly deinit table in IRGen. Jun 13, 2023
@gottesmm gottesmm merged commit abf6585 into swiftlang:release/5.9 Jun 13, 2023
@gottesmm gottesmm deleted the release-5.9-rdar110496872 branch June 13, 2023 21:20
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