Skip to content

Commit 3a0d0be

Browse files
committed
Inline and remove dump_mir_for_pass.
The code is more readable without it.
1 parent 7ea882d commit 3a0d0be

File tree

1 file changed

+6
-16
lines changed

1 file changed

+6
-16
lines changed

compiler/rustc_mir_transform/src/pass_manager.rs

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -275,13 +275,14 @@ fn run_passes_inner<'tcx>(
275275
}
276276

277277
let prof_arg = tcx.sess.prof.enabled().then(|| format!("{:?}", body.source.def_id()));
278+
let pass_num = true;
278279

279280
if !body.should_skip() {
280281
let validate = validate_each & tcx.sess.opts.unstable_opts.validate_mir;
281282
let lint = tcx.sess.opts.unstable_opts.lint_mir;
282283

283284
for pass in passes {
284-
let name = pass.name();
285+
let pass_name = pass.name();
285286

286287
if !should_run_pass(tcx, *pass, optimizations) {
287288
continue;
@@ -290,7 +291,7 @@ fn run_passes_inner<'tcx>(
290291
let dump_enabled = pass.is_mir_dump_enabled();
291292

292293
if dump_enabled {
293-
dump_mir_for_pass(tcx, body, name, false);
294+
mir::dump_mir(tcx, pass_num, pass_name, &"before", body, |_, _| Ok(()));
294295
}
295296

296297
if let Some(prof_arg) = &prof_arg {
@@ -303,13 +304,13 @@ fn run_passes_inner<'tcx>(
303304
}
304305

305306
if dump_enabled {
306-
dump_mir_for_pass(tcx, body, name, true);
307+
mir::dump_mir(tcx, pass_num, pass_name, &"after", body, |_, _| Ok(()));
307308
}
308309
if validate {
309-
validate_body(tcx, body, format!("after pass {name}"));
310+
validate_body(tcx, body, format!("after pass {pass_name}"));
310311
}
311312
if lint {
312-
lint_body(tcx, body, format!("after pass {name}"));
313+
lint_body(tcx, body, format!("after pass {pass_name}"));
313314
}
314315

315316
body.pass_count += 1;
@@ -345,17 +346,6 @@ pub(super) fn validate_body<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>, when
345346
validate::Validator { when }.run_pass(tcx, body);
346347
}
347348

348-
fn dump_mir_for_pass<'tcx>(tcx: TyCtxt<'tcx>, body: &Body<'tcx>, pass_name: &str, is_after: bool) {
349-
mir::dump_mir(
350-
tcx,
351-
true,
352-
pass_name,
353-
if is_after { &"after" } else { &"before" },
354-
body,
355-
|_, _| Ok(()),
356-
);
357-
}
358-
359349
pub(super) fn dump_mir_for_phase_change<'tcx>(tcx: TyCtxt<'tcx>, body: &Body<'tcx>) {
360350
assert_eq!(body.pass_count, 0);
361351
mir::dump_mir(tcx, true, body.phase.name(), &"after", body, |_, _| Ok(()))

0 commit comments

Comments
 (0)