Function rustc_middle::mir::traversal::reverse_postorder

source ·
pub fn reverse_postorder<'a, 'tcx>(
    body: &'a Body<'tcx>,
) -> impl Iterator<Item = (BasicBlock, &'a BasicBlockData<'tcx>)> + ExactSizeIterator + DoubleEndedIterator
Expand description

Reverse postorder traversal of a graph.

This function creates an iterator over the Body’s basic blocks, that:

  • returns basic blocks in a reverse postorder,
  • makes use of the BasicBlocks CFG cache’s reverse postorder.

Reverse postorder is the reverse order of a postorder traversal. This is different to a preorder traversal and represents a natural linearization of control-flow.


        A
       / \
      /   \
     B     C
      \   /
       \ /
        D

A reverse postorder traversal of this graph is either A B C D or A C B D Note that for a graph containing no loops (i.e., A DAG), this is equivalent to a topological sort.