We describe a technique for automatically proving compiler optimizations sound, meaning that their transformations are always semantics-preserving. As is well known, IR (Intermediate Representation) optimization is an important step in a compiler backend. But unfortunately, it is difficult to detect and debug the IR optimization errors for compiler developers. So, we introduce a C level error check system for detecting the correctness of these IR transformation techniques. In our system, we first create an IR-to-C converter to translate IR to C code before and after each compiler optimization phase, respectively, since our technique is based on the Memory Comparison-based Clone(MeCC) detector which is a tool of detecting semantic equivalency in C level. MeCC accepts only C codes as its input and it uses a path-sensitive semantic-based static analyzer to estimate the memory states at exit point of each procedure, and compares memory states to determine whether the procedures are equal or not. But MeCC cannot guarantee two semantic-equivalency codes always have 100% similarity or two codes with different semantics does not get the result of 100% similarity. To increase the reliability of the results, we describe a technique which comprises how to generate C codes in IR-to-C transformation phase and how to send the optimization information to MeCC to avoid the occurrence of these unexpected problems. Our methodology is illustrated by three familiar optimizations, dead code elimination, instruction scheduling and common sub-expression elimination and our experimental results show that the C level error check system is highly reliable.
[1]
Vipin Swarup,et al.
The VLISP verified Scheme system
,
1995,
LISP Symb. Comput..
[2]
Robert S. Boyer,et al.
The Boyer-Moore theorem prover and its interactive enhancement
,
1995
.
[3]
Amir Pnueli,et al.
Translation Validation
,
1998,
TACAS.
[4]
F. Lockwood Morris,et al.
Advice on structuring compilers and proving them correct
,
1973,
POPL.
[5]
Mitchell Wand,et al.
VLISP: A verified implementation of Scheme
,
1995,
LISP Symb. Comput..
[6]
Heejung Kim,et al.
MeCC: memory comparison-based clone detector
,
2011,
2011 33rd International Conference on Software Engineering (ICSE).
[7]
Bernhard Steffen,et al.
Optimal code motion: theory and practice
,
1994,
TOPL.
[8]
P. Favati,et al.
Peano Kernel behaviour and error bounds for symmetric quadrature formulas
,
1995
.
[9]
Bernhard Steffen,et al.
Generating Data Flow Analysis Algorithms from Modal Specifications
,
1993,
Sci. Comput. Program..
[10]
George C. Necula,et al.
Translation validation for an optimizing compiler
,
2000,
PLDI '00.