pub struct Report { /* private fields */ }Expand description
A record of one PassManager run.
A Report is the observability hook: it lists every pass that ran, in order,
with the Outcome each reported, and summarizes the run — how many sweeps
it took, whether it reached a fixpoint, and how many passes changed the unit.
It is produced by PassManager::run and
PassManager::run_to_fixpoint; you
read it, you do not build it.
§Examples
use pass_lang::{Outcome, Pass, PassError, PassManager};
struct Halve;
impl Pass<i64> for Halve {
fn name(&self) -> &'static str { "halve" }
fn run(&mut self, u: &mut i64) -> Result<Outcome, PassError> {
if *u <= 1 { return Ok(Outcome::Unchanged); }
*u /= 2;
Ok(Outcome::Changed)
}
}
let mut pm = PassManager::new();
pm.add(Halve);
let mut unit = 8;
let report = pm.run_to_fixpoint(&mut unit, 16).unwrap();
assert_eq!(unit, 1); // 8 -> 4 -> 2 -> 1
assert!(report.converged()); // a final sweep changed nothing
assert_eq!(report.iterations(), 4); // three halving sweeps + one confirming sweep
assert_eq!(report.changes(), 3); // three sweeps reported ChangedImplementations§
Source§impl Report
impl Report
Sourcepub fn runs(&self) -> &[PassRun]
pub fn runs(&self) -> &[PassRun]
Every pass execution, in the order it happened.
§Examples
use pass_lang::{Outcome, Pass, PassError, PassManager};
struct A;
impl Pass<i64> for A {
fn name(&self) -> &'static str { "a" }
fn run(&mut self, _: &mut i64) -> Result<Outcome, PassError> { Ok(Outcome::Unchanged) }
}
struct B;
impl Pass<i64> for B {
fn name(&self) -> &'static str { "b" }
fn run(&mut self, _: &mut i64) -> Result<Outcome, PassError> { Ok(Outcome::Unchanged) }
}
let mut pm = PassManager::new();
pm.add(A).add(B);
let mut unit = 0;
let report = pm.run(&mut unit).unwrap();
let names: Vec<_> = report.runs().iter().map(|r| r.name()).collect();
assert_eq!(names, ["a", "b"]);Sourcepub fn changes(&self) -> usize
pub fn changes(&self) -> usize
How many pass executions reported Outcome::Changed.
§Examples
use pass_lang::{Outcome, Pass, PassError, PassManager};
struct Inc;
impl Pass<i64> for Inc {
fn name(&self) -> &'static str { "inc" }
fn run(&mut self, u: &mut i64) -> Result<Outcome, PassError> {
*u += 1;
Ok(Outcome::Changed)
}
}
let mut pm = PassManager::new();
pm.add(Inc);
let mut unit = 0;
assert_eq!(pm.run(&mut unit).unwrap().changes(), 1);Sourcepub fn iterations(&self) -> usize
pub fn iterations(&self) -> usize
The number of full sweeps over the pipeline.
PassManager::run always reports 1.
PassManager::run_to_fixpoint
reports how many sweeps it actually performed.
Sourcepub fn converged(&self) -> bool
pub fn converged(&self) -> bool
Whether the final sweep made no change — the pipeline reached a fixpoint.
For run this is true when the single sweep
changed nothing. For
run_to_fixpoint it is true when
a sweep settled before the iteration bound was hit, and false when the
bound was reached with the unit still changing.