Register Spilling and Live-Range Splitting for SSA-Form Programs

  • Matthias Braun
  • Sebastian Hack
Part of the Lecture Notes in Computer Science book series (LNCS, volume 5501)


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.


Register Pressure Basic Block Register Allocation Live Variable Liveness Analysis 
These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.


  1. 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
  2. 2.
    Briggs, P., Cooper, K.D., Torczon, L.: Improvements to graph coloring register allocation. ACM Trans. Program. Lang. Syst. 16(3), 428–455 (1994)CrossRefGoogle Scholar
  3. 3.
    Traub, O., Holloway, G., Smith, M.D.: Quality and speed in linear-scan register allocation. In: PLDI 1998: Proceedings of the Conference on Programming Language Design and Implementation, pp. 142–151. ACM Press, New York (1998)CrossRefGoogle Scholar
  4. 4.
    Poletto, M., Sarkar, V.: Linear scan register allocation. ACM Trans. Program. Lang. Syst. 21(5), 895–913 (1999)CrossRefGoogle Scholar
  5. 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. 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
  7. 7.
    Brisk, P., Dabiri, F., Jafari, R., Sarrafzadeh, M.: Optimal Register Sharing for High-Level Synthesis of SSA Form Programs. IEEE Trans. on CAD of Integrated Circuits and Systems 25(5), 772–779 (2006)CrossRefGoogle Scholar
  8. 8.
    Hack, S., Grund, D., Goos, G.: Register allocation for programs in SSA-form. In: Mycroft, A., Zeller, A. (eds.) CC 2006. LNCS, vol. 3923, pp. 247–262. Springer, Heidelberg (2006)CrossRefGoogle Scholar
  9. 9.
    Belady, L.A.: A study of replacement algorithms for a virtual-storage computer. IBM Systems Journal 5(2), 78–101 (1966)CrossRefGoogle Scholar
  10. 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
  11. 11.
    Roy, B.V.: A short proof of optimality for the min cache replacement algorithm. Inf. Process. Lett. 102(2-3), 72–73 (2007)MathSciNetCrossRefzbMATHGoogle Scholar
  12. 12.
    Nielson, F., Nielson, H.R., Hankin, C.: Principles of Program Analysis. Springer, Heidelberg (1999)CrossRefzbMATHGoogle Scholar
  13. 13.
    Hack, S.: Register Allocation for Programs in SSA Form. PhD thesis, Universität Karlsruhe (TH) (October 2007)Google Scholar
  14. 14.
    Sreedhar, V.C., Ju, R.D.C., Gillies, D.M., Santhanam, V.: Translating out of static single assignment form. In: Cortesi, A., Filé, G. (eds.) SAS 1999. LNCS, vol. 1694, pp. 194–210. Springer, Heidelberg (1999)CrossRefGoogle Scholar
  15. 15.
    Sastry, A.V.S., Ju, R.D.C.: A new algorithm for scalar register promotion based on SSA form. In: PLDI 1998: Proceedings of the conference on Programming language design and implementation, pp. 15–25. ACM, New York (1998)CrossRefGoogle Scholar
  16. 16.
    Cytron, R., Ferrante, J., Rosen, B.K., Wegman, M.N., Zadek, F.K.: Efficiently computing static single assignment form and the control dependence graph. Transactions on Programming Languages and Systems 13(4), 451–490 (1991)CrossRefGoogle Scholar
  17. 17.
    Firm: The libFirm Compiler,
  18. 18.
    Standard Performance Evaluation Corporation: SPEC CPU2000 V1.3,
  19. 19.
    LLVM: The LLVM Compiler Infrastructure,
  20. 20.
    Valgrind: Valgrind Instrumentation Framework for Building Dynamic Analysis Tools,
  21. 21.
    Proebsting, T.A., Fischer, C.N.: Probabilistic register allocation. SIGPLAN Not. 27(7), 300–310 (1992)CrossRefGoogle Scholar
  22. 22.
    Morgan, R.: Building an Optimizing Compiler. Digital Press (1998)Google Scholar
  23. 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
  24. 24.
    Sarkar, V., Barik, R.: Extended linear scan: An alternate foundation for global register allocation. In: Krishnamurthi, S., Odersky, M. (eds.) CC 2007. LNCS, vol. 4420, pp. 141–155. Springer, Heidelberg (2007)CrossRefGoogle Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2009

Authors and Affiliations

  • Matthias Braun
    • 1
  • Sebastian Hack
    • 2
  1. 1.Institut für Programmstrukturen und DatenorganisationUniversität Karlsruhe (TH)Germany
  2. 2.Computer Science DepartmentSaarland UniversityGermany

Personalised recommendations