Étude des problèmes de spilling et coalescing liés à l'allocation de registres en tant que deux phases distinctes

Florent Bouchez 1, 2
2 COMPSYS - Compilation and embedded computing systems
Inria Grenoble - Rhône-Alpes, LIP - Laboratoire de l'Informatique du Parallélisme
Abstract : The goal of register allocation is to assign the variables of a program to the registers or to spill them to memory whenever there are no register left. Since memory is much slower than registers, it is best to minimize the spilling. However, the problem is complicated because spilling is tightly bounded with the colorability of the program. Chaitin et al. [1981] modeled register allocation as an interference graph coloring problem, which they proved NP-complete. So, there is no exact way in this model to tell whether some spilling is necessary or not, and if it is, what to spill and where. In Chaitin et al.'s algorithm, a spilled variable is removed everywhere in the program, even at places where there is enough registers, which leads to unnecessary memory transfers. To address this problem, many authors remarked that splitting the live ranges of variables by inserting copy instructions creates smaller live-ranges. Hence, only part of live ranges can be spilled instead spilling "everywhere." The difficulty is then to choose the right places to split the live ranges. In practice, authors get better spill results when splitting at many program points [Briggs, 1992; Appel and George, 2001], but splitting introduces register-to-register moves to reconcile variables with sub-variables in case they are colored differently. Coalescing is expected remove most of these move instructions, but if it does not, the benefit of a better spill can be canceled out. This led Appel and George [2001] to introduce the "Coalescing Challenge." Recently (2004), three teams discover that the interference graph of a program under Static Single Assignment (SSA) is chordal. Hence, coloring the graph becomes easy with a simplicial elimination scheme and there has been hopes that SSA would simplify register allocation. Ours were that, as the coloring was, the spilling and the coalescing might get easier to solve, as we now have a exact coloring test. Our first goal was to better understand from where the complexity of register allocation does come, and why SSA seems to simplify the problem. We came back to the original proof of Chaitin et al. [1981], finding that the difficulty comes from the pres- ence of (critical) edges and the possibility to perform permutations of colors or not. We studied the spill problem under SSA and several versions of the coalescing problem. The general cases were proven NP-complete but we hopefully found one polynomial result: incremental coalescing for programs under SSA. We used it to design new heuristics to better solve the coalescing problem, so that an aggressive splitting can be used beforehand. This led us to promote a better register allocation scheme. While previous tentatives gave mitigated results, our better coalescing allowed us to cleanly separate register allocation into two independent phases: First, spilling to reduce the register pressure to the number of registers, possibly by splitting a lot; Then color the variables and perform coalescing to remove most of the added copies. This scheme is expected to perform well in an aggressive compiler. However, the high number of splits and the increased compilation time required to perform the coalescing is prohibitive for just-in-time (JIT) compilation. So, we devised a heuristic, called "permutation motion," that is intended to be used with SSA-based splitting in place of our more aggressive coalescing in a JIT context.
Document type :
Other [cs.OH]. Ecole normale supérieure de lyon - ENS LYON, 2009. French

Contributor : Florent Bouchez <>
Submitted on : Tuesday, September 8, 2009 - 8:38:19 AM
Last modification on : Monday, October 5, 2015 - 5:00:05 PM


  • HAL Id : tel-00403504, version 2



Florent Bouchez. Étude des problèmes de spilling et coalescing liés à l'allocation de registres en tant que deux phases distinctes. Other [cs.OH]. Ecole normale supérieure de lyon - ENS LYON, 2009. French. <tel-00403504v2>




Consultation de
la notice


Téléchargement du document