Conversation
|
Some changes occurred to constck cc @fee1-dead
cc @bjorn3 This PR changes MIR cc @oli-obk, @RalfJung, @JakobDegen, @vakaras
cc @rust-lang/clippy Some changes occurred to MIR optimizations cc @rust-lang/wg-mir-opt Some changes occurred to the CTFE machinery This PR changes rustc_public cc @oli-obk, @celinval, @ouz-a, @makai410 Some changes occurred to the intrinsics. Make sure the CTFE / Miri interpreter cc @rust-lang/miri, @RalfJung, @oli-obk, @lcnr Some changes occurred to the CTFE / Miri interpreter cc @rust-lang/miri |
|
LLM disclosure: this PR is in large part the result of an LLM-assisted audit of all existing MIR transformations against the new MIR semantics as implemented in Miri in #163340. LLMs were also used to generate the boilerplate for the MIR tests, but each test was manually reviewed and adjusted before committing. |
|
We started with a single pull request with 65 files changed, and now ended up with multiple "smaller" pull requests, where the first one has 115 files changed. This is not exactly what I expected. Could you move some parts to smaller pull requests still. For example parts of "Fix missing ZST initialization in MIR passes" which don't depend on |
|
I'm currently working to make none of the changes in this PR depend on The main concern is that this means restricting I will then move all of the ZST-related changes to a separate PR since they no longer depend on the flag. |
a4912a3 to
43c741c
Compare
|
I've moved the ZST-related changes to #163359.
Most of the difference come from this preparation work which adjusts the rest of the compiler to work with the new semantics, which ends up touching a lot of tests. The actual compiler code changes are not that big. |
This comment has been minimized.
This comment has been minimized.
43c741c to
7d28b47
Compare
|
I moved the MIR validity changes to the Miri PR. |
| (!debuginfo_locals.contains(place.local)).then_some(**place) | ||
| } | ||
| StatementKind::FakeRead(_) | ||
| | StatementKind::StorageAlloc(_) |
There was a problem hiding this comment.
Do you know a specific reason why StorageAlloc cannot be removed? (If yes, a comment and a test case would be nice to have).
| @@ -226,6 +227,7 @@ impl<'tcx> Analysis<'tcx> for MaybeRequiresStorage { | |||
| StatementKind::SetDiscriminant { place, .. } => { | |||
| state.gen_(place.local); | |||
| } | |||
| StatementKind::StorageAlloc(local) => state.gen_(*local), | |||
There was a problem hiding this comment.
Can we turn those StorageAlloc arms into bug!?
| StatementKind::StorageAlloc(l) => { | ||
| if let Some(final_locals) = self.replacements.place_fragments(l.into()) { | ||
| for (_, _, fl) in final_locals { | ||
| self.patch.add_statement(location, StatementKind::StorageAlloc(fl)); | ||
| } | ||
| statement.make_nop(true); | ||
| } | ||
| return; | ||
| } |
There was a problem hiding this comment.
Please add a test case.
| pub(crate) fn remove_unused_storage_annotations<'tcx>(&self, body: &mut Body<'tcx>) { | ||
| for data in body.basic_blocks.as_mut_preserves_cfg() { | ||
| // Remove unnecessary StorageLive and StorageDead annotations. | ||
| // Remove storage statements for unused locals. | ||
| for statement in data.statements.iter_mut() { | ||
| let keep_statement = match &statement.kind { | ||
| StatementKind::StorageLive(local) | StatementKind::StorageDead(local) => { | ||
| self.locals.contains(*local) | ||
| } | ||
| StatementKind::StorageLive(local) | ||
| | StatementKind::StorageDead(local) | ||
| | StatementKind::StorageAlloc(local) => self.locals.contains(*local), |
There was a problem hiding this comment.
Please add a test case.
| if !context.is_use() { | ||
| // StorageAlloc requires the local to be live. | ||
| if !context.is_use() && context != PlaceContext::NonUse(NonUseContext::StorageAlloc) { |
There was a problem hiding this comment.
Please add a test case.
This PR contains preparatory work for supporting the new MIR semantics from rust-lang/rfcs#3943.
-Zmir-move-eliminationwhich both opts-in to the new semantics and enables the new optimization pass.StorageAllocMIR statement. This is used by the MIR inliner when it needs to borrow a destination place that hasn't been initialized.r? tmiasko