cranelift_codegen::dominator_tree

Struct DominatorTree

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

The dominator tree for a single function.

Implementations§

Source§

impl DominatorTree

Methods for querying the dominator tree.

Source

pub fn is_reachable(&self, block: Block) -> bool

Is block reachable from the entry block?

Source

pub fn cfg_postorder(&self) -> &[Block]

Get the CFG post-order of blocks that was used to compute the dominator tree.

Note that this post-order is not updated automatically when the CFG is modified. It is computed from scratch and cached by compute().

Source

pub fn cfg_rpo(&self) -> impl Iterator<Item = &Block>

Get an iterator over CFG reverse post-order of blocks used to compute the dominator tree.

Note that the post-order is not updated automatically when the CFG is modified. It is computed from scratch and cached by compute().

Source

pub fn idom(&self, block: Block) -> Option<Block>

Returns the immediate dominator of block.

block_a is said to dominate block_b if all control flow paths from the function entry to block_b must go through block_a.

The immediate dominator is the dominator that is closest to block. All other dominators also dominate the immediate dominator.

This returns None if block is not reachable from the entry block, or if it is the entry block which has no dominators.

Source

pub fn rpo_cmp_block(&self, a: Block, b: Block) -> Ordering

Compare two blocks relative to the reverse post-order.

Source

pub fn rpo_cmp<A, B>(&self, a: A, b: B, layout: &Layout) -> Ordering

Compare two program points relative to a reverse post-order traversal of the control-flow graph.

Return Ordering::Less if a comes before b in the RPO.

If a and b belong to the same block, compare their relative position in the block.

Source

pub fn dominates<A, B>(&self, a: A, b: B, layout: &Layout) -> bool

Returns true if a dominates b.

This means that every control-flow path from the function entry to b must go through a.

Dominance is ill defined for unreachable blocks. This function can always determine dominance for instructions in the same block, but otherwise returns false if either block is unreachable.

An instruction is considered to dominate itself. A block is also considered to dominate itself.

Source§

impl DominatorTree

Source

pub fn new() -> Self

Allocate a new blank dominator tree. Use compute to compute the dominator tree for a function.

Source

pub fn with_function(func: &Function, cfg: &ControlFlowGraph) -> Self

Allocate and compute a dominator tree.

Source

pub fn compute(&mut self, func: &Function, cfg: &ControlFlowGraph)

Reset and compute a CFG post-order and dominator tree.

Source

pub fn clear(&mut self)

Clear the data structures used to represent the dominator tree. This will leave the tree in a state where is_valid() returns false.

Source

pub fn is_valid(&self) -> bool

Check if the dominator tree is in a valid state.

Note that this doesn’t perform any kind of validity checks. It simply checks if the compute() method has been called since the last clear(). It does not check that the dominator tree is consistent with the CFG.

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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.