Skip to content

Commit 36333f4

Browse files
committed
Inline and remove dump_mir_for_pass.
The code is more readable without it.
1 parent 6e6dfa6 commit 36333f4

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
@@ -264,13 +264,14 @@ fn run_passes_inner<'tcx>(
264264
}
265265

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

268269
if !body.should_skip() {
269270
let validate = validate_each & tcx.sess.opts.unstable_opts.validate_mir;
270271
let lint = tcx.sess.opts.unstable_opts.lint_mir;
271272

272273
for pass in passes {
273-
let name = pass.name();
274+
let pass_name = pass.name();
274275

275276
if !should_run_pass(tcx, *pass, optimizations) {
276277
continue;
@@ -279,7 +280,7 @@ fn run_passes_inner<'tcx>(
279280
let dump_enabled = pass.is_mir_dump_enabled();
280281

281282
if dump_enabled {
282-
dump_mir_for_pass(tcx, body, name, false);
283+
mir::dump_mir(tcx, pass_num, pass_name, &"before", body, |_, _| Ok(()));
283284
}
284285

285286
if let Some(prof_arg) = &prof_arg {
@@ -292,13 +293,13 @@ fn run_passes_inner<'tcx>(
292293
}
293294

294295
if dump_enabled {
295-
dump_mir_for_pass(tcx, body, name, true);
296+
mir::dump_mir(tcx, pass_num, pass_name, &"after", body, |_, _| Ok(()));
296297
}
297298
if validate {
298-
validate_body(tcx, body, format!("after pass {name}"));
299+
validate_body(tcx, body, format!("after pass {pass_name}"));
299300
}
300301
if lint {
301-
lint_body(tcx, body, format!("after pass {name}"));
302+
lint_body(tcx, body, format!("after pass {pass_name}"));
302303
}
303304

304305
body.pass_count += 1;
@@ -334,17 +335,6 @@ pub(super) fn validate_body<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>, when
334335
validate::Validator { when }.run_pass(tcx, body);
335336
}
336337

337-
fn dump_mir_for_pass<'tcx>(tcx: TyCtxt<'tcx>, body: &Body<'tcx>, pass_name: &str, is_after: bool) {
338-
mir::dump_mir(
339-
tcx,
340-
true,
341-
pass_name,
342-
if is_after { &"after" } else { &"before" },
343-
body,
344-
|_, _| Ok(()),
345-
);
346-
}
347-
348338
pub(super) fn dump_mir_for_phase_change<'tcx>(tcx: TyCtxt<'tcx>, body: &Body<'tcx>) {
349339
assert_eq!(body.pass_count, 0);
350340
mir::dump_mir(tcx, true, body.phase.name(), &"after", body, |_, _| Ok(()))

0 commit comments

Comments
 (0)