skip to main content
research-article
Free Access

Detecting bugs in register allocation

Published:22 April 2010Publication History
Skip Abstract Section

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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  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.Google ScholarGoogle Scholar
  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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. Briggs, P., Cooper, K. D., and Torczon, L. 1992. Rematerialization. In Proceedings of the ACM SIGPLAN Conference on Programming Language Design and Implementation. Google ScholarGoogle ScholarDigital LibraryDigital Library
  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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. Chaitin, G. J. 1982. Register allocation and spilling via graph coloring. In Proceedings of the Symposium on Compiler Construction. Google ScholarGoogle ScholarDigital LibraryDigital Library
  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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. CPU2000 benchmark. Standard Performance Evaluation Corporation (SPEC). http://www.spec.org.Google ScholarGoogle Scholar
  14. Davidson, J. W. and Fraser, C. W. 1984. Register allocation and exhaustive peephole optimization. Softw. Pract. Exper. 14, 9, 857--865.Google ScholarGoogle ScholarCross RefCross Ref
  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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. GCC. GCC homepage. http://gcc.gnu.org/.Google ScholarGoogle Scholar
  18. George, L. and Appel, A. W. 1996. Iterated register coalescing. ACM Trans. Program. Lang. Syst. 3, 18, 300--324. Google ScholarGoogle ScholarDigital LibraryDigital Library
  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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  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.Google ScholarGoogle Scholar
  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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  22. Lee, K. D. 2003. A formally verified register allocation framework. Electron. Not. Theor. Comput. Sci. 82, 3.Google ScholarGoogle Scholar
  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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  28. MiBench. University of Michigan. http://www.eecs.umich.edu/mibench/.Google ScholarGoogle Scholar
  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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  30. Necula, G. C. 2000. Translation validation for an optimizing compiler. In Proceedings of the ACM SIGPLAN Conference on Programming Language Design and Implementation. Google ScholarGoogle ScholarDigital LibraryDigital Library
  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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  32. Pereira, F. M. Q. 2006. Static validation of register allocation. http://compilers.cs.ucla.edu/ralf/publications/Pereira06b-tech-report.pdf.Google ScholarGoogle Scholar
  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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  35. Poletto, M. and Sarkar, V. 1999. Linear scan register allocation. ACM Trans. Program. Lang. Syst. 5, 21, 895--913. Google ScholarGoogle ScholarDigital LibraryDigital Library
  36. Rinard, M. C. 1999. Credible compilation. Tech. rep. MIT-LCS-TR-776, Massachusetts Institute of Technology. March.Google ScholarGoogle Scholar
  37. Rival, X. 2004. Symbolic transfer function-based approaches to certified compilation. In Proceedings of the Symposium on Principles of Programming Languages. Google ScholarGoogle ScholarDigital LibraryDigital Library
  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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  39. Smith, M. D. and Holloway, G. Machine SUIF. http://www.eecs.harvard.edu/hube/research/machsuif.html.Google ScholarGoogle Scholar
  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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  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. Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Detecting bugs in register allocation

            Recommendations

            Comments

            Login options

            Check if you have access through your login credentials or your institution to get full access on this article.

            Sign in

            Full Access

            • 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

              Copyright © 2010 ACM

              Publisher

              Association for Computing Machinery

              New York, NY, United States

              Publication History

              • Published: 22 April 2010
              • Revised: 1 October 2009
              • Accepted: 1 October 2009
              • Received: 1 April 2007
              Published in toplas Volume 32, Issue 4

              Permissions

              Request permissions about this article.

              Request Permissions

              Check for updates

              Qualifiers

              • research-article
              • Research
              • Refereed
            • Article Metrics

              • Downloads (Last 12 months)26
              • Downloads (Last 6 weeks)5

              Other Metrics

            PDF Format

            View or Download as a PDF file.

            PDF

            eReader

            View online with eReader.

            eReader
            About Cookies On This Site

            We use cookies to ensure that we give you the best experience on our website.

            Learn more

            Got it!