Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Regions

The CFG is organized as a tree of SESE (Single Entry, Single Exit) regions. Each region contains an ordered sequence of basic blocks and child regions.

Region Kinds

KindDescription
functionTop-level function region. Every function has exactly one.
loopLoop region. The entry block is the loop header. Backedges use continue.
plainGeneric SESE region for structured control flow.

Nesting and Implicit Capture

Regions nest to form a tree. Values defined in an outer region are visible in inner regions via implicit capture (VPlan style). There is no explicit capture list — the live-in set is computed on demand.

func @example(int) -> int {
  bb0:
    v0 = iconst 10       // v0 defined in function body

  region loop {
    bb1(v1: int):
      v2 = add v1, v0    // v0 captured implicitly from outer scope
      ...
  }
}

Loop Regions

A loop region’s entry block is the loop header. The continue terminator transfers control back to the loop header, passing new values for the header’s block arguments. Exiting a loop is done by branching to a block outside the loop region.