pub struct ControlFlowGraph { /* private fields */ }Expand description
The Control Flow Graph maintains a mapping of blocks to their predecessors and successors where predecessors are basic blocks and successors are basic blocks.
Implementations§
Source§impl ControlFlowGraph
impl ControlFlowGraph
Sourcepub fn with_function(func: &Function) -> Self
pub fn with_function(func: &Function) -> Self
Allocate and compute the control flow graph for func.
Sourcepub fn compute(&mut self, func: &Function)
pub fn compute(&mut self, func: &Function)
Compute the control flow graph of func.
This will clear and overwrite any information already stored in this data structure.
Sourcepub fn recompute_block(&mut self, func: &Function, block: Block)
pub fn recompute_block(&mut self, func: &Function, block: Block)
Recompute the control flow graph of block.
This is for use after modifying instructions within a specific block. It recomputes all edges
from block while leaving edges to block intact. Its functionality a subset of that of the
more expensive compute, and should be used when we know we don’t need to recompute the CFG
from scratch, but rather that our changes have been restricted to specific blocks.
Sourcepub fn pred_iter(&self, block: Block) -> PredIter<'_> ⓘ
pub fn pred_iter(&self, block: Block) -> PredIter<'_> ⓘ
Get an iterator over the CFG predecessors to block.
Sourcepub fn succ_iter(&self, block: Block) -> SuccIter<'_>
pub fn succ_iter(&self, block: Block) -> SuccIter<'_>
Get an iterator over the CFG successors to block.
Sourcepub fn blocks(&self) -> impl ExactSizeIterator<Item = Block> + '_
pub fn blocks(&self) -> impl ExactSizeIterator<Item = Block> + '_
Get an iterator over all blocks this control-flow graph has storage for, in block order.
This may include blocks that are not in the function’s layout (e.g. a block that was created but never inserted, or has since been removed); such blocks have no predecessors or successors in the graph.
Sourcepub fn num_blocks(&self) -> usize
pub fn num_blocks(&self) -> usize
Get the number of blocks this control-flow graph has storage for.
This equals func.dfg.num_blocks() for the function the CFG was
computed from, and is an upper bound on the block indices appearing in
the graph.