Skip to main content

PostDominatorTree

Struct PostDominatorTree 

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

The post-dominator tree for a single function.

Implementations§

Source§

impl PostDominatorTree

Source

pub fn new() -> Self

Allocate a new blank post-dominator tree.

Use compute to compute the post-dominator tree for a function.

Source

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

Allocate and compute a post-dominator tree.

Source

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

Reset and compute the post-dominator tree for func, using the control-flow graph cfg.

Source

pub fn clear(&mut self)

Clear the data structures used to represent the post-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 post-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 post-dominator tree is consistent with the CFG.

Source

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

Returns the immediate post-dominator of block.

block_a is said to post-dominate block_b if all control-flow paths from block_b out of this function (via return or trap) must go through block_a.

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

This returns None if block diverges and cannot exit the function, or if block directly exits the function (returns or traps).

Source

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

Returns true if every path from b out of this function (via return or trap) must go through a.

Source

pub fn block_post_dominates(&self, block_a: Block, block_b: Block) -> bool

Returns true if every path from b to a function exit (return or trap) must go through a.

Source

pub fn children(&self, block: Block) -> ChildIter<'_>

Get an iterator over the direct children of block in the post-dominator tree.

These are the blocks whose immediate post-dominator is block.

Source

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

Is function exit (via return or trap) unreachable from the given block?

Trait Implementations§

Source§

impl Default for PostDominatorTree

Source§

fn default() -> Self

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> 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> Same for T

Source§

type Output = T

Should always be Self
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.