pub struct ControlFlowGraph { /* private fields */ }Expand description
A control flow graph for a MIR function. Provides predecessor/successor queries and traversal orders.
Implementations§
Source§impl ControlFlowGraph
impl ControlFlowGraph
Sourcepub fn build(mir: &MirFunction) -> Self
pub fn build(mir: &MirFunction) -> Self
Build a CFG from a MIR function.
Sourcepub fn successors(&self, block: BasicBlockId) -> &[BasicBlockId]
pub fn successors(&self, block: BasicBlockId) -> &[BasicBlockId]
Get the successors of a block.
Sourcepub fn predecessors(&self, block: BasicBlockId) -> &[BasicBlockId]
pub fn predecessors(&self, block: BasicBlockId) -> &[BasicBlockId]
Get the predecessors of a block.
Sourcepub fn reverse_postorder(&self) -> Vec<BasicBlockId>
pub fn reverse_postorder(&self) -> Vec<BasicBlockId>
Reverse postorder traversal (useful for forward dataflow analysis).
Sourcepub fn dominators(&self) -> HashMap<BasicBlockId, BasicBlockId>
pub fn dominators(&self) -> HashMap<BasicBlockId, BasicBlockId>
Compute dominators using the iterative dataflow algorithm.
Sourcepub fn is_reachable(&self, target: BasicBlockId) -> bool
pub fn is_reachable(&self, target: BasicBlockId) -> bool
Check if a block is reachable from the entry.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ControlFlowGraph
impl RefUnwindSafe for ControlFlowGraph
impl Send for ControlFlowGraph
impl Sync for ControlFlowGraph
impl Unpin for ControlFlowGraph
impl UnsafeUnpin for ControlFlowGraph
impl UnwindSafe for ControlFlowGraph
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more