Nothing Special   »   [go: up one dir, main page]

skip to main content
article

Register allocation and spilling using the expected distance heuristic

Published: 01 November 2016 Publication History

Abstract

The primary goal of the register allocation phase in a compiler is to minimize register spills to memory. Spill decisions by the allocator are often made based on the costs of spilling a virtual register and, therefore, on an assumed placement of spill instructions. However, because most allocators make these decisions incrementally, placement opportunities can change as allocation proceeds, calling into question the basis for the original spill decision. An alternative heuristic to placement costs for spill decisions focuses on where program execution will lead. Spilling the virtual register with the Furthest Next Use is known to lead to the minimum number of loads under certain conditions in straight-line code. While it has been implemented in register allocation in different forms, none of these implementations fully exploits profiling information. We present a register allocator that can adapt to improved profiling information, using branch probabilities to compute an Expected Distance to Next Use for making spill decisions and block frequency information to optimize post-allocation spill instruction placement. Spill placement is optimized after allocation using a novel method for minimizing spill instruction costs on the control flow graph. Our evaluation of the allocator compared with LLVM recognizes more than 36% and 50% reductions, on average, in the number of dynamically executed store and load instructions, respectively, when using statically derived profiling information. When using dynamically gathered profiling, these improvements increase to 50% and 60% reductions, on average, for stores and loads, respectively. Copyright © 2016 John Wiley & Sons, Ltd.

References

[1]
Briggs P, Cooper KD, Torczon L. Improvements to graph coloring register allocation. ACM Transactions on Programming Languages and Systems TOPLAS. 1994; Volume 16 Issue 3: pp.428-455.
[2]
Chaitin GJ. Register allocation and spilling via graph coloring. Proceedings of the 1982 SIGPLAN Symposium on Compiler Construction, SIGPLAN '82. ACM: New York, NY, USA, 1982; pp.98-105.
[3]
Hsu W, Fisher CN, Goodman JR. On the minimization of loads/stores in local register allocation. IEEE Transactions on Software Engineering. 1989; Volume 15 Issue 10: pp.1252-1260.
[4]
Bélády LA. A study of replacement algorithms for a virtual storage computer. IBM Systems Journal. 1966; Volume 5 Issue 2: pp.78-101.
[5]
Guo J, Garzarán MJ, Padua D. The power of belady's algorithm in register allocation for long basic blocks. The 16th International Workshop on Languages and Compilers for Parallel Computing: College Station, TX, USA, 2003; pp.374-389.
[6]
Braun M, Hack S. Register spilling and live-range splitting for SSA-form programs. Proceedings of the 18th International Conference on Compiler Construction: Held As Part of the Joint European Conferences on Theory and Practice of Software, ETAPS 2009, CC '09. Springer-Verlag: Berlin, Heidelberg, 2009.
[7]
Hack S, Grund D, Goos G. Register allocation for programs in SSA-Form. Proceedings of the 15th International Conference on Compiler Construction, CC'06. Springer-Verlag: Berlin, Heidelberg, 2006; pp.247-262.
[8]
Pereira FMQ, Palsberg J. Register allocation by puzzle solving. Proceedings of the 29th ACM SIGPLAN Conference on Programming Language Design and Implementation, PLDI '08. ACM, 2008; pp.216-226.
[9]
Chaitin GJ, Auslander MA, Chandra AK, Cocke J, Hopkins ME, Markstein PW. Register allocation via coloring. Computer Languages. 1981; Volume 6: pp.47-57.
[10]
Chow F, Hennessy J. Register allocation by priority-based coloring. Proceedings of the 1984 SIGPLAN Symposium on Compiler Construction, SIGPLAN '84. ACM: New York, NY, USA, 1984; pp.222-232.
[11]
Bergner P, Dahl P, Engebretsen D, O'Keefe M. Spill code minimization via interference region spilling. Proceedings of the ACM SIGPLAN 1997 Conference on Programming Language Design and Implementation, PLDI '97. ACM: New York, NY, USA, 1997; pp.287-295.
[12]
Callahan D, Koblenz B. Register allocation via hierarchical graph coloring. Proceedings of the ACM SIGPLAN 1991 Conference on Programming Language Design and Implementation, PLDI '91. ACM: New York, NY, USA, 1991; pp.192-203.
[13]
Sarkar V, Barik R. Extended linear scan: an alternate foundation for global register allocation. Compiler Construction, 16th International Conference, CC 2007, 2007; pp.141-155.
[14]
Fu C, Wilken K. A faster optimal register allocator. Proceedings of the 35th Annual ACM/IEEE International Symposium on Microarchitecture. IEEE Computer Society Press: Los Alamitos, CA, USA, 2002; pp.245-256.
[15]
Poletto M, Sarkar V. Linear scan register allocation. ACM Transactions on Programming Language and Systems TOPLAS. 1999; Volume 21 Issue 5: pp.895-913.
[16]
Traub O, Holloway G, Smith MD. Quality and speed in linear-scan register allocation. PLDI '98: Proceedings of the ACM SIGPLAN 1998 Conference on Programming Language Design and Implementation. ACM: New York, NY, USA, 1998; pp.142-151.
[17]
Wimmer C, Mössenböck H. Optimized interval splitting in a linear scan register allocator. VEE '05: Proceedings of the 1st ACM/USENIX International Conference On Virtual Execution Environments. ACM: New York, NY, USA, 2005; pp.132-141.
[18]
Backus J. 1981. The history of Fortran I, II, and III. In History of Programming Languages I, Wexelblat RL ¿ed. ACM: New York, NY, USA; pp.25-74.
[19]
Briggs P, Cooper KD, Torczon L. Rematerialization. Proceedings of the ACM SIGPLAN 1992 Conference on Programming Language Design and Implementation, PLDI '92. ACM: New York, NY, USA, 1992; pp.311-321.
[20]
Farach M, Liberatore V. On local register allocation. SODA '98: Proceedings of the Ninth Annual ACM-SIAM Symposium on Discrete Algorithms. Society for Industrial and Applied Mathematics: Philadelphia, PA, USA, 1998; pp.564-573.
[21]
GCC the GNU Compiler Collection. Available from: "http://gcc.gnu.org/". {last accessed September 2015}.
[22]
libFirm compiler. Available from: "http://www.libfirm.org/". {last accessed September 2015}.
[23]
Proebsting TA, Fischer CN. Demand-driven register allocation. ACM Transactions on Programming Language and Systems TOPLAS. 1996; Volume 18 Issue 6: pp.683-710.
[24]
Koes DR, Goldstein SC. Register allocation deconstructed. SCOPES '09: Proceedings of the 12th International Workshop on Software and Compilers for Embedded Systems. ACM, 2009; pp.21-30.
[25]
Appel AW, George L. Optimal spilling for CISC machines with few registers. Proceedings of the ACM SIGPLAN 2001 Conference on Programming Language Design and Implementation, PLDI '01. ACM: New York, NY, USA, 2001; pp.243-253.
[26]
Chekuri CS, Goldberg AV, Karger DR, Levine MS, Stein C. Experimental study of minimum cut algorithms. Proceedings of the Eighth Annual ACM-SIAM Symposium on Discrete Algorithms, SODA '97. Society for Industrial and Applied Mathematics: Philadelphia, PA, USA, 1997; pp.324-333.
[27]
Cai Q, Xue J. Optimal and efficient speculation-based partial redundancy elimination. Proceedings of the International Symposium on Code Generation and Optimization: Feedback-directed and Runtime Optimization CGO. IEEE Computer Society: Washington, DC, USA, 2003; pp.91-102.
[28]
Xue J, Cai Q. A lifetime optimal algorithm for speculative PRE. ACM Transactions on Architecture and Code Optimization TACO. 2006; Volume 3 Issue 2: pp.115-155.
[29]
Muchnick SS. Advanced Compiler Design and Implementation. Morgan Kaufmann Publishers Inc.: San Francisco, CA, USA, 1997.
[30]
Ebner D, Scholz B, Krall A. Progressive spill code placement. CASES '09: Proceedings of the 2009 International Conference on Compilers, Architecture, and Synthesis for Embedded Systems. ACM: New York, NY, USA, 2009; pp.77-86.
[31]
Khedker U, Sanyal A, Karkare B. Data Flow Analysis: Theory and Practice 1st¿edn. CRC Press, Inc.: Boca Raton, FL, USA, 2009.
[32]
Bell TC, Cleary JG, Witten IH. Text Compression. Prentice-Hall, Inc.: Upper Saddle River, NJ, USA, 1990.
[33]
West DB. Introduction to Graph Theory. Prentice Hall Inc.: Upper Saddle River, NJ, USA, 1996.
[34]
Karger DR, Stein C. A new approach to the minimum cut problem. Journal of the ACM JACM. July 1996; Volume 43 Issue 4: pp.601-640.
[35]
Stoer M, Wagner F. A Simple Min-Cut Algorithm. Journal of the ACM JACM. 1997; Volume 44 Issue 4: pp.585-591.
[36]
Leighton T, Rao S. Multicommodity max-flow min-cut theorems, their use in designing approximation algorithms. Journal of the ACM JACM. 1999; Volume 46 Issue 6: pp.787-832.
[37]
Karger DR. Global min-cuts in RNC, and other ramifications of a simple min-cut algorithm. Proceedings of the Fourth Annual ACM-SIAM Symposium on Discrete Algorithms, SODA '93. Society for Industrial and Applied Mathematics: Philadelphia, PA, USA, 1993; pp.21-30.
[38]
Guattery S, Miller GL. A contraction procedure for planar directed graphs. Proceedings of the Fourth Annual ACM Symposium on Parallel Algorithms and Architectures: San Diego, CA, USA, 1992; pp.431-441.
[39]
The LLVM Compiler Infrastructure. Available from: "http://www.llvm.org/" {last accessed September 2015}.
[40]
Standard Performance Evaluation Corporation. SPEC CPU2000 Benchmark Suite, 2000. Available from: "https://www.spec.org/cpu2000/" {last accessed 9 September 2015}.
  1. Register allocation and spilling using the expected distance heuristic

      Recommendations

      Comments

      Please enable JavaScript to view thecomments powered by Disqus.

      Information & Contributors

      Information

      Published In

      cover image Software
      Software  Volume 46, Issue 11
      November 2016
      143 pages
      ISSN:0038-0644
      EISSN:1097-024X
      Issue’s Table of Contents

      Publisher

      John Wiley & Sons, Inc.

      United States

      Publication History

      Published: 01 November 2016

      Author Tags

      1. Belady MIN algorithm
      2. graph contraction
      3. minimum-cut
      4. register allocation
      5. spilling

      Qualifiers

      • Article

      Contributors

      Other Metrics

      Bibliometrics & Citations

      Bibliometrics

      Article Metrics

      • 0
        Total Citations
      • 0
        Total Downloads
      • Downloads (Last 12 months)0
      • Downloads (Last 6 weeks)0
      Reflects downloads up to 12 Nov 2024

      Other Metrics

      Citations

      View Options

      View options

      Get Access

      Login options

      Media

      Figures

      Other

      Tables

      Share

      Share

      Share this Publication link

      Share on social media