notes

Formal verification of a realistic compiler

Xavier Leroy (INRIA Paris-Rocquencourt)

[PDF]

CompCert

Intermediate languages

The compiler is composed of 14 passes with 8 intermediate languages.

Clight

Large subset of C

Supports:

Omits:

Supported via desugaring:

Semantics defined in big-step operational style

Undefined C behaviors such as null dereference or out-of-bounds array access are consistent “gone wrong” behaviors.

Memory is modeled as disjoint blocks accessed through byte offsets. Pointers are pairs of a block identifier and offset.

C#minor

Cminor

Omits & operator: never-addressed scalar local variables are assigned to Cminor local variables and are candidates for register allocation; other local variables are stack-allocated.

CminorSel

RTL

§4.1:

Dynamic semantics specified in small-step operation style as a labeled transition system.

LTL

LTLin

Linear

Mach

PPC

Register allocation

The register allocation algorithm analyzes the live and dead registers at program points. This is an intrinsic property of static single-assignment form though, which they are not using.

Registers are colored (either as a hardware register or stack slot) where two nodes connected by an interference edge are differently-colored.

Unfortunately the register allocation is not directly-proven, but rather implemented in Coq with the results validated before compilation continues.

Correctness criteria:

  1. color(r) != color(r’) if r and r’ interfere
  2. color(r) != l if r and l interfere
  3. color(r) and r have the same register class (int or float)

This is proven by requiring that the register state of the original program is equal to the location state of the transformed program, for all pseudo-registers live at a point.

Further work

Ongoing work:

They are looking into the feasibility of writing a compiler from Mini-ML (the language Coq extracts to) to Cminor. Once all remaining unverified steps are verified, including the Coq extractor, then this would result in a trusted execution path for programs written in Coq.

Definitions

Looked up externally: