Register Allocation - Tichadou, Florent Bouchez; Rastello, Fabrice (SSA-based Compiler Design, 2022)
Register allocation maps the variables of a program to physical memory locations: usually either CPU registers or the main memory. As there is only a small number of registers available in a CPU, the task of register allocation is also to decide which variables should be evicted from registers and at which program points to store and load them from memory (spilling). Furthermore, register allocation has to remove spurious copy instructions (copy coalescing) inserted by previous phases in the compilation process and to deal with allocation restrictions that the instruction set architecture and the runtime system impose (register targeting). Classical register allocation algorithms address these different issues with either complex and sometimes expensive schemes (usually graph-based), or simpler and faster (but less efficient) algorithms such as linear scan. The goal of this chapter is to illustrate how SSA form can help in designing both simpler and faster schemes with similar or even better quality than the most complex existing ones.