-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Fix cycle error only occurring with -Zdump-mir #134498
Conversation
r? @Nadrieril rustbot has assigned @Nadrieril. Use |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, the impl changes look good to me, however the MIR test differences I don't know well -- it feels like some mir-opt tests actually do want the alloc contents to be in the dump (but that -Zdump-mir
as-is might be insufficient?).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion: could you slightly elaborate what this test intends to check (i.e. just the PR description)?
yea. I think we can make some (most) of these work again by just avoiding the evaluation if we're in a const context, I'll give it a shot |
5518ddb
to
55b6063
Compare
@rustbot ready r? compiler Yea, the fix is now much more targeted and I couldn't come up with a situation where it could cause cycles through a non-const function |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't this still cycle when building the .after.mir after optimized mir is done building? Can you test this with -Zdump-mir locally?
The comment that I left in the issue also noted that the last dump of MIR needs to happen outside of the query itself. As long as we are dumping MIR from within a query, this has the potential to be cyclical? |
Hypothetically yes, but to get the optimized MIR from the const eval queries we'd need to have something that checks the optimized MIR for body-leaky information like "does this have panics after optimizations?". I see no other way we'd end up getting the optimized MIR from const eval without that being a bug, so invoking const eval is fine from optimized MIR (as it only uses It would be more consistent to just never dump the statics as I had it previously, as then the MIR of a const fn and a normal fn would be the same if the constness was the only difference.
no, I get // MIR for `thing` after runtime-optimized
fn thing() -> &Thing {
let mut _0: &Thing;
bb0: {
_0 = const {alloc3: &Thing};
return;
}
}
alloc3 (static: MUTUALLY_RECURSIVE, size: 8, align: 8) {
╾─────alloc3<imm>─────╼ │ ╾──────╼
} in |
325a742
to
aabbc61
Compare
aabbc61
to
15c01eb
Compare
@bors r+ rollup |
…ler-errors Fix cycle error only occurring with -Zdump-mir fixes rust-lang#134205 During mir dumping, we evaluate static items to render their allocations. If a static item refers to itself, its own MIR will have a reference to itself, so during mir dumping we end up evaluating the static again, causing us to try to build MIR again (mir dumping happens during MIR building). Thus I disabled evaluation of statics during MIR dumps in case the MIR body isn't far enough along yet to be able to be guaranteed cycle free.
…ler-errors Fix cycle error only occurring with -Zdump-mir fixes rust-lang#134205 During mir dumping, we evaluate static items to render their allocations. If a static item refers to itself, its own MIR will have a reference to itself, so during mir dumping we end up evaluating the static again, causing us to try to build MIR again (mir dumping happens during MIR building). Thus I disabled evaluation of statics during MIR dumps in case the MIR body isn't far enough along yet to be able to be guaranteed cycle free.
…iaskrgr Rollup of 6 pull requests Successful merges: - rust-lang#134498 (Fix cycle error only occurring with -Zdump-mir) - rust-lang#135440 (rm unnecessary `OpaqueTypeDecl` wrapper) - rust-lang#135441 (Make sure to mark `IMPL_TRAIT_REDUNDANT_CAPTURES` as `Allow` in edition 2024) - rust-lang#135444 (Update books) - rust-lang#135451 (Remove code duplication when hashing query result and interning node) - rust-lang#135452 (bootstrap: fix outdated feature name in comment) r? `@ghost` `@rustbot` modify labels: rollup
Rollup of 10 pull requests Successful merges: - rust-lang#134498 (Fix cycle error only occurring with -Zdump-mir) - rust-lang#134977 (Detect `mut arg: &Ty` meant to be `arg: &mut Ty` and provide structured suggestion) - rust-lang#135390 (Re-added regression test for rust-lang#122638) - rust-lang#135393 (uefi: helpers: Introduce OwnedDevicePath) - rust-lang#135440 (rm unnecessary `OpaqueTypeDecl` wrapper) - rust-lang#135441 (Make sure to mark `IMPL_TRAIT_REDUNDANT_CAPTURES` as `Allow` in edition 2024) - rust-lang#135444 (Update books) - rust-lang#135450 (Fix emscripten-wasm-eh with unwind=abort) - rust-lang#135452 (bootstrap: fix outdated feature name in comment) - rust-lang#135454 (llvm: Allow sized-word rather than ymmword in tests) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#134498 - oli-obk:push-wmxynprsyxvr, r=compiler-errors Fix cycle error only occurring with -Zdump-mir fixes rust-lang#134205 During mir dumping, we evaluate static items to render their allocations. If a static item refers to itself, its own MIR will have a reference to itself, so during mir dumping we end up evaluating the static again, causing us to try to build MIR again (mir dumping happens during MIR building). Thus I disabled evaluation of statics during MIR dumps in case the MIR body isn't far enough along yet to be able to be guaranteed cycle free.
fixes #134205
During mir dumping, we evaluate static items to render their allocations. If a static item refers to itself, its own MIR will have a reference to itself, so during mir dumping we end up evaluating the static again, causing us to try to build MIR again (mir dumping happens during MIR building).
Thus I disabled evaluation of statics during MIR dumps in case the MIR body isn't far enough along yet to be able to be guaranteed cycle free.