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.
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- L. George and A. W. Appel. Iterated register coalescing. ACM Trans. Program. Lang. Syst., 18(3), May 1996. doi:10.1145/229542.229546. Google Scholar
Digital Library
- 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 Scholar
Digital Library
- doi:10.1145/2535838.2535841.Google Scholar
- 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 Scholar
Digital Library
- doi:10.1145/1863543.1863584.Google Scholar
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- doi:10.1145/2784731.2784764.Google Scholar
- 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 Scholar
- 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 Scholar
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- doi:10.1145/1993498.1993532.Google Scholar
- 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 Scholar
Digital Library
Index Terms
A new verified compiler backend for CakeML
Recommendations
A new verified compiler backend for CakeML
ICFP 2016: Proceedings of the 21st ACM SIGPLAN International Conference on Functional ProgrammingWe 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 ...
Verifying efficient function calls in CakeML
We have designed an intermediate language (IL) for the CakeML compiler that supports the verified, efficient compilation of functions and calls. Verified compilation steps include batching of multiple curried arguments, detecting calls to statically ...
A verified type system for CakeML
IFL '15: Proceedings of the 27th Symposium on the Implementation and Application of Functional Programming LanguagesCakeML is a dialect of the (strongly typed) ML family of programming languages, designed to play a central role in high-assurance software systems. To date, the main artefact supporting this is a verified compiler from CakeML source code to x86-64 ...







Comments