EN FR
EN FR




Bibliography




Bibliography


Section: New Results

A Polynomial Spilling Heuristic: Layered Allocation

Participants : Albert Cohen [Inria, Parkas] , Boubacar Diouf [Université Paris Sud, Parkas] , Fabrice Rastello.

Register allocation is subdivided into two sub-problems: first, the allocation (or its dual problem the spilling) selects the set of variables that will reside in registers (resp. in memory) at each point of the program. Then, the assignment or coloring picks a specific register where a variable will reside. Building on some properties of the static single assignment form (SSA), it is now possible to decouple the allocation from the assignment. Indeed, the interference graph of a program in SSA form is a chordal graph. In this context, MaxLive , the maximal number of variables simultaneously live at a program point, is used during the spilling phase as a criterion to guarantee that the forthcoming assignment will be performed without any spill. If MaxLive is lower than or equal to R, the number of available registers, then all the variables will be assigned without any spill. This decoupled approach was advocated by Fabri, Appel and George, Darte et al., and others.

Existing spilling heuristics rely on a sufficient condition to guarantee register assignment, and incrementally spill until the condition holds. As we just mentioned, for programs under SSA, the condition is necessary and sufficient: MaxLive has to be lower than or equal to R. Incremental spilling decisions to satisfy this condition tend to be overly local and suboptimal. Indeed, incremental spilling itself is NP-complete, and heuristics based upon it trade too much their optimality for polynomiality. In contrast to incremental spilling, we proposed to adopt the symmetric approach: incremental allocation. Intuition for it emerges from two observations allowing for more global spilling decisions:

  1. Register allocation is pseudo-polynomial in the number of registers, suggesting a heuristic that solves (optimally) roughly R/𝑠𝑡𝑒𝑝 allocation problems on 𝑠𝑡𝑒𝑝 registers each. The final allocation is the layered composition of the stepwise allocations.

  2. Stepwise optimality does not guarantee an overall optimal allocation, but experiments show that it comes very close to optimal, even with 𝑠𝑡𝑒𝑝=1. Intuition for this comes from recent work by Diouf et al., observing that allocation decisions tend to be a monotonic function of the number of registers.

This work, which will be presented at CGO'13 [11] , proposes a new graph-based allocation heuristic, based on a maximum clique cover formulation to define the profitability of spilling variables. It exploits the pseudo-polynomial complexity in the number of registers of the allocation problem under SSA — as opposed to the symmetric, spilling problem, which remains strongly NP-complete. It addresses the spill-everywhere problem in a decoupled context and also proposes an extension to non-decoupled approaches. It introduces layered allocation a new strategy that incrementally allocates variables instead of incrementally spilling variables. The evaluation performed on standard benchmarks shows that this new approach is near-optimal.