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.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
References
Cloning MachineFunctions. https://groups.google.com/g/llvm-dev/c/DOP6RSV8lQ4/m/C3Lfe6gJEwAJ
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
LLVM testing infrastructure. https://github.com/llvm/llvm-test-suite
Parallel bicubic interpolation. https://github.com/srijanmishra/parallel-bicubic-interpolation
Suggestions on register allocation by using reinforcement learning. https://groups.google.com/g/llvm-dev/c/V9ykDwqGeNw/m/-3SfJsuRAQAJ
Aho, A.V., Sethi, R., Ullman, J.D.: Compilers, Principles, Techniques, and Tools. Addison-Wesley, New York (1986)
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
Briggs, P., Cooper, K.D., Torczon, L.: Improvements to graph coloring register allocation. ACM Trans. Program. Lang. Syst. (TOPLAS) 16(3), 428–455 (1994)
Callahan, D., Koblenz, B.: Register allocation via hierarchical graph coloring. ACM Sigplan Not. 26(6), 192–203 (1991)
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
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)
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
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
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
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
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)
Evlogimenos, A.: Improvements to linear scan register allocation (2004). https://llvm.org/ProjectsWithLLVM/2004-Fall-CS426-LS.pdf
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
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)
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
Olesen, J.S.: Greedy register allocation, September 2011. http://blog.llvm.org/2011/09/greedy-register-allocation-in-llvm-30.html
Poletto, M., Sarkar, V.: Linear scan register allocation. ACM Trans. Prog. Lang. Syst. (TOPLAS) 21(5), 895–913 (1999)
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
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
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)
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)
Yatsina, M.: Improving region split decisions, April 2018. https://llvm.org/devmtg/2018-04/slides/Yatsina-LLVM Greedy Register Allocator.pdf
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
Corresponding author
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2022 Springer Nature Switzerland AG
About this paper
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)