Skip to content

SwiftCompilerSources: move the Context and MutatingContext protocols from the Optimizer to the SIL module #83367

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 10 commits into from
Jul 29, 2025

Conversation

eeckstein
Copy link
Contributor

@eeckstein eeckstein commented Jul 28, 2025

This allows moving some basic SIL-related data structures and utilities from the Optimizer to the SIL module.
Also, all the SIL-modification APIs can now live in the SIL module.

| SIL                                | Optimizer                           |
| ------------------------------------------------------------------------ |
| Context protocols:                                                       |
|   `Context`                        | (<- moved)                          |
|   `MutatingContext`                | (<- moved)                          |
| ------------------------------------------------------------------------ |
| Context-conforming structs:                                              |
|                                    | `FunctionPassContext` (not changed) |
|                                    | `ModulePassContext`   (not changed) |
|                                    | `SimplifyContext`     (not changed) |
|   `TestContext` (new)              |                                     |
|   `VerifierContext` (new)          |                                     |
| ------------------------------------------------------------------------ |
| DataStructures:                                                          |
|   `InstructionRange`               | (<- moved)                          |
|   `BasicBlockRange`                | (<- moved)                          |
|   intrusive `Set`s                 | (<- moved)                          |
|   `Stack`                          | (<- moved)                          |
|   `Worklist`s                      | (<- moved)                          |
| ------------------------------------------------------------------------ |
| Utilities:                                                               |
|   `Test` (new, SIL-version of)     | `FunctionTest` (not changed)        |
|   `Verifier`                       | (<- moved)                          |
|   `ForwardingUtils`                | (<- moved)                          |
|   `BorrowUtils`                    | (<- moved)                          |
|   `SSAUpdater`                     | (<- moved)                          |
|   `PhiUpdater`                     | (<- moved)                          |
| ------------------------------------------------------------------------ |
| bridging:                                                                |
|   `SILContext` (new, baseclass of) | ` SwiftPassInvocation`              |

This a pure refactoring change. There is no functional change

@eeckstein
Copy link
Contributor Author

@swift-ci smoke test

1 similar comment
@eeckstein
Copy link
Contributor Author

@swift-ci smoke test

eeckstein added 10 commits July 28, 2025 14:19
… to the SIL module

This allows to move many SIL APIs and utilities, which require a context, to the SIL module.

The SIL-part of SwiftPassInvocation is extracted into a base class SILContext which now lives in SIL.

Also: simplify the begin/end-pass functions of the SwiftPassInvocation.
…e SIL module

add `Test`, which is the SIL-equivalent of `FunctionTest`.
It's invocation closure gets a `TestContext` instead of a `FunctionContext`.

^ The commit message #2 will be skipped:

^ - test
@eeckstein
Copy link
Contributor Author

@swift-ci smoke test

@atrick
Copy link
Contributor

atrick commented Jul 28, 2025

I haven't looked through the diffs but I strongly support these changes. Thanks!

@eeckstein
Copy link
Contributor Author

@swift-ci smoke test windows

@eeckstein eeckstein merged commit 38711c6 into swiftlang:main Jul 29, 2025
3 checks passed
@eeckstein eeckstein deleted the context-refactor branch July 29, 2025 04:54
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