Master the fundamental concepts of intermediate representation through this focused micro-challenge.
Block A dominates B if every path from entry to B passes through A. Dominance is foundational for SSA phi placement, loop detection, and LICM. Lengauer-Tarjan computes dominators efficiently; LLVM's DominanceInfo wraps this for every pass.
Entry dominates all blocks. Iteratively refine: dom(B) = {B} ∪ ∩ dom(P) for predecessors P of B. The immediate dominator (idom) forms a tree. A dominates B but not strictly if A equals B.
cLoading…
Entry dominates A, B, C. A does not dominate B.
Production compilers embed this step inside a longer pipeline. GCC flows through cpp, cc1, assembly, and ld; Clang uses the driver, Sema, LLVM IR passes, and a target backend. LLVM bitcode, JVM bytecode, and WASM are other familiar IRs at the same layer. The exercise isolates one pass so you can test it alone before chaining it to the next stage.
You will implement dominance analysis on your CFG. This exercise asks you to compute dominator sets or the immediate dominator tree for each basic block, enabling SSA construction and loop analyses.
Implement dominance analysis and dominance frontier computation.
Requirements:
Three hints are available for this task, revealed one at a time inside the code workspace so you can struggle productively before seeing them.
All starter code and reference implementations are available for your local setup.
View on Github