Skip to main content

DominatorTree

Struct DominatorTree 

Source
pub struct DominatorTree<N: Copy + Hash + Eq, S: BuildHasher + Default = FxBuildHasher> { /* private fields */ }
Expand description

Dominator tree for a reachable subgraph.

The immediate-dominator map is computed eagerly by compute_dominators. Full dominator sets and the children map are computed lazily on first access and then cached.

The tree is generic over the hasher S used for its internal, node-keyed maps — pinned to the source graph’s Graph::Hasher by compute_dominators — rather than hardcoding a concrete one. It defaults to FxBuildHasher so the common DominatorTree<NodeId> spelling keeps the fast, deterministic hasher that graph consumers (e.g. qcode’s Context) select.

Implementations§

Source§

impl<N: Copy + Hash + Eq, S: BuildHasher + Default> DominatorTree<N, S>

Source

pub fn root(&self) -> N

The root of the dominator tree (the CFG entry node).

Source

pub fn immediate_dominator(&self, node: N) -> Option<N>

Returns the immediate dominator of node, or None if node is the root or was not in the analyzed subgraph.

Source

pub fn children_of(&self, node: N) -> &[N]

Returns the children of node in the dominator tree — the nodes for which node is the immediate dominator.

Source

pub fn dominates(&self, dominator: N, node: N) -> bool

Returns true if dominator dominates node.

Every node dominates itself. Triggers lazy set computation on first call.

Source

pub fn dominator_set(&self, node: N) -> Option<&HashSet<N, S>>

Returns the set of all nodes that dominate node, or None if node was not in the analyzed subgraph.

Triggers lazy set computation on first call.

Source

pub fn dominator_frontier(&self) -> &HashMap<N, HashSet<N, S>, S>

Returns the dominator frontier for every node in the analyzed subgraph.

The dominator frontier of n is the set of nodes y such that n dominates a predecessor of y but does not strictly dominate y. Frontiers are used by SSA construction to determine phi-node placement.

Computed lazily on first call using the Cytron et al. algorithm.

Auto Trait Implementations§

§

impl<N, S = FxBuildHasher> !Freeze for DominatorTree<N, S>

§

impl<N, S = FxBuildHasher> !RefUnwindSafe for DominatorTree<N, S>

§

impl<N, S = FxBuildHasher> !Sync for DominatorTree<N, S>

§

impl<N, S> Send for DominatorTree<N, S>
where N: Send, HashMap<N, N, S>: Send, HashMap<N, Vec<N>, S>: Send, OnceCell<HashMap<N, HashSet<N, S>, S>>: Send, OnceCell<HashMap<N, Vec<N>, S>>: Send,

§

impl<N, S> Unpin for DominatorTree<N, S>
where N: Unpin, HashMap<N, N, S>: Unpin, HashMap<N, Vec<N>, S>: Unpin, OnceCell<HashMap<N, HashSet<N, S>, S>>: Unpin, OnceCell<HashMap<N, Vec<N>, S>>: Unpin,

§

impl<N, S> UnsafeUnpin for DominatorTree<N, S>
where N: UnsafeUnpin, HashMap<N, N, S>: UnsafeUnpin, HashMap<N, Vec<N>, S>: UnsafeUnpin, OnceCell<HashMap<N, HashSet<N, S>, S>>: UnsafeUnpin, OnceCell<HashMap<N, Vec<N>, S>>: UnsafeUnpin,

§

impl<N, S> UnwindSafe for DominatorTree<N, S>
where N: UnwindSafe, HashMap<N, N, S>: UnwindSafe, HashMap<N, Vec<N>, S>: UnwindSafe, OnceCell<HashMap<N, HashSet<N, S>, S>>: UnwindSafe, OnceCell<HashMap<N, Vec<N>, S>>: UnwindSafe,

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 = !

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.