Struct llvm_ir_analysis::DominatorTree
source · pub struct DominatorTree<'m> { /* private fields */ }
Expand description
The dominator tree for a particular function.
To construct a DominatorTree
, use
FunctionAnalysis
, which you can get
from ModuleAnalysis
.
Implementations§
source§impl<'m> DominatorTree<'m>
impl<'m> DominatorTree<'m>
sourcepub fn idom(&self, block: &'m Name) -> Option<&'m Name>
pub fn idom(&self, block: &'m Name) -> Option<&'m Name>
Get the immediate dominator of the basic block with the given Name
.
This will be None
for the entry block or for any unreachable blocks,
and Some
for all other blocks.
A block bbX is the immediate dominator of bbY if and only if:
- bbX strictly dominates bbY, i.e., bbX appears on every control-flow path from the entry block to bbY (but bbX =/= bbY)
- Of the blocks that strictly dominate bbY, bbX is the closest to bbY (farthest from entry) along paths from the entry block to bbY
sourcepub fn idom_of_return(&self) -> Option<&'m Name>
pub fn idom_of_return(&self) -> Option<&'m Name>
Get the immediate dominator of CFGNode::Return
.
This will be the block bbX such that:
- bbX strictly dominates
CFGNode::Return
, i.e., bbX appears on every control-flow path through the function (but bbX =/=CFGNode::Return
) - Of the blocks that strictly dominate
CFGNode::Return
, bbX is the closest toCFGNode::Return
(farthest from entry) along paths through the function
If the return node is unreachable (e.g., due to an infinite loop in the
function), then the return node has no immediate dominator, and None
will
be returned.
sourcepub fn children<'s>(
&'s self,
block: &'m Name
) -> impl Iterator<Item = CFGNode<'m>> + 's
pub fn children<'s>( &'s self, block: &'m Name ) -> impl Iterator<Item = CFGNode<'m>> + 's
Get the children of the given basic block in the dominator tree, i.e.,
get all the blocks which are immediately dominated by block
.
See notes on idom()
.
sourcepub fn dominates(&self, node_a: CFGNode<'m>, node_b: CFGNode<'m>) -> bool
pub fn dominates(&self, node_a: CFGNode<'m>, node_b: CFGNode<'m>) -> bool
Does node_a
dominate node_b
?
Note that every node dominates itself by definition, so if
node_a == node_b
, this returns true
.
See also strictly_dominates()
sourcepub fn strictly_dominates(
&self,
node_a: CFGNode<'m>,
node_b: CFGNode<'m>
) -> bool
pub fn strictly_dominates( &self, node_a: CFGNode<'m>, node_b: CFGNode<'m> ) -> bool
Does node_a
strictly dominate node_b
?
This is the same as dominates()
, except that if
node_a == node_b
, this returns false
.