Skip to content

Add a method to dump MIR in the middle of MIR building #144780

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 2 commits into from
Aug 22, 2025

Conversation

bjorn3
Copy link
Member

@bjorn3 bjorn3 commented Aug 1, 2025

This makes it easier to debug issues with MIR building by inserting dump_for_debugging calls around the suspected code responsible for the bad MIR.

@rustbot
Copy link
Collaborator

rustbot commented Aug 1, 2025

r? @petrochenkov

rustbot has assigned @petrochenkov.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Aug 1, 2025
@bjorn3
Copy link
Member Author

bjorn3 commented Aug 1, 2025

I used this while debugging a loop match issue with @folkertdev. I figured it could be useful for others too in the future.

self.coroutine.clone(),
None,
);
//body.coverage_info_hi = self.coverage_info.clone().map(|b| b.into_done());
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The coverage info builder is not Clone and I'm not sure if we should implement Clone for it anyway..

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's fine to implement Clone for this, but maybe the people who implemented coverage think differently? cc @Zalathar

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be fine I think.

I have some other half-formed ideas about how to get the same result, but for this PR I don't mind just slapping #[derive(Clone)] on a few data structures.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've posted a draft PR at #145141 that shows how to avoid cloning the builder itself, by making the build method not consume self.

Feel free to incorporate it into this PR if you want, or we can merge it separately, whatever's more convenient for you.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added something like your PR except as a separate method to avoid extra allocations when not doing a dump.

@petrochenkov
Copy link
Contributor

r? mir

This makes it easier to debug issues with MIR building by inserting
dump_for_debugging calls around the suspected code responsible for the
bad MIR.
@rustbot
Copy link
Collaborator

rustbot commented Aug 13, 2025

Some changes occurred in coverage instrumentation.

cc @Zalathar

@rust-log-analyzer

This comment has been minimized.

@matthewjasper
Copy link
Contributor

@bors r+

@bors
Copy link
Collaborator

bors commented Aug 21, 2025

📌 Commit 695473a has been approved by matthewjasper

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Aug 21, 2025
bors added a commit that referenced this pull request Aug 21, 2025
Rollup of 16 pull requests

Successful merges:

 - #137494 (libstd: init(): dup() subsequent /dev/nulls instead of opening them again)
 - #144541 (c-variadic: multiple ABIs in the same program for arm)
 - #144613 (aarch64-nintendo-switch-freestanding - Enable CPU features that are always available in a live system (crypto instructions, plus explicit NEON).)
 - #144780 (Add a method to dump MIR in the middle of MIR building)
 - #145137 (Consolidate panicking functions in `slice/index.rs`)
 - #145507 (Refactor attribute parsing to improve ergonomics and some diagnostics)
 - #145604 (Gate static closures behind a parser feature)
 - #145648 (Add two tidy dependency checks)
 - #145661 (update some s390x codegen tests)
 - #145672 (Instantiate higher-ranked binder with erased when checking `IntoIterator` predicate for query instability)
 - #145689 (Migrate `panic_unwind` to use `cfg_select!`)
 - #145700 (Handle `ReEarlyParam` in `type_name`.)
 - #145703 (Remove MIPS targets from CI LLVM platforms)
 - #145704 (ci: don't cleanup windows disk)
 - #145705 (remove an `as` cast in prefetch codegen)
 - #145712 (Update outdated link in bound region comments)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit cd0972f into rust-lang:master Aug 22, 2025
10 checks passed
@rustbot rustbot added this to the 1.91.0 milestone Aug 22, 2025
rust-timer added a commit that referenced this pull request Aug 22, 2025
Rollup merge of #144780 - bjorn3:mir_build_debug, r=matthewjasper

Add a method to dump MIR in the middle of MIR building

This makes it easier to debug issues with MIR building by inserting dump_for_debugging calls around the suspected code responsible for the bad MIR.
github-actions bot pushed a commit to rust-lang/miri that referenced this pull request Aug 22, 2025
Rollup of 16 pull requests

Successful merges:

 - rust-lang/rust#137494 (libstd: init(): dup() subsequent /dev/nulls instead of opening them again)
 - rust-lang/rust#144541 (c-variadic: multiple ABIs in the same program for arm)
 - rust-lang/rust#144613 (aarch64-nintendo-switch-freestanding - Enable CPU features that are always available in a live system (crypto instructions, plus explicit NEON).)
 - rust-lang/rust#144780 (Add a method to dump MIR in the middle of MIR building)
 - rust-lang/rust#145137 (Consolidate panicking functions in `slice/index.rs`)
 - rust-lang/rust#145507 (Refactor attribute parsing to improve ergonomics and some diagnostics)
 - rust-lang/rust#145604 (Gate static closures behind a parser feature)
 - rust-lang/rust#145648 (Add two tidy dependency checks)
 - rust-lang/rust#145661 (update some s390x codegen tests)
 - rust-lang/rust#145672 (Instantiate higher-ranked binder with erased when checking `IntoIterator` predicate for query instability)
 - rust-lang/rust#145689 (Migrate `panic_unwind` to use `cfg_select!`)
 - rust-lang/rust#145700 (Handle `ReEarlyParam` in `type_name`.)
 - rust-lang/rust#145703 (Remove MIPS targets from CI LLVM platforms)
 - rust-lang/rust#145704 (ci: don't cleanup windows disk)
 - rust-lang/rust#145705 (remove an `as` cast in prefetch codegen)
 - rust-lang/rust#145712 (Update outdated link in bound region comments)

r? `@ghost`
`@rustbot` modify labels: rollup
@bjorn3 bjorn3 deleted the mir_build_debug branch August 22, 2025 07:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants