Skip to content

[region-isolation] Make fields of global actor guarded types that are non-Sendable be considered as actor isolated. #72196

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 3 commits into from
Mar 9, 2024

Conversation

gottesmm
Copy link
Contributor

@gottesmm gottesmm commented Mar 8, 2024

This PR has a few commits in it that ensure that we treat global actor isolated types (which are considered non-Sendable) as actor isolated when performing region isolation checking.

Specifically:

  1. The first commit changes how we represent transferring results at the SIL level. Instead of using a bit in the SILFunctionType (like we are doing in AnyFunctionType since AnyFunctionType), we instead just propagate the bit in TypeLowering to all SILResultInfo. I put in a verification check that if any SILResultInfo are transferring, then all must be transferring. In the fullness of time this will ensure that at the SIL level we will be a bee to easily handle results with different transferring semantics. It also made it so that I could actually write SIL level tests with sil_transferring (the previous implementation relied upon the AST level printer by mistake which caused @owned/@guaranteed to be parsed, but ignored).
  2. The second commit simplifies how we emit diagnostics in TransferNonTransferrable to match what UseAfterTransfer does. Specifically, previously we would have a machine that would produce UseDiagnosticInfo via inference and then a second machine that would consume those and emit a diagnostic. This made it heavy to add new diagnostics (too much code to touch) and hard to track down why a diagnostic was emitted. Instead we now use an emitter helper that in the inference code just immediately emits the error making it easy to diagnose why the error happened using swift-diagnostics-assert-on-error.
  3. This is the meat commit where I ensure that we handle structs/enums that are main actor isolated correctly.

rdar://123488540

gottesmm added 3 commits March 7, 2024 19:44
…fo rather than a bit on SILFunctionType.

We preserve the current semantics that we have today by requiring that either all SILResultInfo are transferring or none are transferring. This also let me swap to @sil_transferring representation.

I did both of these things to fix SIL issues around transferring.

It also ensures that we now properly emit
… like UseAfterTransfer by using an emitter struct.

This makes it easier to debug/maintain/understand the code since the place that
emits the diagnostics is no longer split from the place that decides if a
diagnostic should be emitted. It also lets me eliminate the utility data
structure used to transfer data over.
… non-Sendable be considered as actor isolated.

rdar://123488540
@gottesmm
Copy link
Contributor Author

gottesmm commented Mar 8, 2024

@swift-ci smoke test

@gottesmm gottesmm enabled auto-merge March 8, 2024 20:59
@gottesmm gottesmm merged commit 76e71e7 into swiftlang:main Mar 9, 2024
@gottesmm gottesmm deleted the rest-of-rdar123488540 branch March 9, 2024 01:22
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.

1 participant