Algorithm Search⌘K

Intermediate representations

Problems

  • Out-of-SSA translation

    Replace the phi-functions of an SSA program by copies on incoming edges so that the program runs on a machine without phi-functions.

    core
  • SSA construction

    Given a program in a non-SSA IR, insert phi-functions and rename variables so that each has one definition and the meaning is kept.

    core

Algorithms

  • CPS conversion

    Translates a direct-style program into continuation-passing style, in one pass without administrative redexes by the Danvy-Filinski method.

    O(n) worst1 languagescore
  • Closure conversion

    Turns each function with free variables into closed code plus an environment record, so that functions can be compiled as plain code.

    O(n^2) worst1 languagescore
  • Cooper-Harvey-Kennedy dominance algorithm

    Computes immediate dominators by iterating over the nodes in reverse postorder and intersecting paths in the partial dominator tree.

    O((d + 2) n (n + m)) worst1 languagescore
  • Cytron SSA construction

    Builds minimal SSA form by placing phi-functions at the iterated dominance frontiers of each variable's definitions and renaming over the dominator tree.

    O(I + V (n + m + D)) worst · average1 languagescore
  • Dominance frontier computation

    Computes all dominance frontiers in time linear in their total size by a bottom-up walk of the dominator tree.

    Θ(n + m + D) worst · average · best1 languagescore
  • Lambda lifting

    Moves local functions to the top level and passes their free variables as extra parameters at each call.

    O(n^3) worst1 languagescore
  • T1-T2 reduction

    Tests reducibility by removing self-loops and merging nodes with a single predecessor; the graph is reducible if one node remains.

    O(n^2 + m) worst1 languagescore
  • Braun SSA construction algorithm

    Builds SSA form directly from an AST or CFG by local value numbering and on-demand lookup in predecessors, with no dominance frontiers.

    O(I + (B + E) V + B^2 V^2) worst · average1 languagesadvanced
  • Sreedhar out-of-SSA translation

    Converts SSA into conventional SSA, where phi-related names do not interfere, by inserting copies, and then drops all phi-functions.

    O(F B N V + N^2 V^2) worst · average1 languagesadvanced

Data structures

  • Def-use chains

    Links each definition of a variable to the uses it can reach and each use to the definitions that can reach it.

    1 languagesintro
  • Program dependence graph

    A graph of the statements of a procedure with edges for data and control dependences, used for slicing, vectorization and scheduling.

    O(m + c) control-edges1 languagescore
  • Loop nesting forest

    A forest whose nodes are the loops of a flow graph, with each loop below the loops that contain it, defined for irreducible graphs too.

    1 languagesadvanced
  • Sea of nodes

    A graph IR in SSA where data and control are both edges and most instructions float free of blocks until scheduling.

    O(n + b v) expected build1 languagesadvanced

Techniques

  • Critical edge splitting

    Puts a new empty block on each edge from a block with several successors to a block with several predecessors, to host inserted code.

    core
  • Defunctionalization

    Replaces first-class functions by data constructors, one per lambda, and an apply function that dispatches on the constructor.

    advanced

Concepts

  • Intermediate representation

    A form of the program between source and machine code on which a compiler analyzes and transforms the program.

    intro
  • Lost-copy and swap problems

    Two cases where naive phi removal is wrong after copy folding, because phi copies are parallel and live ranges interfere.

    advanced

Definitions

  • Basic block

    A maximal sequence of instructions entered only at the first one and left only at the last, so it runs all or nothing.

    intro
  • Call graph

    A directed graph with one node per procedure and an edge from caller to callee for each possible call.

    intro
  • Control flow graph

    A directed graph whose nodes are the basic blocks of a procedure and whose edges are the possible transfers of control between them.

    intro
  • Three-address code

    A linear IR whose instructions have at most one operator and three operands, such as x = y op z, with jumps for control.

    intro
  • Continuation-passing style

    A form where no function returns, and each call passes a continuation that receives the result, so control flow is explicit.

    core
  • Control dependence

    Node n is control dependent on branch b if one edge out of b forces n to run and another can skip it, found from post-dominance frontiers.

    core
  • Dominance frontier

    The nodes where the dominance of a node n ends, that is, nodes with a predecessor dominated by n that are not strictly dominated by n.

    core
  • Natural loop

    For a back edge n to h where h dominates n, the set of nodes that reach n without passing through h, with h as the single header.

    core
  • Phi node

    An SSA instruction at the head of a block that takes one operand per incoming edge and yields the operand of the edge taken.

    core
  • Post-dominance

    Block p post-dominates block v if every path from v to the exit passes through p; the immediate post-dominators form a tree rooted at the exit.

    core
  • Reducible flow graph

    A flow graph whose retreating edges are all back edges to dominators, so every loop has one entry, as in structured programs.

    core
  • Static single assignment form

    An IR where each variable has exactly one definition, with phi-functions at join points that choose a value by the incoming edge.

    core
  • A-normal form

    A direct-style IR where each argument is a variable or constant and each intermediate result is named by let, with the benefits of CPS.

    advanced
  • Pruned SSA form

    Minimal SSA form without the phi-functions whose variable is dead at the join, found with liveness.

    advanced
  • Static single information form

    An extension of SSA that also splits variables at branches with sigma-functions, so that facts learned from conditions get their own names.

    research

Theorems