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

skip to main content
research-article
Open access

Detecting bugs in register allocation

Published: 22 April 2010 Publication History

Abstract

Although register allocation is critical for performance, the implementation of register allocation algorithms is difficult, due to the complexity of the algorithms and target machine architectures. It is particularly difficult to detect register allocation errors if the output code runs to completion, as bugs in the register allocator can cause the compiler to produce incorrect output code. The output code may even execute properly on some test data, but errors can remain. In this article, we propose novel data flow analyses to statically check that the value flow of the output code from the register allocator is the same as the value flow of its input code. The approach is accurate, fast, and can identify and report error locations and types. It is independent of the register allocator and uses only the input and output code of the register allocator. It can be used with different register allocators, including those that perform coalescing and rematerialization. The article describes our approach, called SARAC, and a tool that statically checks a register allocation and reports the errors and their types that it finds. The tool has an average compile-time overhead of only 8% and a modest average memory overhead of 85KB. Our techniques can be used by compiler developers during regression testing and as a command-line-enabled debugging pass for mysterious compiler behavior.

References

[1]
Adl-Tabatabai, A. and Gross, T. 1993. Evicted variables and the interaction of global register allocation and symbolic debugging. In Proceedings of the Symposium on Principles of Programming Languages.
[2]
Adl-Tabatabai, A. and Gross, T. 1996. Source-Level debugging of scalar optimized code. In Proceedings of the ACM SIGPLAN Conference on Programming Language Design and Implementation.
[3]
Barthe, G., Gregoire, B., Kunz, C., and Rezk, T. 2006. Certificate translation for optimizing compilers. In Proceedings of the 13th International Static Analysis Symposium.
[4]
Blech, J. O. and Gregoire, B. 2008. Certifying code generation runs with Coq: A tool description. In Proceedings of the 7th International Workshop on Compiler Optimization Meets Compiler Verification.
[5]
Benitez, M. E. and Davidson, J. W. 1988. A portable global optimizer and linker. In Proceedings of the ACM SIGPLAN Conference on Programming Language Design and Implementation.
[6]
Bernstein, D., Golumbic, M., Mansour, Y., Pinter, R., Goldin, D., Krawczyk, H., and Nahshon, I. 1989. Spill code minimization techniques for optimizing compilers. In Proceedings of the ACM SIGPLAN Conference on Programming Language Design and Implementation.
[7]
Bradlee, D. G., Eggers, S. J., and Henry, R. R. 1991. Integrating register allocation and instruction scheduling for RISCs. In Proceedings of the 4th International Conference on Architectural Support for Programming Languages and Operating Systems.
[8]
Briggs, P., Cooper, K. D., and Torczon, L. 1992. Rematerialization. In Proceedings of the ACM SIGPLAN Conference on Programming Language Design and Implementation.
[9]
Briggs, P., Cooper, K. D., and Torczon, L. 1994. Improvements to graph coloring register allocation. ACM Trans. Program. Lang. Syst. 3, 16, 428--455.
[10]
Chaitin, G. J. 1982. Register allocation and spilling via graph coloring. In Proceedings of the Symposium on Compiler Construction.
[11]
Chow, F. C. and Hennessy, J. L. 1990. The priority-based register allocation coloring approach. ACM Trans. Program. Lang. Syst. 4, 12, 501--536.
[12]
Cooper, K. D. and Lu, J. 1997. Register promotion in C programs. In Proceedings of the ACM SIGPLAN Conference on Programming Language Design and Implementation.
[13]
CPU2000 benchmark. Standard Performance Evaluation Corporation (SPEC). http://www.spec.org.
[14]
Davidson, J. W. and Fraser, C. W. 1984. Register allocation and exhaustive peephole optimization. Softw. Pract. Exper. 14, 9, 857--865.
[15]
Dor, N., Adams, S., Das, M., and Yang, Z. 2004. Software validation via scalable path-sensitive value flow analysis. In Proceedings of the International Symposium on Software Testing and Analysis.
[16]
Dwyer, M. B. and Clarke, L. A. 1994. Data flow analysis for verifying properties of concurrent programs. In Proceedings of the ACM SIGSOFT Symposium on Foundations of Software Engineering.
[17]
GCC. GCC homepage. http://gcc.gnu.org/.
[18]
George, L. and Appel, A. W. 1996. Iterated register coalescing. ACM Trans. Program. Lang. Syst. 3, 18, 300--324.
[19]
Gupta, R., Soffa, M. L., and Steele, T. 1989. Register allocation via clique separators. In Proceedings of the ACM SIGPLAN Conference on Programming Language Design and Implementation.
[20]
Jaramillo, C. S., Gupta, R., and Soffa, M. L. 2002. Verifying optimizers through comparison checking. In Proceedings of the International Workshop on Compiler Optimization Meets Compiler Verification.
[21]
Lee, C., Potkonjak, M., and Mangione-Smith, W. H. 1997. MediaBench: A tool for evaluating and synthesizing multimedia and communicatons systems. In Proceedings of the ACM/IEEE International Symposium on Microarchitecture.
[22]
Lee, K. D. 2003. A formally verified register allocation framework. Electron. Not. Theor. Comput. Sci. 82, 3.
[23]
Lerner, S., Millstein, T., and Chambers, C. 2003. Automatically proving the correctness of compiler optimizations. In Proceedings of the ACM SIGPLAN Conference on Programming Language Design and Implementation.
[24]
Lerner, S., Millstein, T., Rice, E., and Chambers, C. 2005. Automated soundness proofs for dataflow analyses and transformations via local rules. In Proceedings of the Symposium on Principles of Programming Languages.
[25]
Leroy, X. 2006. Formal certification of a compiler back-end or: Programming a compiler with a proof assistant. In Proceedings of the Symposium on Principles of Programming Languages.
[26]
Li, G., Owens, S., and Slind, K. 2007. Structure of a proof-producing compiler for a subset of higher order logic. In Proceedings of the 16th European Symposium on Programming (ESOP'07). Lecture Notes in Computer Science, vol. 4421. Springer, 205--219.
[27]
McNerney, T. M. 1991. Verifying the correctness of compiler transformations on basic blocks using abstract interpretation. In Proceedings of the ACM/SIGPLAN Workshop on Partial Evaluation and Semantics-Based Program Manipulation.
[28]
MiBench. University of Michigan. http://www.eecs.umich.edu/mibench/.
[29]
Nandivada, V. K., Pereira, F. M. Q., and Palsberg, J. 2007. A framework for end-to-end verification and evaluation of register allocators. In Proceedings of the 14th International Static Analysis Symposium.
[30]
Necula, G. C. 2000. Translation validation for an optimizing compiler. In Proceedings of the ACM SIGPLAN Conference on Programming Language Design and Implementation.
[31]
Necula, G. C. and Lee, P. 1998. The design and implementation of a certifying compiler. In Proceedings of the ACM SIGPLAN Conference on Programming Language Design and Implementation.
[32]
Pereira, F. M. Q. 2006. Static validation of register allocation. http://compilers.cs.ucla.edu/ralf/publications/Pereira06b-tech-report.pdf.
[33]
Pinter, S. S. 1993. Register allocation with instruction scheduling: A new approach. In Proceedings of the ACM SIGPLAN Conference on Programming Language Design and Implementation.
[34]
Pnueli, A., Siegel, M., and Singerman, F. 1998. Translation validation. In Proceedings of the 4th Conference on Tools and Algorithms for Construction and Analysis of Systems.
[35]
Poletto, M. and Sarkar, V. 1999. Linear scan register allocation. ACM Trans. Program. Lang. Syst. 5, 21, 895--913.
[36]
Rinard, M. C. 1999. Credible compilation. Tech. rep. MIT-LCS-TR-776, Massachusetts Institute of Technology. March.
[37]
Rival, X. 2004. Symbolic transfer function-based approaches to certified compilation. In Proceedings of the Symposium on Principles of Programming Languages.
[38]
Santhanam, V. and Odnert, D. 1990. Register allocation across procedure and module boundaries. In Proceedings of the ACM SIGPLAN Conference on Programming Language Design and Implementation.
[39]
Smith, M. D. and Holloway, G. Machine SUIF. http://www.eecs.harvard.edu/hube/research/machsuif.html.
[40]
Smith, M. D., Ramsey, N., and Holloway, G. 2004. A generalized algorithm for graph-coloring register allocation. In Proceedings of the ACM SIGPLAN Conference on Programming Language Design and Implementation.
[41]
Steffen, B., Knoop, J., and Ruthing, O. 1990. The value flow graph: A program representation for optimal program transformations. In Proceedings of the 3rd European Symposium on Programming (ESOP). Lecture Notes in Computer Science, vol. 432. Springer, 389--405.
[42]
Wismueller, R. 1994. Debugging of globally optimized programs using data flow analysis. In Proceedings of the ACM SIGPLAN Conference on Programming Language Design and Implementation.

Recommendations

Comments

Please enable JavaScript to view thecomments powered by Disqus.

Information & Contributors

Information

Published In

cover image ACM Transactions on Programming Languages and Systems
ACM Transactions on Programming Languages and Systems  Volume 32, Issue 4
April 2010
230 pages
ISSN:0164-0925
EISSN:1558-4593
DOI:10.1145/1734206
Issue’s Table of Contents
Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than ACM must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected]

Publisher

Association for Computing Machinery

New York, NY, United States

Publication History

Published: 22 April 2010
Accepted: 01 October 2009
Revised: 01 October 2009
Received: 01 April 2007
Published in TOPLAS Volume 32, Issue 4

Permissions

Request permissions for this article.

Check for updates

Author Tag

  1. Register allocation

Qualifiers

  • Research-article
  • Research
  • Refereed

Contributors

Other Metrics

Bibliometrics & Citations

Bibliometrics

Article Metrics

  • 0
    Total Citations
  • 591
    Total Downloads
  • Downloads (Last 12 months)104
  • Downloads (Last 6 weeks)15
Reflects downloads up to 24 Sep 2024

Other Metrics

Citations

View Options

View options

PDF

View or Download as a PDF file.

PDF

eReader

View online with eReader.

eReader

Get Access

Login options

Full Access

Media

Figures

Other

Tables

Share

Share

Share this Publication link

Share on social media