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
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
Register allocation is pseudo-polynomial in the number of registers, suggesting a heuristic that solves (optimally) roughly
allocation problems on registers each. The final allocation is the layered composition of the stepwise allocations.Stepwise optimality does not guarantee an overall optimal allocation, but experiments show that it comes very close to optimal, even with
. 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.