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.
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Cross Ref
- S. Buchwald. Optgen: A generator for local optimizations. In Proceedings of the 24th International Conference on Compiler Construction, pages 171–189, Apr. 2015.Google Scholar
Cross Ref
- 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 Scholar
Digital Library
- 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 Scholar
Cross Ref
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- X. Leroy. Formal verification of a realistic compiler. Commun. ACM, 52(7):107–115, July 2009. Google Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- W. M. McKeeman. Peephole optimization. Commun. ACM, 8 (7):443–444, July 1965. Google Scholar
Digital Library
- J. S. Moore. A mechanically verified language implementation. J. Autom. Reasoning, 5(4):461–492, 1989. Google Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
Index Terms
Verified peephole optimizations for CompCert
Recommendations
Verified peephole optimizations for CompCert
PLDI '16: Proceedings of the 37th ACM SIGPLAN Conference on Programming Language Design and ImplementationTransformations 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 ...
Handling loops in bounded model checking of C programs via k-induction
The first attempts to apply the k-induction method to software verification are only recent. In this paper, we present a novel proof by induction algorithm, which is built on the top of a symbolic context-bounded model checker and uses an iterative ...
CompCertM: CompCert with C-assembly linking and lightweight modular verification
Supporting multi-language linking such as linking C and handwritten assembly modules in the verified compiler CompCert requires a more compositional verification technique than that used in CompCert just supporting separate compilation. The two ...







Comments