Dominator (graph theory) explained

Dominator (graph theory) should not be confused with dominating set.

1 dom     3 4 5 6
2 dom
3 dom
4 dom
5 dom
6 dom
Corresponding domination relation:
are not strictly dominated
are immediately dominated

In computer science, a node of a control-flow graph dominates a node if every path from the entry node to must go through . Notationally, this is written as (or sometimes). By definition, every node dominates itself.

There are a number of related concepts:

History

Dominance was first introduced by Reese T. Prosser in a 1959 paper on analysis of flow diagrams.[1] Prosser did not present an algorithm for computing dominance, which had to wait ten years for Edward S. Lowry and C. W. Medlock.[2] Ron Cytron et al. rekindled interest in dominance in 1989 when they applied it to the problem of efficiently computing the placement of φ functions, which are used in static single assignment form.[3]

Applications

Dominators, and dominance frontiers particularly, have applications in compilers for computing static single assignment form. A number of compiler optimizations can also benefit from dominators. The flow graph in this case comprises basic blocks.

Dominators play a crucial role in control flow analysis by identifying the program behaviors that are relevant to a specific statement or operation, which helps in optimizing and simplifying the control flow of programs for analysis.[4]

Automatic parallelization benefits from postdominance frontiers. This is an efficient method of computing control dependence, which is critical to the analysis.

Memory usage analysis can benefit from the dominator tree to easily find leaks and identify high memory usage.[5]

In hardware systems, dominators are used for computing signal probabilities for test generation, estimating switching activities for power and noise analysis, and selecting cut points in equivalence checking.[6] In software systems, they are used for reducing the size of the test set in structural testing techniques such as statement and branch coverage.[7]

Algorithms

Let

n0

be the source node on the Control-flow graph. The dominators of a node

n

are given by the maximal solution to the following data-flow equations:

\operatorname{Dom}(n)=\begin{cases}\left\{n\right\}&ifn=n0\\left\{n\right\}\cup\left(

cap
p\inpreds(n)

\operatorname{Dom}(p)\right)&ifnn0\end{cases}

The dominator of the start node is the start node itself. The set of dominators for any other node

n

is the intersection of the set of dominators for all predecessors

p

of

n

. The node

n

is also in the set of dominators for

n

.

An algorithm for the direct solution is:

// dominator of the start node is the start itself Dom(n0) = // for all other nodes, set all nodes as the dominators for each n in N - Dom(n) = N; // iteratively eliminate nodes that are not dominators while changes in any Dom(n) for each n in N - : Dom(n) = union with intersection over Dom(p) for all p in pred(n)

The direct solution is quadratic in the number of nodes, or O(n2). Lengauer and Tarjan developed an algorithm which is almost linear,[8] and in practice, except for a few artificial graphs, the algorithm and a simplified version of it are as fast or faster than any other known algorithm for graphs of all sizes and its advantage increases with graph size.[9]

Keith D. Cooper, Timothy J. Harvey, and Ken Kennedy of Rice University describe an algorithm that essentially solves the above data flow equations but uses well engineered data structures to improve performance.[10]

Postdominance

Analogous to the definition of dominance above, a node z is said to post-dominate a node n if all paths to the exit node of the graph starting at n must go through z. Similarly, the immediate post-dominator of a node n is the postdominator of n that doesn't strictly postdominate any other strict postdominators of n.

See also

References

  1. Prosser . Reese T. . Applications of Boolean matrices to the analysis of flow diagrams . AFIPS Joint Computer Conferences: Papers Presented at the December 1 - 3, 1959, Eastern Joint IRE-AIEE-ACM Computer Conference . 133–138 . 1959 . 10.1145/1460299.1460314 . IRE-AIEE-ACM '59 (Eastern). 15546681 . Reese Prosser.
  2. Object code optimization . Communications of the ACM . 12 . 1 . January 1969 . 13–22 . Edward S. . Lowry . Medlock, Cleburne W.. 10.1145/362835.362838. 16768560 . free .
  3. Book: Ron. Cytron. Jeanne. Ferrante. Barry K.. Rosen. Mark N.. Wegman. F. Kenneth. Zadeck. Proceedings of the 16th ACM SIGPLAN-SIGACT symposium on Principles of programming languages - POPL '89. An efficient method of computing static single assignment form. http://portal.acm.org/citation.cfm?doid=75277.75280. 10.1145/75277.75280. 0897912942. POPL ’89. 1989. 25–35. 8301431.
  4. Tamrawi . Ahmed . Kothari . Suresh . 2018-10-01 . Projected control graph for computing relevant program behaviors . Science of Computer Programming . 163 . 93–114 . 10.1016/j.scico.2018.04.003 . 0167-6423.
  5. Web site: Dominator Tree . . 2008. 2012 . eclipse.org . SAP AG and IBM Corporation . 21 June 2013 .
  6. Book: Teslenko , Maxim . Dubrova, Elena . Design, Automation and Test in Europe . An Efficient Algorithm for Finding Double-Vertex Dominators in Circuit Graphs . 406–411 . 2005 . 10.1109/DATE.2005.53 . 9780769522883 . Date '05 . 10.1.1.598.3053 . 10305833 .
  7. Book: Dubrova , Elena . Design, Automation and Test in Europe . Structural Testing Based on Minimum Kernels. http://dl.acm.org/citation.cfm?id=1049294. 1168–1173 . 2005 . 10.1109/DATE.2005.284 . 9780769522883 . Date '05 . 10.1.1.583.5547 . 11439732 .
  8. A fast algorithm for finding dominators in a flowgraph . ACM Transactions on Programming Languages and Systems . 1. 1 . July 1979 . 121–141 . Thomas . Lengauer. Robert Endre. Tarjan. Thomas Lengauer. Robert Tarjan . 10.1145/357062.357071. 10.1.1.117.8843 . 976012 .
  9. Web site: Finding Dominators in Practice . Georgiadis, Loukas. Tarjan, Robert E.. Werneck, Renato F.. Robert Tarjan. 2006.
  10. Web site: A Simple, Fast Dominance Algorithm . Cooper, Keith D.. Harvey, Timothy J. Kennedy, Ken. Keith D. Cooper. Ken Kennedy (computer scientist). 2001 .

External links