Formal Verification of Coalescing Graph-Coloring Register Allocation

  • Sandrine Blazy
  • Benoît Robillard
  • Andrew W. Appel
Part of the Lecture Notes in Computer Science book series (LNCS, volume 6012)


Iterated Register Coalescing (IRC) is a widely used heuristic for performing register allocation via graph coloring. Many implementations in existing compilers follow (more or less faithfully) the imperative algorithm published in 1996. Several mistakes have been found in some of these implementations.

In this paper, we present a formal verification (in Coq) of the whole IRC algorithm. We detail a specification that can be used as a reference for IRC. We also define the theory of register-interference graphs; we implement a purely functional version of the IRC algorithm, and we prove the total correctness of our implementation. The automatic extraction of our IRC algorithm into Caml yields a program with competitive performance. This work has been integrated into the CompCert verified compiler.


Graph Coloring Recursive Call Chordal Graph Proof Obligation Proof Assistant 
These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.


  1. 1.
    Abrial, J.-R., Cansell, D., Méry, D.: Formal derivation of spanning trees algorithms. In: Bert, D., Bowen, J.P., King, S. (eds.) ZB 2003. LNCS, vol. 2651, pp. 457–476. Springer, Heidelberg (2003)CrossRefGoogle Scholar
  2. 2.
    Appel, A.W.: Modern Compiler Implementation in ML. Cambridge University Press, Cambridge (1998)Google Scholar
  3. 3.
    Appel, A.W., George, L.: Optimal spilling for CISC machines with few registers. In: PLDI. ACM, New York (2001)Google Scholar
  4. 4.
    Appel, K., Haken, W.: Every planar map is four colorable. Bulletin of the American Mathematical Society 82, 711–712 (1976)zbMATHCrossRefMathSciNetGoogle Scholar
  5. 5.
    Bauer, G., Nipkow, T.: The 5 colour theorem in Isabelle/Isar. In: Carreño, V.A., Muñoz, C.A., Tahar, S. (eds.) TPHOLs 2002. LNCS, vol. 2410, pp. 67–82. Springer, Heidelberg (2002)CrossRefGoogle Scholar
  6. 6.
    Bertot, Y., Castéran, P.: Interactive Theorem Proving and Program Development. Coq’Art: The Calculus of Inductive Constructions. Texts in Theoretical Computer Science. Springer, Heidelberg (2004)zbMATHGoogle Scholar
  7. 7.
    Blazy, S., Dargaye, Z., Leroy, X.: Formal verification of a C compiler front-end. In: Misra, J., Nipkow, T., Sekerinski, E. (eds.) FM 2006. LNCS, vol. 4085, pp. 460–475. Springer, Heidelberg (2006)CrossRefGoogle Scholar
  8. 8.
    Briggs, P., Cooper, K.D., Torczon, L.: Improvements to graph coloring register allocation. TOPLAS 16(3), 428–455 (1994)CrossRefGoogle Scholar
  9. 9.
    Chaitin, G.J., Auslander, M.A., Chandra, A.K., Cocke, J., Hopkins, M.E., Markstein, P.W.: Register allocation via coloring. Computer Languages 6, 47–57 (1981)CrossRefGoogle Scholar
  10. 10.
    Chen, J.-C.: Dijkstra’s shortest path algorithm. Journal of Formalized Mathematics 15 (2003)Google Scholar
  11. 11.
    Chou, C.-T.: A formal theory of undirected graphs in higher-order logic. In: Melham, T.F., Camilleri, J. (eds.) HUG 1994. LNCS, vol. 859, pp. 144–157. Springer, Heidelberg (1994)Google Scholar
  12. 12.
    Coq. The coq proof assistant,
  13. 13.
    George, L., Appel, A.W.: Iterated register coalescing. TOPLAS 18(3), 300–324 (1996)CrossRefGoogle Scholar
  14. 14.
    Gonthier, G.: Formal proof – the four-color theorem. Notices of the American Mathematical Society 55(11), 1382–1393 (2008)zbMATHMathSciNetGoogle Scholar
  15. 15.
    Hack, S., Goos, G.: Copy coalescing by graph recoloring. In: PLDI. ACM, New York (2008)Google Scholar
  16. 16.
    Kempe, A.B.: On the geographical problem of the four colors. American Journal of Mathematics 2, 193–200 (1879)CrossRefMathSciNetGoogle Scholar
  17. 17.
    Leroy, X.: Formal certification of a compiler back-end or: Programming a compiler with a proof assistant. In: POPL, pp. 42–54. ACM, New York (2006)Google Scholar
  18. 18.
    Moore, J.S., Zhang, Q.: Proof pearl: Dijkstra’s shortest path algorithm verified with ACL2. In: Hurd, J., Melham, T. (eds.) TPHOLs 2005. LNCS, vol. 3603, pp. 373–384. Springer, Heidelberg (2005)Google Scholar
  19. 19.
    Necula, G.C.: Translation validation for an optimizing compiler. SIGPLAN Not. 35(5), 83–94 (2000)CrossRefGoogle Scholar
  20. 20.
    Pnueli, A., Siegel, M., Singerman, E.: Translation validation. In: Steffen, B. (ed.) TACAS 1998. LNCS, vol. 1384, pp. 151–166. Springer, Heidelberg (1998)CrossRefGoogle Scholar
  21. 21.
    Yamamoto, M., Nishizaki, S.-y., Hagiya, M., Toda, Y.: Formalization of planar graphs. In: Workshop on Higher Order Logic Theorem Proving and Its Applications, pp. 369–384 (1995)Google Scholar
  22. 22.
    Yamamoto, M., Takahashi, K., Hagiya, M., Nishizaki, S.-y., Tamai, T.: Formalization of graph search algorithms and its applications. In: Grundy, J., Newey, M. (eds.) TPHOLs 1998. LNCS, vol. 1479, pp. 479–496. Springer, Heidelberg (1998)CrossRefGoogle Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2010

Authors and Affiliations

  • Sandrine Blazy
    • 1
  • Benoît Robillard
    • 2
  • Andrew W. Appel
    • 3
  1. 1.IRISA - Université Rennes 1 
  3. 3.Princeton University 

Personalised recommendations