Imagine a city with a single bridge over a river. No matter which road you take into the eastern half, you must cross that bridge. The bridge dominates every destination on the far side.
The same idea appears at the heart of every compiler, every program analyzer, and every security tool that traces how data moves through code. Given a directed graph with a distinguished entry node, we say that node A dominates node B if every path from the entry to B passes through A. By definition the entry dominates itself and everything else; a node can have many dominators. The one closest to B in the domination order â the node that dominates B but is dominated by everything else that also dominates B â is called B's immediate dominator.
The collection of all immediate-dominator relationships forms a tree rooted at the entry. That tree is the dominator tree, and it encodes a remarkable amount of structure: loops, irreducible regions, and safe spots for code motion all become visible the moment you have it in hand.
Computing dominators naively would require checking every possible path â exponentially many in the worst case. The elegant insight of Thomas Lengauer and Robert Tarjan (1979) is that a single depth-first traversal plus a clever link-cut structure is almost enough: their algorithm runs in time on a graph with edges and nodes, where is the inverse Ackermann function â for all practical purposes, linear time.
Comments
Loading comments...