1
Fork 0

Generate MIR pass names for profiling on the fly and pass the body DefId as argument

This commit is contained in:
John Kåre Alsaker 2023-09-13 13:05:15 +02:00
parent f742d88326
commit 9624c30965
2 changed files with 47 additions and 4 deletions

View file

@ -94,6 +94,8 @@ fn run_passes_inner<'tcx>(
let overridden_passes = &tcx.sess.opts.unstable_opts.mir_enable_passes;
trace!(?overridden_passes);
let prof_arg = tcx.sess.prof.enabled().then(|| format!("{:?}", body.source.def_id()));
if !body.should_skip() {
for pass in passes {
let name = pass.name();
@ -121,10 +123,14 @@ fn run_passes_inner<'tcx>(
validate_body(tcx, body, format!("before pass {name}"));
}
tcx.sess
.prof
.generic_activity_with_arg("mir_pass", name)
.run(|| pass.run_pass(tcx, body));
if let Some(prof_arg) = &prof_arg {
tcx.sess
.prof
.generic_activity_with_arg(pass.profiler_name(), &**prof_arg)
.run(|| pass.run_pass(tcx, body));
} else {
pass.run_pass(tcx, body);
}
if dump_enabled {
dump_mir_for_pass(tcx, body, &name, true);