pub struct Stats { /* private fields */ }Expand description
What one pass has to say about one function.
Built by the pass as it works, and read by the pass manager afterwards. The events come out in the order they were first recorded rather than sorted, so a pass that records its sites in the order it visits them produces output that reads like the walk.
Implementations§
Source§impl Stats
impl Stats
Sourcepub const fn new() -> Self
pub const fn new() -> Self
Nothing recorded yet, which is what every pass starts from and what a pass that found nothing to do ends with.
Sourcepub fn optimized(&mut self, what: &'static str)
pub fn optimized(&mut self, what: &'static str)
Records that the pass rewrote something, once.
Call this at the rewrite and not at the end, because a count kept in a local and written once is a count that is wrong on every early return.
Sourcepub fn missed(&mut self, what: &'static str)
pub fn missed(&mut self, what: &'static str)
Records that the pass could have rewritten something and did not, once.
Sourcepub fn note(&mut self, what: &'static str)
pub fn note(&mut self, what: &'static str)
Records something that is neither a rewrite nor a missed one, once.
Sourcepub fn record(&mut self, kind: Kind, what: &'static str, count: u32)
pub fn record(&mut self, kind: Kind, what: &'static str, count: u32)
Adds count to the event with this kind and text, creating it if it is new.
A count of zero does nothing at all, so a pass may add a number it computed without first checking whether the number is zero and without producing an event that says a thing happened no times.
Sourcepub fn merge(&mut self, other: &Self)
pub fn merge(&mut self, other: &Self)
Takes everything in other into this, keeping the order the two of them are already in.
What the pass manager does across the functions of a module, so that the total for a pass is one set of named counts rather than one per function.
Sourcepub fn changed(&self) -> bool
pub fn changed(&self) -> bool
Whether the pass changed the function.
One optimized event is a change and any number of missed and note events is not.
This is the whole reason the record is a return value: the pass manager has no other way
to find out, so recording the rewrite is not a thing a pass can leave until later.
Sourcepub fn of(&self, kind: Kind) -> impl Iterator<Item = &Event>
pub fn of(&self, kind: Kind) -> impl Iterator<Item = &Event>
Everything of one kind, in the same order.