Profile MIR passes.
This commit is contained in:
parent
2913ad6db0
commit
addc72799a
4 changed files with 7 additions and 7 deletions
|
@ -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
|
/// 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`.
|
/// loop that goes over each available MIR and applies `run_pass`.
|
||||||
pub trait MirPass<'tcx> {
|
pub trait MirPass<'tcx> {
|
||||||
fn name(&self) -> &str {
|
fn name(&self) -> &'static str {
|
||||||
let name = std::any::type_name::<Self>();
|
let name = std::any::type_name::<Self>();
|
||||||
if let Some((_, tail)) = name.rsplit_once(':') { tail } else { name }
|
if let Some((_, tail)) = name.rsplit_once(':') { tail } else { name }
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@ use rustc_session::config::OutputType;
|
||||||
pub struct Marker(pub &'static str);
|
pub struct Marker(pub &'static str);
|
||||||
|
|
||||||
impl<'tcx> MirPass<'tcx> for Marker {
|
impl<'tcx> MirPass<'tcx> for Marker {
|
||||||
fn name(&self) -> &str {
|
fn name(&self) -> &'static str {
|
||||||
self.0
|
self.0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ use crate::{validate, MirPass};
|
||||||
|
|
||||||
/// Just like `MirPass`, except it cannot mutate `Body`.
|
/// Just like `MirPass`, except it cannot mutate `Body`.
|
||||||
pub trait MirLint<'tcx> {
|
pub trait MirLint<'tcx> {
|
||||||
fn name(&self) -> &str {
|
fn name(&self) -> &'static str {
|
||||||
let name = std::any::type_name::<Self>();
|
let name = std::any::type_name::<Self>();
|
||||||
if let Some((_, tail)) = name.rsplit_once(':') { tail } else { name }
|
if let Some((_, tail)) = name.rsplit_once(':') { tail } else { name }
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,7 @@ impl<'tcx, T> MirPass<'tcx> for Lint<T>
|
||||||
where
|
where
|
||||||
T: MirLint<'tcx>,
|
T: MirLint<'tcx>,
|
||||||
{
|
{
|
||||||
fn name(&self) -> &str {
|
fn name(&self) -> &'static str {
|
||||||
self.0.name()
|
self.0.name()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,7 +49,7 @@ impl<'tcx, T> MirPass<'tcx> for WithMinOptLevel<T>
|
||||||
where
|
where
|
||||||
T: MirPass<'tcx>,
|
T: MirPass<'tcx>,
|
||||||
{
|
{
|
||||||
fn name(&self) -> &str {
|
fn name(&self) -> &'static str {
|
||||||
self.1.name()
|
self.1.name()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -121,7 +121,7 @@ fn run_passes_inner<'tcx>(
|
||||||
validate_body(tcx, body, format!("before pass {}", name));
|
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 {
|
if dump_enabled {
|
||||||
dump_mir_for_pass(tcx, body, &name, true);
|
dump_mir_for_pass(tcx, body, &name, true);
|
||||||
|
|
|
@ -74,7 +74,7 @@ pub fn simplify_cfg<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx> MirPass<'tcx> for SimplifyCfg {
|
impl<'tcx> MirPass<'tcx> for SimplifyCfg {
|
||||||
fn name(&self) -> &str {
|
fn name(&self) -> &'static str {
|
||||||
&self.name()
|
&self.name()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue