Skip to content

[6.0] Fix request cycle in macro expansion mangling #74299

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

Conversation

slavapestov
Copy link
Contributor

@slavapestov slavapestov commented Jun 11, 2024

6.0 cherry-pick of #74201

  • Description: Expanding a macro inside a local function with autoclosures would attempt to assign discriminators before the autoclosures had been formed. As a result, SILGen would emit autoclosures with duplicate symbol names. This would either cause a silent miscompile or diagnose an error about mismatched SIL function types. This PR changes the macro expansion buffer mangling to use the source location of the expansion instead. This avoids evaluating requests before everything has been type checked.

  • Origination: This never worked, but it's become more common now that the with.*Continuation functions have a default argument that expands the #isolation macro. These APIs are often used with local functions.

  • Radar: Fixes rdar://127078338.

  • Risk: Low. However, to avoid silent miscompiles in the future, this converts the absence of a discriminator into a fatal error. This is a major invariant violation which should always be flagged, even in noassert builds.

  • Reviewed by: @DougGregor

... even in noassert builds. This is always a miscompile and should
be prevented.
@slavapestov slavapestov requested a review from a team as a code owner June 11, 2024 17:06
@slavapestov slavapestov force-pushed the macro-expansion-mangling-6.0 branch from 94d986a to 6f88906 Compare June 11, 2024 17:09
@slavapestov
Copy link
Contributor Author

@swift-ci Please test

@slavapestov
Copy link
Contributor Author

swiftlang/llvm-project#8894
@swift-ci Please test macOS

@slavapestov slavapestov merged commit 157ae91 into swiftlang:release/6.0 Jun 14, 2024
5 checks passed
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