What is a Dominator

In a control flow graph , node is said to dominate node if every path from START to contains .

Dominance Properties

  • Reflexive:
  • Anti-symmetric: and
  • Transitive:
  • Tree-structured:
    • Intuitively, this means that dominators of a node are themselves ordered by dominance

Dominance Relation: relation on nodes

We write if dominates .

Computing Dominance Relation

The domain of this relation is the power set of nodes in the CFG.

There is a dataflow problem. If we have a node with multiple inputs, how do we get dataflow information.

.

Example CFG

graph TD
    A[START] --> B(a)
    B --> C(b)
    C --> D(c)
    D --> E{d}
    D --> F{e}
    E --> G(f)
    F --> G
    G --> C
    B --> D
    G --> H(g)
    H --> I[END]
    A --> I
StartABCDEFGEND
Startxxxxxxxxx
Axxxxxxx
Bx
Cxxxxx
Dx
Ex
Fxx
Gx
ENDx

Building Dominator Tree Directly

Based on depth-first-search (DFS) of graph.

where is the number of edges in a CFG.

This runs in essentially linear time (the inverse Ackermann function grows incredibly slowly).

There is a linear time algorithm, but its a lot more complex and not efficient to implement for extremely large graphs.

Immediate Dominators

The immediate dominator of a node is the parent of the node on all paths, if it exists.

  • Denoted as
  • There is no for START

As a result, all dominators of other than itself dominate .

Postdominators

Given a CFG , node is said to postdominate node if every path from to END contains

  • Denoted as to say that postdominates

Postdominance is dominance in reverse CFGs obtained by reversing the direction of all edges and interchanging the roles of START and END.

There is a caveat: does not necessarily imply .

Immediate Postdominator

The immediate post-dominator of a node is the child of the node on all paths, if it exists.

  • Denoted as .

Strict Postdominance

A node is said to strictly postdominate a node if