Dominators and Dominator Trees

Compute which blocks every path to a program point must traverse and use immediate dominators to organize that relation.

Source
Anbloq
Language
English
Created
Updated
Chapters
2
Reading time
1 min
In this article2 chapters
  1. Every predecessor constrains dominance
  2. The closest strict dominator gives a tree edge

Every predecessor constrains dominance

For reachable block \(b\), block \(d\) dominates \(b\) if all paths from the entry to \(b\) contain \(d\). A block dominates itself. At a nonentry block, intersect the dominator sets of all reachable predecessors and insert the block itself. In a diamond CFG, the entry dominates the merge, but neither single branch does. Ignore unreachable blocks or give them an explicit separate convention, since a path quantifier over an empty set behaves differently.

The closest strict dominator gives a tree edge

The immediate dominator of a reachable nonentry block is its nearest strict dominator in the dominance relation. These edges form a tree rooted at the entry. Compiler transformations can use the tree to verify that a definition precedes every ordinary use on every path. SSA phi functions handle edge-specific uses at joins. Loop-invariant code motion uses dominance along with safety conditions to select a placement.[1][2]

References

  1. Andrew C. Myers, Cornell CS 4120: Compiler Course Notes ↩
  2. LLVM Project, LLVM Language Reference Manual ↩