Register Spilling and Live-Range Splitting for SSA-Form Programs
Register allocation decides which parts of a variable’s live range are held in registers and which in memory. The compiler inserts spill code to move the values of variables between registers and memory. Since fetching data from memory is much slower than reading directly from a register, careful spill code insertion is critical for the performance of the compiled program.
In this paper, we present a spilling algorithm for programs in SSA form. Our algorithm generalizes the well-known furthest-first algorithm, which is known to work well on straight-line code, to control-flow graphs.
We evaluate our technique by counting the executed spilling instructions in the CINT2000 benchmark on an x86 machine. The number of executed load (store) instructions was reduced by 54.5% (61.5%) compared to a state-of-the-art linear scan allocator and reduced by 58.2% (41.9%) compared to a standard graph-coloring allocator. The runtime of our algorithm is competitive with standard linear-scan allocators.
- 1.Chaitin, G.J., Auslander, M.A., Chandra, A.K., Cocke, J., Hopkins, M.E., Markstein, P.W.: Register allocation via graph coloring. Journal of Computer Languages 6, 45–57 (1981)Google Scholar
- 5.Wimmer, C., Mössenböck, H.: Optimized interval splitting in a linear scan register allocator. In: VEE 2005: Proceedings of the 1st international conference on Virtual execution environments, pp. 132–141. ACM, New York (2005)Google Scholar
- 6.Bouchez, F., Darte, A., Guillon, C., Rastello, F.: Register allocation: What does the NP-completeness proof of chaitin et al. Really prove? Or revisiting register allocation: Why and how. In: Almási, G.S., Caşcaval, C., Wu, P. (eds.) KSEM 2006. LNCS, vol. 4382, pp. 283–298. Springer, Heidelberg (2007)CrossRefGoogle Scholar
- 10.Guo, J., Garzarn, M.J., Padua, D.: The power of beladys algorithm in register allocation for long basic blocks. In: The 16th International Workshop on Languages and Compilers for Parallel Computing (2003)Google Scholar
- 13.Hack, S.: Register Allocation for Programs in SSA Form. PhD thesis, Universität Karlsruhe (TH) (October 2007)Google Scholar
- 17.Firm: The libFirm Compiler, http://www.libfirm.org
- 18.Standard Performance Evaluation Corporation: SPEC CPU2000 V1.3, http://www.spec.org/cpu2000/
- 19.LLVM: The LLVM Compiler Infrastructure, http://www.llvm.org
- 20.Valgrind: Valgrind Instrumentation Framework for Building Dynamic Analysis Tools, http://www.valgrind.org
- 22.Morgan, R.: Building an Optimizing Compiler. Digital Press (1998)Google Scholar
- 23.Farach, M., Liberatore, V.: On local register allocation. In: SODA 1998: Proceedings of the ninth annual symposium on Discrete algorithms, Philadelphia, PA, USA, Society for Industrial and Applied Mathematics, pp. 564–573 (1998)Google Scholar