Rollup merge of #111619 - cjgillot:profile-pass, r=WaffleLapkin

Add timings for MIR passes to profiling report

This will help identify which pass is responsible for a regression.
This commit is contained in:
Dylan DPC 2023-05-20 12:20:59 +05:30 committed by GitHub
commit 1397827f25
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 7 additions and 7 deletions

View File

@ -101,7 +101,7 @@ impl<'tcx> HasLocalDecls<'tcx> for Body<'tcx> {
/// pass will be named after the type, and it will consist of a main
/// loop that goes over each available MIR and applies `run_pass`.
pub trait MirPass<'tcx> {
fn name(&self) -> &str {
fn name(&self) -> &'static str {
let name = std::any::type_name::<Self>();
if let Some((_, tail)) = name.rsplit_once(':') { tail } else { name }
}

View File

@ -12,7 +12,7 @@ use rustc_session::config::OutputType;
pub struct Marker(pub &'static str);
impl<'tcx> MirPass<'tcx> for Marker {
fn name(&self) -> &str {
fn name(&self) -> &'static str {
self.0
}

View File

@ -6,7 +6,7 @@ use crate::{validate, MirPass};
/// Just like `MirPass`, except it cannot mutate `Body`.
pub trait MirLint<'tcx> {
fn name(&self) -> &str {
fn name(&self) -> &'static str {
let name = std::any::type_name::<Self>();
if let Some((_, tail)) = name.rsplit_once(':') { tail } else { name }
}
@ -26,7 +26,7 @@ impl<'tcx, T> MirPass<'tcx> for Lint<T>
where
T: MirLint<'tcx>,
{
fn name(&self) -> &str {
fn name(&self) -> &'static str {
self.0.name()
}
@ -49,7 +49,7 @@ impl<'tcx, T> MirPass<'tcx> for WithMinOptLevel<T>
where
T: MirPass<'tcx>,
{
fn name(&self) -> &str {
fn name(&self) -> &'static str {
self.1.name()
}
@ -121,7 +121,7 @@ fn run_passes_inner<'tcx>(
validate_body(tcx, body, format!("before pass {}", name));
}
pass.run_pass(tcx, body);
tcx.sess.time(name, || pass.run_pass(tcx, body));
if dump_enabled {
dump_mir_for_pass(tcx, body, &name, true);

View File

@ -74,7 +74,7 @@ pub fn simplify_cfg<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
}
impl<'tcx> MirPass<'tcx> for SimplifyCfg {
fn name(&self) -> &str {
fn name(&self) -> &'static str {
&self.name()
}