Definitioncore
Dominance frontier
Also called DF set.
The nodes where the dominance of a node n ends, that is, nodes with a predecessor dominated by n that are not strictly dominated by n.
The dominance frontier of a node in a flow graph is the set of nodes where the dominance of stops. A node is in it if dominates a predecessor of but does not strictly dominate itself. So can be reached from , and also along a path that avoids . If a variable is assigned in , then is the first place where that value can meet a different value of the same variable. This is why the dominance frontier tells a compiler where to put phi-functions when it builds static single assignment form. Cytron, Ferrante, Rosen, Wegman and Zadeck defined it in 1991, together with the iterated dominance frontier and a fast way to compute both.
Definition
The frontier of one node
Let be a control flow graph with entry , in which every node is reachable from . A node dominates , written , if every path from to passes through . It strictly dominates if also . The dominance frontier of is
The node itself can be in . This happens when dominates a predecessor of , as a loop header does with its latch.
The frontier of a set, and the iterated frontier
For a set of nodes, . The iterated dominance frontier is the limit of
The sequence grows and is finite, so it stops. is the smallest set with . A worklist computes it: start with the nodes of , and add the frontier of each node taken from the list, putting each new node on the list once.
The main theorem
Let be the set of blocks that assign a variable , plus the entry , which holds the initial value. A block is a join point of if there are two non-empty paths that start at two different nodes of , end at , and have no other node in common. Cytron et al. proved that the join points of are exactly . So minimal SSA form puts a phi-function for at each block of , and at no other block. The SSA construction problem page proves this.
Two other ways to write it
By the dominator tree, bottom up. Let be the parent of in the dominator tree. Cytron et al. split into a local part and a part that comes up from the children:
This gives an algorithm that visits the tree in postorder. See dominance frontier computation.
By the edges. Every node that strictly dominates also dominates every predecessor of : a path from to that avoids , followed by the edge , would avoid too. So is an ancestor of in the dominator tree, and the ancestors of form a chain. A node that dominates is on this chain. It strictly dominates if and only if it is or above it. So
If , no node strictly dominates , and the whole path from up to counts. The walk of Cooper, Harvey and Kennedy uses this form. A node with one predecessor has , so the path is empty and is in no frontier. Only join nodes appear in dominance frontiers.
Size
The sum can be quadratic in the size of the graph. Take nested repeat-until loops. The nodes are headers , latches and an exit , with entry . The edges are for , , the back edges , the loop exits for , and . The graph has nodes and edges. Its dominator tree is the path . For each ,
because the back edge leaves the region dominated by and for each . The total is , which is for nodes. If a variable is assigned in , then , and minimal SSA form has phi-functions for these variables. Cytron et al. measured the frontiers of real programs and found their total size grew about linearly. Sreedhar and Gao showed that can be found in time linear in the size of the graph, without computing the frontiers at all.
The reverse graph
On the reverse graph, with the exit as the entry, dominance becomes post-dominance, and the dominance frontier becomes the post-dominance frontier. A block is control dependent on if and only if is in the post-dominance frontier of . Cytron et al. build the control dependence graph this way.
Examples and non-examples
A loop with a branch inside
The program that adds the odd numbers below , from the control flow graph page, has the edges B1 → B2, B2 → B3, B2 → B6, B3 → B4, B3 → B5, B4 → B5 and B5 → B2. The immediate dominators are B1 for B2, B2 for B3 and B6, and B3 for B4 and B5. The frontiers are:
| node | DF |
|---|---|
| B1 | ∅ |
| B2 | {B2} |
| B3 | {B2} |
| B4 | {B5} |
| B5 | {B2} |
| B6 | ∅ |
- : B4 dominates itself, a predecessor of B5, but B5 can be reached through B3 → B5, so B4 does not dominate it.
- : B2 dominates the latch B5, which is a predecessor of B2, and B2 does not strictly dominate itself.
- and : from the back edge B5 → B2. By the edge form, the walk from B5 up to passes B5, B3 and B2.
The variable s is assigned in B1 and B4. Then , , and adding B2 gives nothing new. So , and these are the two blocks that get a phi-function for s in the SSA form of this program. The variable i is assigned in B1 and B5, and .
Three nested repeat-until loops
For the quadratic family above has the nodes and
12 entries in total for 7 nodes and 9 edges.
Non-examples
- A node with one predecessor. It is in no dominance frontier, since its predecessor is its immediate dominator.
- A node dominated by . If strictly dominates , then is not in , even if is a join node. In the example, B5 is a join node but is not in , because B3 dominates B5.
- The successors of . is not the set of successors of . A successor can be strictly dominated by , and a node far from can be in , as shows.
Related definitions
- Dominators problem and dominator tree: the relation the frontier is built on.
- Dominance frontier computation: the bottom-up algorithm and the walk from the predecessors.
- Phi-function, SSA construction problem and Cytron SSA construction: phi-functions go on the iterated frontier.
- Pruned SSA form: keeps only the frontier blocks where the variable is live.
- Post-dominance and control dependence: the frontier on the reverse graph.
References
- Ron Cytron, Jeanne Ferrante, Barry K. Rosen, Mark N. Wegman and F. Kenneth Zadeck, Efficiently computing static single assignment form and the control dependence graph, ACM Transactions on Programming Languages and Systems 13(4), 1991, pages 451-490, the definition of the dominance frontier, of DF of a set and of the iterated dominance frontier, the split into DF_local and DF_up, the theorem that the join points of a variable are its iterated dominance frontier, and control dependence as the dominance frontier of the reverse graph
- Vugranam C. Sreedhar and Guang R. Gao, A linear time algorithm for placing phi-nodes, Proceedings of the 22nd ACM Symposium on Principles of Programming Languages (POPL), 1995, pages 62-73, DJ-graphs, and the iterated dominance frontier computed without the full dominance frontiers
- Keith D. Cooper, Timothy J. Harvey and Ken Kennedy, A simple, fast dominance algorithm, technical report, Department of Computer Science, Rice University, the dominance frontier algorithm that walks up the dominator tree from each predecessor of a join node to its immediate dominator
- Andrew W. Appel with Jens Palsberg, Modern Compiler Implementation in Java, second edition, Cambridge University Press, 2002, Chapter 19 (Static Single-Assignment Form), the dominance frontier criterion and the computation of DF
- Fabrice Rastello and Florent Bouchez Tichadou (editors), SSA-based Compiler Design, Springer, 2022, Chapter 3 (Standard Construction and Destruction Algorithms), join sets and dominance frontiers; Chapter 4 (Advanced Construction Algorithms for SSA), DJ-graphs and merge sets
Where this leads
About this page
The build computes these levels from the evidence in the repository. Each row says what the next level needs. Read what the levels mean.
| Ladder | Level | What the next level needs |
|---|---|---|
| Human proof | H0 no proof |
|
| Lean | L0 no Lean part |
|
| Visual | V0 none |
|
| Writing | W4 complete |
|
Tag BRKW75 Edit this page History Report an error Markdown