Mechanizing conventional SSA for a verified destruction with coalescing

Modern optimizing compilers rely on the Static Single Assignment (SSA) form to make optimizations fast and simpler to implement. From a semantic perspective, the SSA form is nowadays fairly well understood, as witnessed by recent advances in the field of formally verified compilers. The destruction of the SSA form, however, remains a difficult problem, even in a non-verified environment. In fact, the out-of-SSA transformation has been revisited, for correctness and performance issues, up until recently. Unsurprisingly, state-of-the-art compiler formalizations thus either completely ignore, only partially handle, or implement naively the SSA destruction. This paper reports on the implementation of such a destruction within a verified compiler. We formally define and prove the properties of the generation of Conventional SSA (CSSA) which make its destruction simple to implement and prove. Second, we implement and prove correct a coalescing destruction of CSSA, a la Boissinot et al., where variables can be coalesced according to a refined notion of interference. This formalization work extends the CompCertSSA compiler, whose correctness proof is mechanized in the Coq proof assistant. Our CSSA-based, coalescing destruction removes, on average, more than 99% of introduced copies, and leads to encouraging results concerning spilling during post-SSA register allocation.

[1]  Keith D. Cooper,et al.  Value Numbering , 1997, Softw. Pract. Exp..

[2]  David Pichardie,et al.  Validating Dominator Trees for a Fast, Verified Dominance Test , 2015, ITP.

[3]  David Pichardie,et al.  Verifying Fast and Sparse SSA-Based Optimizations in Coq , 2015, CC.

[4]  Sebastian Buchwald,et al.  Simple and Efficient Construction of Static Single Assignment Form , 2013, CC.

[5]  Sabine Glesner,et al.  Optimizing Code Generation from SSA Form: A Comparison Between Two Formal Correctness Proofs in Isabelle/HOL , 2005, COCV@ETAPS.

[6]  John Cocke,et al.  A methodology for the real world , 1981 .

[7]  Xavier Leroy,et al.  Tilting at Windmills with Coq: Formal Verification of a Compilation Algorithm for Parallel Moves , 2007, Journal of Automated Reasoning.

[8]  Sebastian Buchwald,et al.  Verified construction of static single assignment form , 2016, CC.

[9]  Roy Dz-Ching Ju,et al.  Translating Out of Static Single Assignment Form , 1999, SAS.

[10]  Santosh Nagarakatte,et al.  Formal verification of SSA-based optimizations for LLVM , 2013, PLDI.

[11]  Milo M. K. Martin,et al.  Formalizing the LLVM intermediate representation for verified program transformations , 2012, POPL '12.

[12]  Gilles Barthe,et al.  Formal Verification of an SSA-Based Middle-End for CompCert , 2014, TOPL.

[13]  Benoît Dupont de Dinechin Using the SSA-Form in a Code Generator , 2014, CC.

[14]  Sebastian Hack,et al.  Register allocation for programs in SSA form , 2006, CC.

[15]  Mark N. Wegman,et al.  Efficiently computing static single assignment form and the control dependence graph , 1991, TOPL.

[16]  Benoît Dupont de Dinechin,et al.  Revisiting Out-of-SSA Translation for Correctness, Code Quality and Efficiency , 2009, 2009 International Symposium on Code Generation and Optimization.

[17]  Xavier Leroy,et al.  A Formally Verified Compiler Back-end , 2009, Journal of Automated Reasoning.

[18]  Benoît Dupont de Dinechin,et al.  Fast liveness checking for ssa-form programs , 2008, CGO '08.

[19]  John Cocke,et al.  Register Allocation Via Coloring , 1981, Comput. Lang..

[20]  Keith D. Cooper,et al.  Practical improvements to the construction and destruction of static single assignment form , 1998, Softw. Pract. Exp..