skip to main content
research-article
Free Access

Practical verification of peephole optimizations with Alive

Published:23 January 2018Publication History
Skip Abstract Section

Abstract

Compilers should not miscompile. Peephole optimizations, which perform local rewriting of the input program to improve the efficiency of generated code, are a persistent source of compiler bugs. We created Alive, a domain-specific language for writing optimizations and for automatically either proving them correct or else generating counterexamples. Furthermore, Alive can be automatically translated into C++ code that is suitable for inclusion in an LLVM optimization pass. Alive is based on an attempt to balance usability and formal methods; for example, it captures---but largely hides---the detailed semantics of the various kinds of undefined behavior. Alive has found numerous bugs in the LLVM compiler and is being used by LLVM developers.

References

  1. Bansal, S., Aiken, A. Automatic generation of peephole superoptimizers. In Proceedings of the 12th International Conference on Architectural Support for Programming Languages and Operating Systems (ASPLOS) (2006), 394--403. Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. Buchwald, S. Optgen: A generator for local optimizations. In Proceedings of the 24th International Conference on Compiler Construction (CC) (2015).Google ScholarGoogle ScholarCross RefCross Ref
  3. Davidson, J.W., Fraser, C.W. Automatic generation of peephole optimizations. In Proceedings of the 1984 SIGPLAN Symposium on Compiler Construction (1984). Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. De Moura, L., Bjørner, N. Z3: An efficient SMT solver. In Proceedings of the 14th International Conference on Tools and Algorithms for the Construction and Analysis of Systems (2008), 337--340. Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. Joshi, R., Nelson, G., Zhou, Y. Denali: A practical algorithm for generating optimal code. ACM Trans. Program. Lang. Syst. 28, 6 (Nov. 2006), 967--989. Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. Kundu, S., Tatlock, Z., Lerner, S. Proving optimizations correct using parameterized program equivalence. In Proceedings of the 2009 ACM SIGPLAN Conference on Programming Language Design and Implementation (2009). Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. Le, V., Afshari, M., Su, Z. Compiler validation via equivalence modulo inputs. In Proceedings of the 35th ACM SIGPLAN Conference on Programming Language Design and Implementation (2014). Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. Lee, J., Kim, Y., Song, Y., Hur, C.-K., Das, S., Majnemer, D., Regehr, J., Lopes, N.P. Taming undefined behavior in LLVM. In Proceedings of the 38th annual ACM SIGPLAN conference on Programming Language Design and Implementation (2017). Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. Leroy, X. Formal verification of a realistic compiler. Commun. of the ACM 52, 7 (2009), 107--115. Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. Lopes, N.P., Menendez, D., Nagarakatte, S., Regehr, J. Provably correct peephole optimizations with Alive. In Proceedings of the 36th annual ACM SIGPLAN conference on Programming Language Design and Implementation (PLDI) (2015). Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. Lopes, N.P., Monteiro, J. Automatic equivalence checking of programs with uninterpreted functions and integer arithmetic. Int. J. Softw. Tools Technol. Transf. 18, 4 (2016), 359--374. Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. Massalin, H. Superoptimizer: A look at the smallest program. In Proceedings of the 2nd International Conference on Architectural Support for Programming Languages and Operating Systems (ASPLOS) (1987). Google ScholarGoogle ScholarCross RefCross Ref
  13. Menendez, D., Nagarakatte, S. Alive-infer: Data-driven precondition inference for peephole optimizations in LLVM. In Proceedings of the 38th annual ACM SIGPLAN conference on Programming Language Design and Implementation (2017). Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. Menendez, D., Nagarakatte, S., Gupta, A. Alive-FP: Automated verification of floating point based peephole optimizations in LLVM. In Proceedings of the 23rd International Symposium on Static Analysis (2016).Google ScholarGoogle ScholarCross RefCross Ref
  15. Morisset, R., Pawan, P., Nardelli, F.Z. Compiler testing via a theory of sound optimisations in the C11/C++11 memory model. In Proceedings of the 34th ACM SIGPLAN Conference on Programming Language Design and Implementation (2013). Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. Nötzli, A., Brown, F. LifeJacket: Verifying precise floating-point optimizations in LLVM. In Proceedings of the 5th ACM SIGPLAN International Workshop on State Of the Art in Program Analysis (2016). Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. Pnueli, A., Siegel, M., Singerman, E. Translation validation. In Proceedings of the 4th International Conference on Tools and Algorithms for Construction and Analysis of Systems (1998), 151--166. Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. Samet, H. Proving the correctness of heuristically optimized code. In Communications of the ACM (1978). Google ScholarGoogle ScholarDigital LibraryDigital Library
  19. Schkufza, E., Sharma, R., Aiken, A. Stochastic superoptimization. In Proceedings of the 18th International Conference on Architectural Support for Programming Languages and Operating Systems (ASPLOS) (2013). Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. Yang, X., Chen, Y., Eide, E., Regehr, J. Finding and understanding bugs in C compilers. In Proceedings of the 32nd ACM SIGPLAN Conference on Programming Language Design and Implementation (2011). Google ScholarGoogle ScholarDigital LibraryDigital Library
  21. Zhao, J., Nagarakatte, S., Martin, M.M., Zdancewic, S. Formalizing the LLVM intermediate representation for verified program transformations. In Proceedings of the 39th Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (2012). Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Practical verification of peephole optimizations with Alive

              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 Communications of the ACM
                Communications of the ACM  Volume 61, Issue 2
                February 2018
                94 pages
                ISSN:0001-0782
                EISSN:1557-7317
                DOI:10.1145/3181977
                Issue’s Table of Contents

                Copyright © 2018 ACM

                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: 23 January 2018

                Permissions

                Request permissions about this article.

                Request Permissions

                Check for updates

                Qualifiers

                • research-article
                • Research
                • Refereed

              PDF Format

              View or Download as a PDF file.

              PDF

              eReader

              View online with eReader.

              eReader

              HTML Format

              View this article in HTML Format .

              View HTML Format