Skip to content

[rbi] Change Region Based Isolation for closures to not use the AST and instead just use SIL. #78837

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
Jan 23, 2025

Conversation

gottesmm
Copy link
Contributor

The reason why I am doing this is that in certain cases the AST captures indices
will never actually line up with partial apply capture indices since we seem to
"smush" together closures and locally defined functions.

NOTE: The reason for the really small amount of test changes is that this change
does not change the actual output by design. The only cases I had to change were
a case where we began to emit a better diagnostic and also where I added code
coverage around _ and let _ since those require ignored_use to be implemented so
that they would be diagnosed (previously we just did not emit anything so we
couldn't emit the diagnostic at the SIL level).

rdar://142661388


The first two patches introduce a new type of instruction called ignored_use. I needed to introduce this to ensure feature parity in between the AST/SIL implementations since the AST would emit errors on code that involved _ = ... but at the SIL level, we wouldn't emit any code for such statements implying we could not emit a diagnostic. Now we emit ignored_use in that case, so we now have an instruction emitted in such a case meaning that parity is restored.

This is used for synthetic uses like _ = x that do not act as a true use but
instead only suppress unused variable warnings. This patch just adds the
instruction.

Eventually, we can use it to move the unused variable warning from Sema to SIL
slimmming the type checker down a little bit... but for now I am using it so
that other diagnostic passes can have a SIL instruction (with SIL location) so
that we can emit diagnostics on code like _ = x. Today we just do not emit
anything at all for that case so a diagnostic SIL pass would not see any
instruction that it could emit a diagnostic upon. In the next patch of this
series, I am going to add SILGen support to do that.
…nd instead just use SIL.

The reason why I am doing this is that in certain cases the AST captures indices
will never actually line up with partial apply capture indices since we seem to
"smush" together closures and locally defined functions.

NOTE: The reason for the really small amount of test changes is that this change
does not change the actual output by design. The only cases I had to change were
a case where we began to emit a better diagnostic and also where I added code
coverage around _ and let _ since those require ignored_use to be implemented so
that they would be diagnosed (previously we just did not emit anything so we
couldn't emit the diagnostic at the SIL level).

rdar://142661388
@gottesmm
Copy link
Contributor Author

@swift-ci smoke test

@eeckstein
Copy link
Contributor

eeckstein commented Jan 23, 2025

ignored_use is a good idea, BTW!

@gottesmm
Copy link
Contributor Author

@swift-ci smoke test

1 similar comment
@gottesmm
Copy link
Contributor Author

@swift-ci smoke test

@gottesmm gottesmm enabled auto-merge January 23, 2025 20:37
@gottesmm
Copy link
Contributor Author

@swift-ci test macOS platform

@gottesmm
Copy link
Contributor Author

@swift-ci smoke test macOS platform

@gottesmm gottesmm merged commit d060f01 into swiftlang:main Jan 23, 2025
3 of 4 checks passed
@gottesmm gottesmm deleted the rdar-142661388 branch January 24, 2025 00:54
gottesmm added a commit that referenced this pull request Jan 30, 2025
[rbi] Small tweaks to the closure patch #78837
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