skip to main content
article

Verified peephole optimizations for CompCert

Published:02 June 2016Publication History
Skip Abstract Section

Abstract

Transformations over assembly code are common in many compilers. These transformations are also some of the most bug-dense compiler components. Such bugs could be elim- inated by formally verifying the compiler, but state-of-the- art formally verified compilers like CompCert do not sup- port assembly-level program transformations. This paper presents Peek, a framework for expressing, verifying, and running meaning-preserving assembly-level program trans- formations in CompCert. Peek contributes four new com- ponents: a lower level semantics for CompCert x86 syntax, a liveness analysis, a library for expressing and verifying peephole optimizations, and a verified peephole optimiza- tion pass built into CompCert. Each of these is accompanied by a correctness proof in Coq against realistic assumptions about the calling convention and the system memory alloca- tor. Verifying peephole optimizations in Peek requires prov- ing only a set of local properties, which we have proved are sufficient to ensure global transformation correctness. We have proven these local properties for 28 peephole transfor- mations from the literature. We discuss the development of our new assembly semantics, liveness analysis, representa- tion of program transformations, and execution engine; de- scribe the verification challenges of each component; and detail techniques we applied to mitigate the proof burden.

References

  1. A. Appel. Verification of a cryptographic primitive: SHA-256. ACM Transactions on Programming Languages and Systems, 37(2):7:1–7:31, Apr. 2015. Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. S. Bansal and A. Aiken. Automatic generation of peephole superoptimizers. In Proceedings of the 12th International Conference on Architectural Support for Programming Languages and Operating Systems, pages 394–403, Oct. 2006. Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. F. Besson, S. Blazy, and P. Wilke. A concrete memory model for CompCert. In Proceedings of the 6th International Conference on Interactive Theorem Proving, pages 67–83, July 2015.Google ScholarGoogle ScholarCross RefCross Ref
  4. S. Buchwald. Optgen: A generator for local optimizations. In Proceedings of the 24th International Conference on Compiler Construction, pages 171–189, Apr. 2015.Google ScholarGoogle ScholarCross RefCross Ref
  5. A. Chlipala. A verified compiler for an impure functional language. In Proceedings of the 37th ACM Symposium on Principles of Programming Languages, pages 93–106, Jan. 2011. Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. S. Z. Guyer and C. Lin. Broadway: A compiler for exploiting the domain-specific semantics of software libraries. Proceedings of the IEEE, 93(2):342–357, Feb. 2005.Google ScholarGoogle ScholarCross RefCross Ref
  7. J. Kang, C.-K. Hur, W. Mansky, D. Garbuzov, S. Zdancewic, and V. Vafeiadis. A formal C memory model supporting integer-pointer casts. In Proceedings of the 36th ACM SIGPLAN Conference on Programming Language Design and Implementation, pages 326–335, June 2015. Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. S. Kundu, Z. Tatlock, and S. Lerner. Proving optimizations correct using parameterized program equivalence. In Proceedings of the 30th ACM SIGPLAN Conference on Programming Language Design and Implementation, June 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. V. Le, M. Afshari, and Z. Su. Compiler validation via equivalence modulo inputs. In Proceedings of the 35th ACM SIGPLAN Conference on Programming Language Design and Implementation, pages 216–226, June 2014. Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. S. Lerner, T. Millstein, and C. Chambers. Cobalt: A language for writing provably-sound compiler optimizations. Electronic Notes in Theoretical Compututer Science, 132:5–17, 2005. Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. S. Lerner, T. Millstein, E. Rice, and C. Chambers. Automated soundness proofs for dataflow analyses and transformations via local rules. In Proceedings of the 32nd ACM Symposium on Principles of Programming Languages, pages 364–377, Jan. 2005. Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. X. Leroy. Formal verification of a realistic compiler. Commun. ACM, 52(7):107–115, July 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. N. P. Lopes, D. Menendez, S. Nagarakatte, and J. Regehr. Provably correct peephole optimizations with Alive. In Proceedings of the 36th ACM SIGPLAN Conference on Programming Language Design and Implementation, pages 22–32, June 2015. Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. H. Massalin. Superoptimizer: A look at the smallest program. In Proceedings of the 2nd International Conference on Architectural Support for Programming Languages and Operating Systems, pages 122–126, Oct. 1987. Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. W. M. McKeeman. Peephole optimization. Commun. ACM, 8 (7):443–444, July 1965. Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. J. S. Moore. A mechanically verified language implementation. J. Autom. Reasoning, 5(4):461–492, 1989. Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. G. Morrisett, G. Tan, J. Tassarotti, J.-B. Tristan, and E. Gan. Rocksalt: Better, faster, stronger SFI for the x86. In Proceedings of the 33rd ACM SIGPLAN Conference on Programming Language Design and Implementation, pages 395–404, June 2012. Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. S. Owens, S. Sarkar, and P. Sewell. A better x86 memory model: X86-TSO. In Proceedings of the 22nd International Conference on Theorem Proving in Higher Order Logics, pages 391–407, Aug. 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library
  19. P. M. Phothilimthana, T. Jelvis, R. Shah, N. Totla, S. Chasins, and R. Bodik. Chlorophyll: Synthesis-aided compiler for lowpower spatial architectures. In Proceedings of the 35th ACM SIGPLAN Conference on Programming Language Design and Implementation, pages 396–407, June 2014. Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. S. Rideau and X. Leroy. Validating register allocation and spilling. In Proceedings of the 19th International Conference on Compiler Construction, pages 224–243, Apr. 2010. Google ScholarGoogle ScholarDigital LibraryDigital Library
  21. V. Robert and X. Leroy. A formally verified alias analysis. In Proceedings of the 2nd International Conference on Certified Programs and Proofs, pages 11–26, Dec. 2012. Google ScholarGoogle ScholarDigital LibraryDigital Library
  22. E. Schkufza, R. Sharma, and A. Aiken. Stochastic superoptimization. In Proceedings of the 18th International Conference on Architectural Support for Programming Languages and Operating Systems, pages 305–316, Mar. 2013. Google ScholarGoogle ScholarDigital LibraryDigital Library
  23. E. Schkufza, R. Sharma, and A. Aiken. Stochastic optimization of floating-point programs with tunable precision. In Proceedings of the 35th ACM SIGPLAN Conference on Programming Language Design and Implementation, pages 53– 64, June 2014. Google ScholarGoogle ScholarDigital LibraryDigital Library
  24. Z. Tatlock and S. Lerner. Bringing extensibility to verified compilers. In Proceedings of the 31st ACM SIGPLAN Conference on Programming Language Design and Implementation, pages 111–121, June 2010. Google ScholarGoogle ScholarDigital LibraryDigital Library
  25. J.-B. Tristan and X. Leroy. Verified validation of lazy code motion. In Proceedings of the 30th ACM SIGPLAN Conference on Programming Language Design and Implementation, pages 316–326, June 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library
  26. J.-B. Tristan and X. Leroy. A simple, verified validator for software pipelining. In Proceedings of the 37th ACM Symposium on Principles of Programming Languages, pages 83–92, Jan. 2011. Google ScholarGoogle ScholarDigital LibraryDigital Library
  27. J. ˇSevˇc´ık, V. Vafeiadis, F. Zappa Nardelli, S. Jagannathan, and P. Sewell. CompCertTSO: A verified compiler for relaxedmemory concurrency. J. ACM, 60(3), June 2013. Google ScholarGoogle ScholarDigital LibraryDigital Library
  28. D. L. Whitfield and M. L. Soffa. An approach for exploring code improving transformations. ACM Transactions on Programming Languages and Systems, 19(6):1053–1084, Nov. 1997. Google ScholarGoogle ScholarDigital LibraryDigital Library
  29. X. Yang, Y. Chen, E. Eide, and J. Regehr. Finding and understanding bugs in C compilers. In Proceedings of the 32nd ACM SIGPLAN Conference on Programming Language Design and Implementation, pages 283–294, June 2011. Google ScholarGoogle ScholarDigital LibraryDigital Library
  30. J. Zhao, S. Nagarakatte, M. M. K. Martin, and S. Zdancewic. Formalizing the LLVM intermediate representation for verified program transformations. In Proceedings of the 39th ACM Symposium on Principles of Programming Languages, pages 427–440, Jan. 2012. Google ScholarGoogle ScholarDigital LibraryDigital Library
  31. J. Zhao, S. Nagarakatte, M. M. K. Martin, and S. Zdancewic. Formal verification of SSA-based optimizations for LLVM. In Proceedings of the 34th ACM SIGPLAN Conference on Programming Language Design and Implementation, pages 175–186, June 2013. Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Verified peephole optimizations for CompCert

                Recommendations

                Comments

                Login options

                Check if you have access through your login credentials or your institution to get full access on this article.

                Sign in

                Full Access

                • Published in

                  cover image ACM SIGPLAN Notices
                  ACM SIGPLAN Notices  Volume 51, Issue 6
                  PLDI '16
                  June 2016
                  726 pages
                  ISSN:0362-1340
                  EISSN:1558-1160
                  DOI:10.1145/2980983
                  • Editor:
                  • Andy Gill
                  Issue’s Table of Contents
                  • cover image ACM Conferences
                    PLDI '16: Proceedings of the 37th ACM SIGPLAN Conference on Programming Language Design and Implementation
                    June 2016
                    726 pages
                    ISBN:9781450342612
                    DOI:10.1145/2908080
                    • General Chair:
                    • Chandra Krintz,
                    • Program Chair:
                    • Emery Berger

                  Copyright © 2016 ACM

                  Publisher

                  Association for Computing Machinery

                  New York, NY, United States

                  Publication History

                  • Published: 2 June 2016

                  Check for updates

                  Qualifiers

                  • article

                PDF Format

                View or Download as a PDF file.

                PDF

                eReader

                View online with eReader.

                eReader
                About Cookies On This Site

                We use cookies to ensure that we give you the best experience on our website.

                Learn more

                Got it!