Skip to main content

Hybrid Register Allocation with Spill Cost and Pattern Guided Optimization

  • Conference paper
  • First Online:
Languages and Compilers for Parallel Computing (LCPC 2021)

Part of the book series: Lecture Notes in Computer Science ((LNCS,volume 13181))

Abstract

Modern compilers have relied on various best-effort heuristics to solve the register allocation problem due to its high computation complexity. A “greedy” algorithm that performs a scan of prioritized live intervals for allocation followed by interval splits and spills is one of the widely used register allocation mechanisms with consistent performance and low compile-time overheads. However, its live interval splitting heuristics suffer from making sub-optimal decisions for scenarios hard to predict, and recent effort to remedy the issue is not free from unintended side effects with performance degradation. In this paper, we propose Greedy-SO, a greedy register allocator with a spill cost and pattern guided optimization that systematically addresses inherent suboptimalities in live-interval splitting. Greedy-SO does this by avoiding splitting codes whose performance are more likely to be impacted by sub-optimal decisions. Greedy-SO identifies functions with such code patterns, precisely models the spill cost for them during the greedy allocation process, then when the spill cost starts to deteriorate, switches to an alternative allocator that does not use interval splitting. Our hybrid register allocator improves the performance of target benchmarks up to 16.1% (7.3% on average) with a low compilation overhead, while not impacting non-target benchmarks at all.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 44.99
Price excludes VAT (USA)
  • Available as EPUB and PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 59.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

References

  1. Cloning MachineFunctions. https://groups.google.com/g/llvm-dev/c/DOP6RSV8lQ4/m/C3Lfe6gJEwAJ

  2. Intel(R) 64 and IA-32 architectures optimization reference manual. https://www.intel.com/content/dam/www/public/us/en/documents/manuals/64-ia-32-architectures-optimization-manual.pdf

  3. LLVM testing infrastructure. https://github.com/llvm/llvm-test-suite

  4. Parallel bicubic interpolation. https://github.com/srijanmishra/parallel-bicubic-interpolation

  5. Suggestions on register allocation by using reinforcement learning. https://groups.google.com/g/llvm-dev/c/V9ykDwqGeNw/m/-3SfJsuRAQAJ

  6. Aho, A.V., Sethi, R., Ullman, J.D.: Compilers, Principles, Techniques, and Tools. Addison-Wesley, New York (1986)

    MATH  Google Scholar 

  7. Brawn, J.: Strange regalloc behaviour: one more available register causes much worse allocation, December 2018. https://lists.llvm.org/pipermail/llvm-dev/2018-December/128299.html

  8. Briggs, P., Cooper, K.D., Torczon, L.: Improvements to graph coloring register allocation. ACM Trans. Program. Lang. Syst. (TOPLAS) 16(3), 428–455 (1994)

    Article  Google Scholar 

  9. Callahan, D., Koblenz, B.: Register allocation via hierarchical graph coloring. ACM Sigplan Not. 26(6), 192–203 (1991)

    Article  Google Scholar 

  10. Cavazos, J., Moss, J.E.B., O’Boyle, M.F.P.: Hybrid optimizations: which optimization algorithm to use? In: Mycroft, A., Zeller, A. (eds.) CC 2006. LNCS, vol. 3923, pp. 124–138. Springer, Heidelberg (2006). https://doi.org/10.1007/11688839_12

    Chapter  Google Scholar 

  11. Chaitin, G.J., Auslander, M.A., Chandra, A.K., Cocke, J., Hopkins, M.E., Markstein, P.W.: Register allocation via coloring. Comput. Lang. 6(1), 47–57 (1981)

    Article  Google Scholar 

  12. Chow, F.C., Hennessy, J.L.: The priority-based coloring approach to register allocation. ACM Trans. Program. Lang. Syst. 12(4), 501–536 (1990). https://doi.org/10.1145/88616.88621

    Article  Google Scholar 

  13. Cohen, W.W.: Fast effective rule induction. In: Prieditis, A., Russell, S. (eds.) Machine Learning Proceedings 1995, pp. 115–123. Morgan Kaufmann, San Francisco (CA) (1995). https://doi.org/10.1016/B978-1-55860-377-6.50023-2, https://www.sciencedirect.com/science/article/pii/B9781558603776500232

  14. Cooper, K.D., Torczon, L.: Engineering a Compiler, 2nd edn. Morgan Kaufmann, Boston (2012). https://doi.org/10.1016/B978-0-12-088478-0.00001-3, https://www.sciencedirect.com/science/article/pii/B9780120884780000013

  15. Diouf, B., Cohen, A., Rastello, F., Cavazos, J.: Split register allocation: linear complexity without the performance penalty. In: Patt, Y.N., Foglia, P., Duesterwald, E., Faraboschi, P., Martorell, X. (eds.) HiPEAC 2010. LNCS, vol. 5952, pp. 66–80. Springer, Heidelberg (2010). https://doi.org/10.1007/978-3-642-11515-8_7

    Chapter  Google Scholar 

  16. Eisl, J., Marr, S., Würthinger, T., Mössenböck, H.: Trace register allocation policies: compile-time vs. performance trade-offs. In: Proceedings of the 14th International Conference on Managed Languages and Runtimes, pp. 92–104 (2017)

    Google Scholar 

  17. Evlogimenos, A.: Improvements to linear scan register allocation (2004). https://llvm.org/ProjectsWithLLVM/2004-Fall-CS426-LS.pdf

  18. Hames, L., Scholz, B.: Nearly optimal register allocation with PBQP. In: Lightfoot, D.E., Szyperski, C. (eds.) JMLC 2006. LNCS, vol. 4228, pp. 346–361. Springer, Heidelberg (2006). https://doi.org/10.1007/11860990_21

    Chapter  Google Scholar 

  19. Lattner, C., Adve, V.: LLVM: a compilation framework for lifelong program analysis & transformation. In: International Symposium on Code Generation and Optimization, 2004. CGO 2004, pp. 75–86. IEEE (2004)

    Google Scholar 

  20. Mössenböck, H., Pfeiffer, M.: Linear scan register allocation in the context of SSA form and register constraints. In: Horspool, R.N. (ed.) CC 2002. LNCS, vol. 2304, pp. 229–246. Springer, Heidelberg (2002). https://doi.org/10.1007/3-540-45937-5_17

    Chapter  Google Scholar 

  21. Olesen, J.S.: Greedy register allocation, September 2011. http://blog.llvm.org/2011/09/greedy-register-allocation-in-llvm-30.html

  22. Poletto, M., Sarkar, V.: Linear scan register allocation. ACM Trans. Prog. Lang. Syst. (TOPLAS) 21(5), 895–913 (1999)

    Article  Google Scholar 

  23. Rosen, B.K., Wegman, M.N., Zadeck, F.K.: Global value numbers and redundant computations. In: Proceedings of the 15th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, pp. 12–27, POPL 1988. Association for Computing Machinery, New York, NY, USA (1988). https://doi.org/10.1145/73560.73562

  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). https://doi.org/10.1007/978-3-540-71229-9_10

    Chapter  Google Scholar 

  25. Scholz, B., Eckstein, E.: Register allocation for irregular architectures. In: Proceedings of the Joint Conference on Languages, Compilers and Tools for Embedded Systems: Software and Compilers for Embedded Systems, pp. 139–148 (2002)

    Google Scholar 

  26. Wimmer, C., Mössenböck, H.: Optimized interval splitting in a linear scan register allocator. In: Proceedings of the 1st ACM/USENIX International Conference on Virtual Execution Environments, pp. 132–141 (2005)

    Google Scholar 

  27. Yatsina, M.: Improving region split decisions, April 2018. https://llvm.org/devmtg/2018-04/slides/Yatsina-LLVM Greedy Register Allocator.pdf

Download references

Acknowledgement

This work was supported by Institute for Information & communications Technology Promotion (IITP) grants funded by the Korea government (MSIP) (No. 2019-0-01906, Artificial Intelligence Graduate School Program (POSTECH) and No. 2021-0-00310, AI Frameworks) and the Super Computer Development Leading Program of the National Research Foundation of Korea (NRF) funded by the Korean government (Ministry of Science and ICT (MSIT)) (No. 2020M3H6A1084853).

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Hyojin Sung .

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 2022 Springer Nature Switzerland AG

About this paper

Check for updates. Verify currency and authenticity via CrossMark

Cite this paper

Shin, Y., Sung, H. (2022). Hybrid Register Allocation with Spill Cost and Pattern Guided Optimization. In: Li, X., Chandrasekaran, S. (eds) Languages and Compilers for Parallel Computing. LCPC 2021. Lecture Notes in Computer Science, vol 13181. Springer, Cham. https://doi.org/10.1007/978-3-030-99372-6_3

Download citation

  • DOI: https://doi.org/10.1007/978-3-030-99372-6_3

  • Published:

  • Publisher Name: Springer, Cham

  • Print ISBN: 978-3-030-99371-9

  • Online ISBN: 978-3-030-99372-6

  • eBook Packages: Computer ScienceComputer Science (R0)

Publish with us

Policies and ethics