Reach.Dominator (Reach v2.5.0)

Copy Markdown View Source

Immediate dominator/post-dominator trees and dominance frontiers.

Summary

Functions

Checks if a dominates b in the given idom map.

Computes the dominance frontier for each node.

Computes the immediate dominator map for a directed graph.

Computes the immediate post-dominator map.

Builds a dominator tree from an immediate dominator map.

Functions

dominates?(idom_map, a, a)

@spec dominates?(map(), term(), term()) :: boolean()

Checks if a dominates b in the given idom map.

frontier(cfg, idom_map)

@spec frontier(Graph.t(), map()) :: %{required(term()) => MapSet.t()}

Computes the dominance frontier for each node.

The dominance frontier of a node N is the set of nodes where N's dominance ends — where a node has a predecessor dominated by N but is not itself strictly dominated by N.

idom(graph, root)

@spec idom(Graph.t(), term()) :: %{required(term()) => term()}

Computes the immediate dominator map for a directed graph.

Returns %{vertex => immediate_dominator}. The root vertex maps to itself.

ipdom(graph, exit_node)

@spec ipdom(Graph.t(), term()) :: %{required(term()) => term()}

Computes the immediate post-dominator map.

Reverses the CFG and computes dominators from the exit node.

tree(idom_map)

@spec tree(map()) :: Graph.t()

Builds a dominator tree from an immediate dominator map.

Returns a Graph.t() where edges go from dominator to dominated.