Register Allocation via Coloring of Chordal Graphs

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.

[1]  Vivek Sarkar,et al.  Linear scan register allocation , 1999, TOPL.

[2]  Andrew W. Appel,et al.  Optimal spilling for CISC machines with few registers , 2001, PLDI '01.

[3]  G. Dirac On rigid circuit graphs , 1961 .

[4]  Jens Palsberg,et al.  Register Allocation After Classical SSA Elimination is NP-Complete , 2006, FoSSaCS.

[5]  Gregory J. Chaitin,et al.  Register allocation and spilling via graph coloring , 2004, SIGP.

[6]  D. West Introduction to Graph Theory , 1995 .

[7]  Robert E. Tarjan,et al.  Simple Linear-Time Algorithms to Test Chordality of Graphs, Test Acyclicity of Hypergraphs, and Selectively Reduce Acyclic Hypergraphs , 1984, SIAM J. Comput..

[8]  Ken Kennedy,et al.  Fast copy coalescing and live-range identification , 2002, PLDI '02.

[9]  Sebastian Hack,et al.  Interference Graphs of Programs in SSA-form , 2005 .

[10]  Keith D. Cooper,et al.  Improvements to graph coloring register allocation , 1994, TOPL.

[11]  Fanica Gavril,et al.  Algorithms for Minimum Coloring, Maximum Clique, Minimum Covering by Cliques, and Maximum Independent Set of a Chordal Graph , 1972, SIAM J. Comput..

[12]  Barry W. Peyton,et al.  Maximum Cardinality Search for Computing Minimal Triangulations of Graphs , 2004, Algorithmica.

[13]  Martin Grötschel,et al.  The ellipsoid method and its consequences in combinatorial optimization , 1981, Comb..

[14]  Christian Andersson Register Allocation by Optimal Graph Coloring , 2003, CC.

[15]  Paul D. Seymour,et al.  Recognizing Berge Graphs , 2005, Comb..

[16]  John Whaley,et al.  Joeq: a virtual machine and compiler infrastructure , 2003, IVME '03.

[17]  Mihalis Yannakakis,et al.  The Maximum k-Colorable Subgraph Problem for Chordal Graphs , 1987, Inf. Process. Lett..

[18]  Andrew W. Appel,et al.  Iterated register coalescing , 1996, POPL '96.