Docs / design / dominance-design · Edit on GitHub

Dominance — Engineering Design

Dominator trees and dominance frontiers — compiler structures that identify where control joins and where definitions reach. Exposed via inspect dom and the dashboard Dataflow tab’s dominator mode.

Dominator tree view (gbuilder)

Figure 1: Dataflow tab with view mode Dominator Tree — tree layout and statement list with frontier sizes.


1. Goals

GoalHow
Immediate dominatorsClassic Cooper–Harvey–Kennedy style tree per function
Dominance frontiersNodes where control from multiple predecessors meet
PDG inputControl-dependence edges derived from dominance
Developer visibilitySame CFG export powers CLI + dashboard

2. Theory → implementation

flowchart LR
  CFG[CFG]
  IDOM[Immediate dominator tree]
  DF[Dominance frontiers]
  PDG[Control dependence edges]
  CFG --> IDOM
  IDOM --> DF
  IDOM --> PDG

For each edge A → B in the CFG, if B does not strictly dominate A, add control dependence from the immediate dominator of B to B.


3. CLI output

rgctl inspect Symbol dom
rgctl inspect Symbol dom --frontiers
rgctl -f json inspect Symbol dom -o dom.json

JSON includes nodes[] with idom, frontier_size when --frontiers is set.


4. Rust implementation map

ComponentPath
Dominator algorithmcrates/rgctl-analysis/src/dominance.rs
CFG integrationcrates/rgctl-analysis/src/cfg.rs
PDG control edgescrates/rgctl-analysis/src/pdg.rs
CLI inspectsrc/cli/inspect.rs

5. Dashboard implementation

PiecePath
View toggleDataflowView.tsxviewMode: "dominator"
Graph layoutcomputeDominatorGraph() in dataflowEngine.ts
Node sizingLarger nodes when frontier_size > 0
LegendsDOMINATOR_NODE_LEGEND, DOMINATOR_EDGE_LEGEND

6. Testing

LayerLocation
Dominance testscrates/rgctl-analysis/src/dominance.rs
Semantic verificationscripts/semantic-verification.sh

Screenshots: capture-design-screenshots.mjsdocs/images/design/dominance/.


7. Related docs