skip to main content
article

A new verified compiler backend for CakeML

Published:04 September 2016Publication History
Skip Abstract Section

Abstract

We have developed and mechanically verified a new compiler backend for CakeML. Our new compiler features a sequence of intermediate languages that allows it to incrementally compile away high-level features and enables verification at the right levels of semantic detail. In this way, it resembles mainstream (unverified) compilers for strict functional languages. The compiler supports efficient curried multi-argument functions, configurable data representations, exceptions that unwind the call stack, register allocation, and more. The compiler targets several architectures: x86-64, ARMv6, ARMv8, MIPS-64, and RISC-V.

In this paper, we present the overall structure of the compiler, including its 12 intermediate languages, and explain how everything fits together. We focus particularly on the interaction between the verification of the register allocator and the garbage collector, and memory representations. The entire development has been carried out within the HOL4 theorem prover.

References

  1. G. Barthe, D. Demange, and D. Pichardie. Formal verification of an SSAbased middle-end for CompCert. ACM Trans. Program. Lang. Syst., 36 (1), Mar. 2014. doi:10.1145/2579080. Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. S. Blazy, B. Robillard, and A. W. Appel. Formal verification of coalescing graph-coloring register allocation. In A. D. Gordon, editor, European Symposium on Programming (ESOP). Springer, 2010. doi:10.1007/978- 3-642-11957-6_9. Q. Carbonneaux, J. Hoffmann, T. Ramananandro, and Z. Shao. End-to-end verification of stack-space bounds for C programs. SIGPLAN Not., 49 (6), June 2014. doi:10.1145/2666356.2594301. Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. A. Chlipala. A verified compiler for an impure functional language. In M. V. Hermenegildo and J. Palsberg, editors, Principles of Programming Languages (POPL). ACM, Jan. 2010. doi:10.1145/1707801.1706312. Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. D. Demange, D. Pichardie, and L. Stefanesco. Verifying fast and sparse SSA-based optimizations in Coq. In B. Franke, editor, Compiler Construction (CC). Springer, 2015. doi:10.1007/978-3-662-46663-6_12. P. Gammie, A. L. Hosking, and K. Engelhardt. Relaxing safely: verified onthe-fly garbage collection for x86-TSO. In D. Grove and S. Blackburn, editors, Programming Language Design and Implementation (PLDI). ACM, 2015. doi:10.1145/2813885.2738006. Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. L. George and A. W. Appel. Iterated register coalescing. ACM Trans. Program. Lang. Syst., 18(3), May 1996. doi:10.1145/229542.229546. Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. R. Kumar, M. O. Myreen, M. Norrish, and S. Owens. CakeML: a verified implementation of ML. In S. Jagannathan and P. Sewell, editors, Principles of Programming Languages (POPL), 2014. Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. doi:10.1145/2535838.2535841.Google ScholarGoogle Scholar
  8. X. Leroy. A formally verified compiler back-end. J. Autom. Reasoning, 43 (4), 2009. doi:10.1007/s10817-009-9155-4. A. McCreight, T. Chevalier, and A. Tolmach. A certified framework for compiling and executing garbage-collected languages. In International Conference on Functional Programming (ICFP). ACM, 2010. Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. doi:10.1145/1863543.1863584.Google ScholarGoogle Scholar
  10. E. Mullen, D. Zuniga, Z. Tatlock, and D. Grossman. Verified peephole optimizations for CompCert. In C. Krintz and E. Berger, editors, Programming Language Design and Implementation (PLDI). ACM, 2016. Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. M. O. Myreen. Reusable verification of a copying collector. In G. T. Leavens, P. W. O’Hearn, and S. K. Rajamani, editors, Verified Software: Theories, Tools, Experiments (VSTTE). Springer, 2010. doi:10.1007/978-3- 642-15057-9_10. M. O. Myreen and J. Davis. A verified runtime for a verified theorem prover. In M. C. J. D. van Eekelen, H. Geuvers, J. Schmaltz, and F. Wiedijk, editors, Interactive Theorem Proving (ITP), 2011. Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. G. Neis, C. Hur, J. Kaiser, C. McLaughlin, D. Dreyer, and V. Vafeiadis. Pilsner: a compositionally verified compiler for a higher-order imperative language. In K. Fisher and J. H. Reppy, editors, International Conference on Functional Programming (ICFP), 2015. Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. doi:10.1145/2784731.2784764.Google ScholarGoogle Scholar
  14. L. O’Connor, C. Rizkallah, Z. Chen, S. Amani, J. Lim, Y. Nagashima, T. Sewell, A. Hixon, G. Keller, T. C. Murray, and G. Klein. COGENT: certified compilation for a functional systems language. CoRR, abs/1601.05520, 2016.Google ScholarGoogle Scholar
  15. S. Owens, M. O. Myreen, R. Kumar, and Y. K. Tan. Functional big-step semantics. In P. Thiemann, editor, European Symposium on Programming (ESOP), LNCS. Springer, 2016.Google ScholarGoogle Scholar
  16. L. Rideau, B. P. Serpette, and X. Leroy. Tilting at windmills with Coq: Formal verification of a compilation algorithm for parallel moves. J. Autom. Reason., 40(4), May 2008. doi:10.1007/s10817-007-9096-8. S. Rideau and X. Leroy. Validating Register Allocation and Spilling. In R. Gupta, editor, Compiler Construction, volume 6011 of LNCS. Springer Berlin Heidelberg, 2010. doi:10.1007/978-3-642-11970-5_13. J. Ševˇcík, V. Vafeiadis, F. Zappa Nardelli, S. Jagannathan, and P. Sewell. CompCertTSO: A verified compiler for relaxed-memory concurrency. J. ACM, 60(3), 2013. doi:10.1145/2487241.2487248. Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. T. A. L. Sewell, M. O. Myreen, and G. Klein. Translation validation for a verified OS kernel. In Programming Language Design and Implementation (PLDI). ACM, 2013. doi:10.1145/2491956.2462183. Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. G. Stewart, L. Beringer, S. Cuellar, and A. W. Appel. Compositional Comp-Cert. In S. K. Rajamani and D. Walker, editors, Principles of Programming Languages (POPL). ACM, 2015. doi:10.1145/2676726.2676985. Google ScholarGoogle ScholarDigital LibraryDigital Library
  19. Y. K. Tan, S. Owens, and R. Kumar. A verified type system for CakeML. In Implementation and Application of Functional Programming Languages (IFL). ACM Press, 2015. doi:10.1145/2897336.2897344. Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. S. Ullrich and D. Lohner. Verified construction of static single assignment form. Archive of Formal Proofs, Feb. 2016. http://afp.sf.net/ entries/Formal_SSA.shtml, Formal proof development. X. Yang, Y. Chen, E. Eide, and J. Regehr. Finding and understanding bugs in C compilers. In M. W. Hall and D. A. Padua, editors, Programming Language Design and Implementation (PLDI), 2011. Google ScholarGoogle ScholarDigital LibraryDigital Library
  21. doi:10.1145/1993498.1993532.Google ScholarGoogle Scholar
  22. J. Zhao, S. Nagarakatte, M. M. Martin, and S. Zdancewic. Formal verification of SSA-based optimizations for LLVM. In H. Boehm and C. Flanagan, editors, Programming Language Design and Implementation (PLDI). ACM, 2013. doi:10.1145/2491956.2462164. Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. A new verified compiler backend for CakeML

              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 9
                ICFP '16
                September 2016
                501 pages
                ISSN:0362-1340
                EISSN:1558-1160
                DOI:10.1145/3022670
                Issue’s Table of Contents
                • cover image ACM Conferences
                  ICFP 2016: Proceedings of the 21st ACM SIGPLAN International Conference on Functional Programming
                  September 2016
                  501 pages
                  ISBN:9781450342193
                  DOI:10.1145/2951913

                Copyright © 2016 ACM

                Publisher

                Association for Computing Machinery

                New York, NY, United States

                Publication History

                • Published: 4 September 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!