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>
impl<N: Copy + Hash + Eq, S: BuildHasher + Default> DominatorTree<N, S>
Sourcepub fn immediate_dominator(&self, node: N) -> Option<N>
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.
Sourcepub fn children_of(&self, node: N) -> &[N]
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.
Sourcepub fn dominates(&self, dominator: N, node: N) -> bool
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.
Sourcepub fn dominator_set(&self, node: N) -> Option<&HashSet<N, S>>
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.
Sourcepub fn dominator_frontier(&self) -> &HashMap<N, HashSet<N, S>, S>
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.