Validation of GCC optimizers through trace generation

The translation validation approach involves establishing semantics preservation of individual compilations. In this paper, we present a novel framework for translation validation of optimizers. We identify a comprehensive set of primitive program transformations that are commonly used in many optimizations. For each primitive, we define soundness conditions that guarantee that the transformation is semantics preserving. This framework of transformations and soundness conditions is independent of any particular compiler implementation and is formalized in PVS. An optimizer is instrumented to generate the trace of an optimization run in terms of the predefined transformation primitives. The validation succeeds if (1) the trace conforms to the optimization and (2) the soundness conditions of the individual transformations in the trace are satisfied. The first step eliminates the need to trust the instrumentation. The soundness conditions are defined in a temporal logic and therefore the second step involves model checking. Thus the scheme is completely automatable. We have applied this approach to several intraprocedural optimizations of RTL intermediate code in GNU Compiler Collection (GCC) v4.1.0, namely, loop invariant code motion, partial redundancy elimination, lazy code motion, code hoisting, and copy and constant propagation for sample programs written in a subset of the C language. The validation does not require information about program analyses performed by GCC. Therefore even though the GCC code base is quite large and complex, instrumentation could be achieved easily. The framework requires an estimated 21 lines of instrumentation code and 140 lines of PVS specifications for every 1000 lines of the GCC code considered for validation. Copyright © 2009 John Wiley & Sons, Ltd.

[1]  David A. Schmidt,et al.  Program Analysis as Model Checking of Abstract Interpretations , 1998, SAS.

[2]  Eric Van Wyk,et al.  Proving correctness of compiler optimizations by temporal logic , 2002, POPL '02.

[3]  Sabine Glesner,et al.  Using Program Checking to Ensure the Correctness of Compiler Implementations , 2003, J. Univers. Comput. Sci..

[4]  Xavier Leroy Formal verification of an optimizing compiler , 2007 .

[5]  Amir Pnueli,et al.  TVOC: A Translation Validator for Optimizing Compilers , 2005, CAV.

[6]  Xavier Leroy,et al.  Formal verification of translation validators: a case study on instruction scheduling optimizations , 2008, POPL '08.

[7]  Amir Pnueli,et al.  VOC: A Translation Validator for Optimizing Compilers , 2002, COCV@ETAPS.

[8]  Aditya Kanade,et al.  A PVS Based Framework for Validating Compiler Optimizations , 2006, Fourth IEEE International Conference on Software Engineering and Formal Methods (SEFM'06).

[9]  David A. Schmidt Data flow analysis is model checking of abstract interpretations , 1998, POPL '98.

[10]  Ernst-Rüdiger Olderog,et al.  Correct System Design, Recent Insight and Advances, (to Hans Langmaack on the occasion of his retirement from his professorship at the University of Kiel) , 1999 .

[11]  Sorin Lerner,et al.  Automatically proving the correctness of compiler optimizations , 2003, PLDI '03.

[12]  Edmund M. Clarke,et al.  Model Checking , 1999, Handbook of Automated Reasoning.

[13]  Sabine Glesner,et al.  Program Checking with Certificates: Separating Correctness-Critical Code , 2003, FME.

[14]  Arnd Poetzsch-Heffter,et al.  Towards Proof Generating Compilers , 2022 .

[15]  Owre Sam,et al.  Theory Interpretations in PVS , 2001 .

[16]  Martín Abadi,et al.  Authentication in distributed systems: theory and practice , 1991, SOSP '91.

[17]  George C. Necula,et al.  Translation validation for an optimizing compiler , 2000, PLDI '00.

[18]  Aditya Kanade,et al.  Structuring Optimizing Transformations and Proving Them Sound , 2007, COCV@ETAPS.

[19]  Alfred V. Aho,et al.  Compilers: Principles, Techniques, and Tools , 1986, Addison-Wesley series in computer science / World student series edition.

[20]  Mary Lou Soffa,et al.  Catching and Identifying Bugs in Register Allocation , 2006, SAS.

[21]  Gerhard Goos,et al.  Verification of Compilers , 1999, Correct System Design.

[22]  Benjamin Goldberg,et al.  Into the Loops: Practical Issues in Translation Validation for Optimizing Compilers , 2005, COCV@ETAPS.