Skip to main content

Module control_flow

Module control_flow 

Source
Expand description

Relations of control flow that follow from Dominators, returned as graphs: the dominance frontiers and, from them, control dependence - Java’s class ControlFlow.

A block is control dependent on another if that block decides whether it runs. Control dependence is the transposed graph of the dominance frontiers of the post-dominators. The post-dominators are the dominators of the transposed graph with the exits as entries. Here, for a method load with a for loop and an if in it, whose control flow cfg ends in the block exit:

let post_dominators = Dominators::of(&BiAdjacentGraph::of(&cfg).transposed(), exit);
let control_dependence =
    BiAdjacentGraph::of(&control_flow::dominance_frontiers(&post_dominators))
        .transposed();
// header -> [header, body, next]: the loop condition decides whether they run
// body -> [then]: the if decides whether then runs

For the placement of phi-nodes, IteratedDominanceFrontier answers without building the dominance frontiers.

Functions§

dominance_frontiers
Returns the dominance frontiers as a graph: an edge n -> m for every node m in the dominance frontier of n.