Skip to main content

Analyses

Struct Analyses 

Source
pub struct Analyses { /* private fields */ }
Expand description

The analyses of one function, computed when asked for and kept until something breaks them.

Empty to start with. Nothing here is computed by existing, which matters because most functions are walked by a pass that wants none of it.

Implementations§

Source§

impl Analyses

Source

pub fn new() -> Self

An empty cache.

Source

pub fn cfg(&mut self, func: &Func) -> &Cfg

The control flow graph, computed if it is not already here.

Source

pub fn dominators(&mut self, func: &Func) -> &Dominators

The dominator tree, computed if it is not already here.

The graph comes out of the cache as well, so a caller that wants both pays for it once. Each of these is written against the field rather than through the method above it, because two fields of one structure can be borrowed at the same time and two calls that each take all of self cannot.

Source

pub fn post_dominators(&mut self, func: &Func) -> &PostDominators

The post-dominator tree, computed if it is not already here.

§Panics

Panics through PostDominators::new, on a function with a block that control reaches and that has no path to any exit even after the fake edges have been added.

Source

pub fn loops(&mut self, func: &Func) -> &Loops

The loop forest, computed if it is not already here.

Source

pub fn frontiers(&mut self, func: &Func) -> &Frontiers

The dominance frontier of every block, computed if it is not already here.

Source

pub fn control_dependence(&mut self, func: &Func) -> &ControlDependence

Which branches decide whether each block runs, computed if it is not already here.

§Panics

Panics through PostDominators::new, for the reason above it.

Source

pub fn frequencies(&mut self, func: &Func) -> &Frequencies

How often each block runs and which way each branch goes, computed if it is not here.

Predicted rather than measured, and every number out of it says so. A function pass is given one function and not the module around it, so nothing is known here about what any callee does. Section 11.2’s two predictors that would like to know, which are the ones about a call that never returns and a call to something cold, still fire on what the IR says: the front end puts an unreachable after a call that does not come back. A module pass that wants the rest of the answer builds its own with Callees::of_module.

Source

pub fn holds(&self, analysis: Analysis) -> bool

Whether this one is here without computing it.

For the debug check below and for tests. A pass has no business asking, because a pass that behaves differently depending on what somebody else happened to leave in the cache is a pass whose output depends on the pipeline around it.

Source

pub fn settle( &mut self, func: &Func, keeps: Preserved, check: bool, ) -> Vec<Analysis>

Takes the pass at its word, and in a checked build sees whether it was telling the truth.

Call it after every pass over the function, with what the pass said it preserved. What comes back is the analyses the pass claimed to preserve and did not, which is empty when check is off and is empty on an honest pass. Everything the pass did not preserve is gone from the cache afterwards, and so is everything that was built on top of it.

The check recomputes, which is why it is behind a flag and why the flag is the one that already turns the IR verifier on. Both are the same kind of thing: a cost paid in a build somebody is developing in, to catch the kind of mistake that produces a wrong program rather than a slow one.

Source

pub fn clear(&mut self)

Throws everything away, whatever any pass said.

For the caller that changed the function itself rather than through a pass, and for a test that wants a cold cache.

Trait Implementations§

Source§

impl Clone for Analyses

Source§

fn clone(&self) -> Analyses

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Analyses

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Analyses

Source§

fn default() -> Analyses

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.