-
Notifications
You must be signed in to change notification settings - Fork 69
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
Revise how MIR variants are distinguished #522
Comments
This issue is not meant to be used for technical discussion. There is a Zulip stream for that. Use this issue to leave procedural comments, such as volunteering to review, indicating that you second the proposal (or third, etc), or raising a concern that you would like to be addressed. cc @rust-lang/compiler @rust-lang/compiler-contributors |
Also see rust-lang/rust#86299 |
@rustbot second |
@rustbot label -final-comment-period +major-change-accepted |
Rework definition of MIR phases to more closely reflect semantic concerns Implements most of rust-lang/compiler-team#522 . I tried my best to restrict this PR to the "core" parts of the MCP. In other words, this includes just enough changes to make the new definition of `MirPhase` make sense. That means there are a couple of FIXMEs lying around. Depending on what reviewers prefer, I can either fix them in this PR or send follow up PRs. There are also a couple other refactorings of the `rustc_mir_transform/src/lib.rs` file that I want to do in follow ups that I didn't leave explicit FIXMEs for.
Background
In rustc today, MIR goes through a number of transformations between being built and being codegened. Mistakes in these transformations tend to manifest as miscompilations, and so their correctness is exceedingly important. Particularly the various MIR optimization passes are especially easy to get wrong and the history of soundness bugs reflect this. In order to begin improving the story here, we need to clarify MIR as an IR and improve the surrounding compiler infrastructure.
Recently, rust-lang/rust#95320 took a significant step in this direction by documenting much of the semantics of MIR. However, it also revealed further weaknesses, particularly around the many variants of MIR. Many passes change the "rules" for the IR in some way, and the large number of rule changes make it difficult to know what the rules at a particular point are and if a particular assumption or transformation is sound. These changes can be divided into two groups:
Currently, all of the following
MirPass
es are semantic changes:ElaborateDrops
AbortUnwindingCalls
AddMovesForPackedDrops
AddRetag
generator::StateTransform
One could also include
const_prop_lint::ConstProp
, depending on whether one considers the emission of lints a part of MIR's semantics.Proposal
This proposal essentially says that we should agree to adopt the mental model described above and we should take a disciplined approach to adhering to it within the compiler. Specifically, this means we:
MirPhase
, and various pieces of documentation, to reflect the proposals in the previous bullet points. We should enforce in code the parts of this that we can.External Projects
As I mentioned above, the primary goal here is to agree on a general direction for MIR variants such that we avoid bugs and reduce complexity in the compiler. However, it may additionally be worth evaluating how this interacts with external initiatives like a-mir-formality and especially SMIR. If there are fundamental, hard-to-fix incompatibilities with rustc moving in this direction, this at least seems worth knowing.
Mentors or Reviewers
None in particular. The diffs resulting from this change are likely to end up being relatively few lines of code spread across a large-ish part of the compiler, so this hopefully won't end up being too much work for any one person.
Process
The main points of the Major Change Process are as follows:
@rustbot second
.-C flag
, then full team check-off is required.@rfcbot fcp merge
on either the MCP or the PR.You can read more about Major Change Proposals on forge.
Comments
This issue is not meant to be used for technical discussion. There is a Zulip stream for that. Use this issue to leave procedural comments, such as volunteering to review, indicating that you second the proposal (or third, etc), or raising a concern that you would like to be addressed.
The text was updated successfully, but these errors were encountered: