Abstract
TVOC is a tool designed to ensure that optimizing compilers do not introduce errors into code during the transformation process. Rather than attempting the monumental task of formally verifying an entire, evolving compiler, TVOC employs "translation validation." This approach mathematically proves that the specific output of a compilation run is equivalent to the original source code.
Introduction: The Challenge of Compiler Optimization
Modern optimizing compilers are highly complex, performing hundreds of transformations to improve performance. However, their size and constant updates make them susceptible to subtle bugs. Formally verifying a full compiler—proving it will always produce correct code—is practically impossible.
TVOC addresses this by acting as an independent validator at the end of the compilation pipeline. By comparing the source program with the generated target program, TVOC attempts to prove their functional equivalence. If an optimization introduces a bug, TVOC is designed to detect it before the code is deployed.
Methods and Architecture
TVOC operates on programs in the WHIRL intermediate representation, used by Intel’s Open Research Compiler (ORC). The validation process is divided into two distinct phases to handle different classes of optimizations.
Phase 1: Reordering Transformations
This phase focuses on "loop-level" optimizations, such as loop interchange, fusion, and tiling. These transformations alter the execution order of statements without typically changing the underlying logic. TVOC employs a proof rule called PERMUTE to generate verification conditions, ensuring that these reorderings preserve the program's final state.
Phase 2: Structure-Preserving Transformations
This phase handles standard optimizations like constant folding and dead code elimination, where the basic control flow structure remains consistent. It utilizes a proof rule called VALIDATE, which requires establishing a control mapping (matching "cut-points" between source and target) and a data mapping (ensuring variable correspondence).
The mathematical verification conditions generated in both phases are processed by CVC Lite, an automated theorem prover that determines if the transformations are valid.
Key Insights
- Decomposition: Splitting validation into reordering and structure-preserving phases makes the verification task manageable by using specialized proof rules for different compiler behaviors.
- Soundness Priority: TVOC prioritizes soundness over completeness. While it may occasionally fail to prove a complex but correct transformation (a false negative), it is designed to never incorrectly validate a buggy program (a false positive).
- Automated Mapping: TVOC automates the generation of cut-points and data mappings, which are traditionally the most labor-intensive aspects of translation validation.
Results and Evaluation
As a research prototype, TVOC has been evaluated using Intel’s ORC and specific test programs. A key success was demonstrating the tool's ability to validate complex transformations, such as loop fusion combined with the insertion of branch conditions. By generating logical equations using "primed variables" to represent state changes, TVOC successfully used CVC Lite to confirm program integrity in these scenarios.
Limitations and Future Work
Despite its promise, TVOC currently has several limitations:
- Language Support: The current prototype lacks support for procedures (functions) and pointers, which are critical for real-world C/C++ applications.
- Inductive Invariants: Complex data mappings sometimes require invariants that are not easily generated. While simple data-flow analysis helps, more sophisticated techniques are needed for complex cases.
- Tool Maturity: TVOC remains a research prototype, with ongoing work focused on expanding its capabilities for production environments.
Summary updated