Register Allocation Via Coloring of Chordal Graphs

  • Fernando Magno Quintão Pereira
  • Jens Palsberg
Part of the Lecture Notes in Computer Science book series (LNCS, volume 3780)


We present a simple algorithm for register allocation which is competitive with the iterated register coalescing algorithm of George and Appel. We base our algorithm on the observation that 95% of the methods in the Java 1.5 library have chordal interference graphs when compiled with the JoeQ compiler. A greedy algorithm can optimally color a chordal graph in time linear in the number of edges, and we can easily add powerful heuristics for spilling and coalescing. Our experiments show that the new algorithm produces better results than iterated register coalescing for settings with few registers and comparable results for settings with many registers.


Iterate Register Graph Coloring Chordal Graph Register Allocation Large Clique 
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.


Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.


  1. 1.
    Andersson, C.: Register allocation by optimal graph coloring. In: 12th Conference on Compiler Construction, pp. 34–45. Springer, Heidelberg (2003)Google Scholar
  2. 2.
    Appel, A.W., George, L.: Optimal spilling for cisc machines with few registers. In: International Conference on Programming Languages Design and Implementation, pp. 243–253. ACM Press, New York (2001)Google Scholar
  3. 3.
    Appel, A.W., George, L.: 27,921 actual register-interference graphs generated by standard ML of New Jersey, version 1.09 (2005),
  4. 4.
    Berry, A., Blair, J., Heggernes, P., Peyton, B.: Maximum cardinality search for computing minimal triangulations of graphs. Algorithmica 39(4), 287–298 (2004)zbMATHCrossRefMathSciNetGoogle Scholar
  5. 5.
    Briggs, P., Cooper, K.D., Torczon, L.: Improvements to graph coloring register allocation. Transactions on Programming Languages and Systems (TOPLAS) 16(3), 428–455 (1994)CrossRefGoogle Scholar
  6. 6.
    Brisk, P., Dabiri, F., Macbeth, J., Sarrafzadeh, M.: Polynomial-time graph coloring register allocation. In: 14th International Workshop on Logic and Synthesis. ACM Press, New York (2005)Google Scholar
  7. 7.
    Budimlic, Z., Cooper, K.D., Harvey, T.J., Kennedy, K., Oberg, T.S., Reeves, S.W.: Fast copy coalescing and live-range identification. In: International Conference on Programming Languages Design and Implementation, pp. 25–32. ACM Press, New York (2002)Google Scholar
  8. 8.
    Chaitin, G.J.: Register allocation and spilling via graph coloring. In: Symposium on Compiler Construction, vol. 17(6), pp. 98–105 (1982)Google Scholar
  9. 9.
    Chudnovsky, M., Cornuejols, G., Liu, X., Seymour, P., Vuskovic, K.: Recognizing berge graphs. Combinatorica 25, 143–186 (2005)zbMATHCrossRefMathSciNetGoogle Scholar
  10. 10.
    Dirac, G.A.: On rigid circuit graphs. In: Abhandlungen aus dem Mathematischen Seminar der Universiat Hamburg, vol. 25, pp. 71–75. University of Hamburg (1961)Google Scholar
  11. 11.
    Gavril, F.: Algorithms for minimum coloring, maximum clique, minimum covering by cliques, and maximum independent set of a chordal graph. SICOMP 1(2), 180–187 (1972)zbMATHMathSciNetGoogle Scholar
  12. 12.
    George, L., Appel, A.W.: Iterated register coalescing. Transactions on Programming Languages and Systems (TOPLAS) 18(3), 300–324 (1996)CrossRefGoogle Scholar
  13. 13.
    Grotschel, M., Lovasz, L., Schrijver, A.: The ellipsoid method and its consequences in combinatorial optimization. Combinatorica 1(2), 169–197 (1981)CrossRefMathSciNetGoogle Scholar
  14. 14.
    Hack, S.: Interference graphs of programs in SSA-form. Technical report, Universitat Karlsruhe (2005)Google Scholar
  15. 15.
    Pereira, F.M.Q., Palsberg, J.: Register allocation after SSA elimination is NP-complete (2005) (Manuscript)Google Scholar
  16. 16.
    Poletto, M., Sarkar, V.: Linear scan register allocation. ACM Transactions on Programming Languages and Systems 21(5), 895–913 (1999)CrossRefGoogle Scholar
  17. 17.
    Tarjan, R.E., Yannakakis, M.: Simple linear-time algorithms to test chordality of graphs, test acyclicity of hypergraphs, and selectively reduce acyclic hypergraphs. SIAM J. Comput. 13(3), 566–579 (1984)zbMATHCrossRefMathSciNetGoogle Scholar
  18. 18.
    West, D.B.: Introduction to Graph Theory, 2nd edn. Prentice-Hall, Englewood Cliffs (2001)Google Scholar
  19. 19.
    Whaley, J.: Joeq: a virtual machine and compiler infrastructure. In: Workshop on Interpreters, virtual machines and emulators, pp. 58–66. ACM Press, New York (2003)CrossRefGoogle Scholar
  20. 20.
    Yannakakis, M., Gavril, F.: The maximum k-colorable subgraph problem for chordal graphs. Information Processing Letters 24(2), 133–137 (1987)zbMATHCrossRefMathSciNetGoogle Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2005

Authors and Affiliations

  • Fernando Magno Quintão Pereira
    • 1
  • Jens Palsberg
    • 1
  1. 1.UCLA Computer Science DepartmentUniversity of CaliforniaLos Angeles

Personalised recommendations