pub struct DominatorTree { /* private fields */ }
Expand description
The dominator tree for a single function.
Implementations§
Source§impl DominatorTree
Methods for querying the dominator tree.
impl DominatorTree
Methods for querying the dominator tree.
Sourcepub fn is_reachable(&self, block: Block) -> bool
pub fn is_reachable(&self, block: Block) -> bool
Is block
reachable from the entry block?
Sourcepub fn cfg_postorder(&self) -> &[Block]
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()
.
Sourcepub fn cfg_rpo(&self) -> impl Iterator<Item = &Block>
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()
.
Sourcepub fn idom(&self, block: Block) -> Option<Block>
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.
Sourcepub fn rpo_cmp_block(&self, a: Block, b: Block) -> Ordering
pub fn rpo_cmp_block(&self, a: Block, b: Block) -> Ordering
Compare two blocks relative to the reverse post-order.
Sourcepub fn rpo_cmp<A, B>(&self, a: A, b: B, layout: &Layout) -> Ordering
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.
Sourcepub fn dominates<A, B>(&self, a: A, b: B, layout: &Layout) -> bool
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
impl DominatorTree
Sourcepub fn new() -> Self
pub fn new() -> Self
Allocate a new blank dominator tree. Use compute
to compute the dominator tree for a
function.
Sourcepub fn with_function(func: &Function, cfg: &ControlFlowGraph) -> Self
pub fn with_function(func: &Function, cfg: &ControlFlowGraph) -> Self
Allocate and compute a dominator tree.
Sourcepub fn compute(&mut self, func: &Function, cfg: &ControlFlowGraph)
pub fn compute(&mut self, func: &Function, cfg: &ControlFlowGraph)
Reset and compute a CFG post-order and dominator tree.