Abstract
Rewrite rules with side conditions can elegantly express many classical compiler optimizations for imperative programming languages. In this paper, programs are written in an intermediate language and transformation-enabling side conditions are specified in a temporal logic suitable for describing program data flow.
The purpose of this paper is to show how such transformations may be proven correct. Our methodology is illustrated by three familiar optimizations: dead code elimination, constant folding, and code motion. A transformation is correct if whenever it can be applied to a program, the original and transformed programs are semantically equivalent, i.e., they compute the same input-output function. The proofs of semantic equivalence inductively show that a transformation-specific bisimulation relation holds between the original and transformed program computations.
Article PDF
Similar content being viewed by others
Avoid common mistakes on your manuscript.
References
Abramsky, S. and Hankin, C. Abstract Interpretation of Declarative Languages. Ellis-Horwood, 1987.
Aho, A.V., Sethi, R., and Ullman, J.D. Compilers: Principles, Techniques, and Tools. Addison Wesley, 1986.
Assmann, U. How to uniformly specify program analysis and transformation. In Proc. 6th International Conference on Compiler Construction (CC'96), vol. 1060 of Lecture Notes in Computer Science, Springer-Verlag, 1996, pp. 121-135.
Clarke, E.M., Emerson, E.A., and Sistla, A.P. Automatic verification of finite-state concurrent systems using temporal logic specifications. ACM Transactions on Programming Languages and Systems (TOPLAS), 8(2) (1986) 244-263.
Cleaveland, R. and Jackson, D. In Proceedings of First ACM SIGPLAN Workshop on Automated Analysis of Software. Paris, France, Jan. 1997.
Cousot, P. Semantic foundations of program analysis. In Program Flow Analysis: Theory and Applications, S.S. Muchnick and N.D. Jones (Eds.), Englewood Cliffs, NJ, Prentice Hall, 1981, chap. 10, pp. 303-342.
Cousot, P. and Cousot, R. Abstract interpretation: A unified lattice model for static analysis of programs by construction or approximation of fix-points. In Fourth ACM Symposium on Principles of Programming Languages, Los Angeles, California, January 1977, New York, ACM, 1977, pp. 238-252.
Cousot, P. and Cousot, R. Systematic design of program transformations by abstract interpretation. In Proc. of 29th ACM Symposium on Principles of Programming Languages, ACM, 2000, pp. 178-190.
Cousot, P. and Cousot, R. Systematic design of program transformation frameworks by abstract interpretation. In Proc. of the 29th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, Portland, Oregon, ACM Press, 2002, pp. 178-190.
Frederiksen, C.C. Correctness of classical compiler optimizations using CTL. Unpublished TOPPS report, University of Copenhagen, 2001. www.diku.dk/research-groups/topps/bibliography/2001.html#D-443.
Frederiksen, C.C. Correctness of classical compiler optimizations using CTL logic. In Compiler Optimization meets Compiler Verification (COCV), Satellite workshop at ETAPS 2002.
Hafer, Th. and Thomas, W. Computation tree logic CTL* and path quantifiers in the monadic theory of the binary tree. In Automata, Languages and Programming Proceedings, ICALP'87, vol. 267 of Lecture Notes in Computer Science, Springer-Verlag, 1987, pp. 267-279.
Havelund, K. Stepwise Development of a Denotational Stack Semantics. M.Sc. thesis, University of Copenhagen, 1984.
Hecht, M. Flow Analysis of Computer Programs. North-Holland, 1977.
Jones, N.D. (Ed.), Semantics-Directed Compiler Generation, vol. 94 of Lecture Notes in Computer Science, Springer-Verlag, 1980.
Jones, N.D. Semantique: Semantic-based program manipulation techniques. In Bulletin European Association for Theoretical Computer Science, 39 (1989) 74-83.
Jones, N.D. and Nielson, F. Abstract interpretation: A semantics-based tool for program analysis. In Handbook of Logic in Computer Science, S. Abramsky, D. Gabbay, and T. Maibaum (Eds.), Oxford University Press, 1994, pp. 527-629.
Knoop, J., Rüthing, O., and Steffen, B. Optimal code motion: Theory and practice. ACM Transactions on Programming Languages and Systems (TOPLAS), 16(4) (1994) 1117-1155.
Kozen, D. and Patron, M. Certification of compiler optimizations using Kleene algebra with tests. In Proceedings of the 1st International Conference on Computational Logic (CL2000), J. Lloyd, V. Dahl, U. Furbach, M. Kerber, K.-K. Lau, C. Palamidessi, L.M. Pereira, Y. Sagiv, and P.J. Stuckey (Eds.), Lecture Notes in Artificial Intelligence, vol. 1861, Springer-Verlag, London, 2000, pp. 568-582.
Kripke, S. Semantical analysis of modal logic i: Normal modal propositional calculi. Zeitschrift f. Math. Logik und Grundlagen d. Math., 9 (1963).
Kupferman, O. and Pnueli, A. Once and for all. In Proc. 10th IEEE Symposium on Logic in Computer Science, San Diego, 1995, pp. 25-35.
Lacey, D. Program transformation using temporal logic specification. DPhil Thesis (forthcoming). Oxford University Computing Laboratory, 2003.
Lacey, D. and de Moor, O. Imperative program transformation by rewriting. In Proc. 10th International Conf. on Compiler Construction, vol. 1113 of Lecture Notes in Computer Science, Springer-Verlag, 2001, pp. 52-68.
Lacey, D., Jones, N.D., Van Wyk, E. and Frederiksen, C.C. Proving correctness of compiler optimizations by temporal logic. In 29th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, 2002, pp. 283-294.
Lerner, S., Grove, D., and Chambers, C. Composing dataflow analyses and transformations. In 29th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, 2002, pp. 283-294.
Lerner, S., Millstein, T., and Chambers, C. Automatically proving correctness of compiler optimizations. Technical Report UW-CSE-02-11-02, University of Washington, 2002.
Milne, R. and Strachey, C. A Theory of Programming Language Semantics. Chapman and Hall, 1976.
Muchnick, S.S. Advanced Compiler Design and Implementation. Morgan Kaufmann, 1997.
Muchnick, S.S. and Jones, N.D. (Eds.), Program Flow Analysis: Theory and Applications. Englewood Cliffs, NJ, Prentice Hall, 1981.
Nielson, F. Semantic Foundations of Data Flow Analysis. M.Sc. thesis, Aarhus University, DAIMI PB-131, 1981
Nielson, F. A denotational framework for data flow analysis. Acta Informatica, 18 (1982) 265-287.
Nielson, F., Nielson, H.R., and Hankin, C. Principles of Program Analysis. Springer-Verlag, 1999.
Pinter, S.S. and Wolper, P. A temporal logic for reasoning about partially ordered computations. In Proc. 3rd ACM Symposium on Principles of Distributed Computing, 1984, pp. 28-37.
Podelski, A., Steffen, B., and Vardi, M. Schloss Ringberg Seminar: Model Checking and Program Analysis. Workshop, Feb. 2000, Bavaria.
Rus, T. and Van Wyk, E. Using model checking in a parallelizing compiler. Parallel Processing Letters, 8(4) (1998) 459-471.
Schmidt, D.A. Data-flow analysis is model checking of abstract interpretations. In Proc. of 25th ACM Symposium on Principles of Programming Languages, ACM, 1998.
Schmidt, D.A. and Steffen, B. Program analysis as model checking of abstract interpretations. In Proc. of 5th Static Analysis Symposium, G. Levi (Ed.), Pisa, vol. 1503 of Lecture Notes in Computer Science, Springer-Verlag, 1998.
SRI International. The PVS specification and verification system http://pvs.csl.sri.com/
Steckler, P.A. and Wand, M. Lightweight closure conversion. ACM Transactions on Programming Languages and Systems, ACM, 19(1) (1997) 48-86.
Steffen, B. Data flow analysis as model checking. In Proc. of 1st International Conference on Theoretical Aspects of Computer Software (TACS'91), Heidelberg, vol. 526 of Lecture Notes in Computer Science, Springer-Verlag, 1991, pp. 346-364.
Steffen, B. Generating data flow analysis algorithms from modal specifications. In Science of Computer Programming, 1993, vol. 21, pp. 115-139.
Steffen, B., Claßen, A., Klein, M., Knoop, J., and Margaria, T. The fixpoint analysis machine. In Proc. of the 6th International Conference on Concurrency Theory (CONCUR'95), J. Lee and S. Smolka (Eds.), Philadelphia, Pennsylvania (USA), vol. 962 of Lecture Notes in Computer Science, Springer-Verlag, 1995, pp. 72-87.
Visser, E., Benaissa, Z., and Tolmach, A. Building program optimizers with rewriting strategies. In Proc. of ACM SIGPLAN International Conference on Functional Programming (ICFP'98), ACM, 1998, pp. 13-26.
Whitfield, D. and Soffa, M.L. Automatic generation of global optimisers. In Proc. of ACM SIGPLAN on Program Language Design and Implementation (PLDI'91), ACM, 1991, pp. 120-129.
Whitfield, D. and Soffa, M.L. An approach for exploring code-improving transformations. In ACM Transactions on Programming Languages and Systems, ACM, 1997, vol. 19,no. 6, pp. 1053-1084.
Winskel, G. The Formal Semantics of Programming Languages. Boston, MA, the MIT Press, 1993.
Wolper, P. On the relation of programs and computations to models of temporal logic. In Proc. Temporal Logic in Specification, vol. 398 of Lecture Notes in Computer Science, Springer-Verlag, 1987, pp. 75-123.
Author information
Authors and Affiliations
Rights and permissions
This article is published under an open access license. Please check the 'Copyright Information' section either on this page or in the PDF for details of this license and what re-use is permitted. If your intended use exceeds what is permitted by the license or if you are unable to locate the licence and re-use information, please contact the Rights and Permissions team.
About this article
Cite this article
Lacey, D., Jones, N.D., Van Wyk, E. et al. Compiler Optimization Correctness by Temporal Logic. Higher-Order and Symbolic Computation 17, 173–206 (2004). https://doi.org/10.1023/B:LISP.0000029444.99264.c0
Issue Date:
DOI: https://doi.org/10.1023/B:LISP.0000029444.99264.c0