Skip to main content

dominance_frontiers

Function dominance_frontiers 

Source
pub fn dominance_frontiers(dominators: &Dominators) -> Graph
Expand description

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

The dominance frontier of n holds the nodes where its dominance ends: m is in it if n dominates an in-node of m but does not strictly dominate m. A node can be in its own dominance frontier, as the header of a natural loop is, so the result can have self-loops. Nodes that the entries do not reach have empty dominance frontiers and are in none. The result has the node IDs of the graph of dominators.

Uses the algorithm of Cooper, Harvey and Kennedy. The result is computed anew on every call, not cached: keep it to use it more than once. It can grow quadratically with the node count, for example on deeply nested do-while loops.

Time: O(node_count + edge_count + frontier_count), where frontier_count is the number of edges of the result. Memory: 4 x (node_count + frontier_count) bytes for the result; while it runs, 8 x node_count bytes more. The result takes over the arrays built here (Graph::from_csr). Java copies them, which takes as much again.

ยงPanics

With an invalid argument message if the result would have more edges than a graph can have.