Speed and Precision in Range Analysis

  • Victor Hugo Sperle Campos
  • Raphael Ernani Rodrigues
  • Igor Rafael de Assis Costa
  • Fernando Magno Quintão Pereira
Part of the Lecture Notes in Computer Science book series (LNCS, volume 7554)


Range analysis is a compiler technique that determines statically the lower and upper values that each integer variable from a target program may assume during this program’s execution. This type of inference is very important, because it enables several compiler optimizations, such as dead and redundant code elimination, bitwidth aware register allocation, and detection of program vulnerabilities. In this paper we describe an inter-procedural, context-sensitive range analysis algorithm that we have implemented in the LLVM compiler. During the effort to produce an industrial-quality implementation of our algorithm, we had to face a constant tension between precision and speed. The foremost goal of this paper is to discuss the many engineering choices that, due to this tension, have shaped our implementation. Given the breath of our evaluation, we believe that this paper contains the most comprehensive empirical study of a range analysis algorithm ever presented in the compiler related literature.


Growth Analysis Constraint System Range Analysis Abstract Interpretation Program Representation 
These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.


Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.


  1. 1.
    Barik, R., Grothoff, C., Gupta, R., Pandit, V., Udupa, R.: Optimal Bitwise Register Allocation Using Integer Linear Programming. In: Almási, G.S., Caşcaval, C., Wu, P. (eds.) KSEM 2006. LNCS, vol. 4382, pp. 267–282. Springer, Heidelberg (2007)CrossRefGoogle Scholar
  2. 2.
    Bertrane, J., Cousot, P., Cousot, R., Feret, J., Mauborgne, L., Miné, A., Rival, X.: Static analysis and verification of aerospace software by abstract interpretation. In: I@A, pp. 1–38. AIAA (2010)Google Scholar
  3. 3.
    Bodik, R., Gupta, R., Sarkar, V.: ABCD: eliminating array bounds checks on demand. In: PLDI, pp. 321–333. ACM (2000)Google Scholar
  4. 4.
    Cong, J., Fan, Y., Han, G., Lin, Y., Xu, J., Zhang, Z., Cheng, X.: Bitwidth-aware scheduling and binding in high-level synthesis. In: Proceedings of the Asia and South Pacific Design Automation Conference, ASP-DAC 2005, January 18-21, vol. 2, pp. 856–861 (2005)Google Scholar
  5. 5.
    Cousot, P., Cousot, R.: Abstract interpretation: a unified lattice model for static analysis of programs by construction or approximation of fixpoints. In: POPL, pp. 238–252. ACM (1977)Google Scholar
  6. 6.
    Cousot, P., Cousot, R., Feret, J., Mauborgne, L., Miné, A., Rival, X.: Why does astrée scale up? Form. Methods Syst. Des. 35(3), 229–264 (2009)zbMATHCrossRefGoogle Scholar
  7. 7.
    Cytron, R., Ferrante, J., Rosen, B.K., Wegman, M.N., Kenneth Zadeck, F.: Efficiently computing static single assignment form and the control dependence graph. TOPLAS 13(4), 451–490 (1991)CrossRefGoogle Scholar
  8. 8.
    do Couto Teixeira, D., Pereira, F.M.Q.: The design and implementation of a non-iterative range analysis algorithm on a production compiler. In: SBLP, pp. 45–59. SBC (2011)Google Scholar
  9. 9.
    Gawlitza, T., Leroux, J., Reineke, J., Seidl, H., Sutre, G., Wilhelm, R.: Polynomial precise interval analysis revisited. Efficient Algorithms 1, 422–437 (2009)CrossRefGoogle Scholar
  10. 10.
    Lakhdar-Chaouch, L., Jeannet, B., Girault, A.: Widening with Thresholds for Programs with Complex Control Graphs. In: Bultan, T., Hsiung, P.-A. (eds.) ATVA 2011. LNCS, vol. 6996, pp. 492–502. Springer, Heidelberg (2011)CrossRefGoogle Scholar
  11. 11.
    Lattner, C., Adve, V.S.: LLVM: A compilation framework for lifelong program analysis & transformation. In: CGO, pp. 75–88. IEEE (2004)Google Scholar
  12. 12.
    Lhairech-Lebreton, G., Coussy, P., Heller, D., Martin, E.: Bitwidth-aware high-level synthesis for designing low-power dsp applications. In: ICECS, pp. 531–534. IEEE (2010)Google Scholar
  13. 13.
    Logozzo, F., Fahndrich, M.: Pentagons: a weakly relational abstract domain for the efficient validation of array accesses. In: SAC, pp. 184–188. ACM (2008)Google Scholar
  14. 14.
    Mahlke, S., Ravindran, R., Schlansker, M., Schreiber, R., Sherwood, T.: Bitwidth cognizant architecture synthesis of custom hardware accelerators. Computer-Aided Design of Integrated Circuits and Systems 20(11), 1355–1371 (2001)CrossRefGoogle Scholar
  15. 15.
    Nielson, F., Nielson, H.R., Hankin, C.: Principles of Program Analysis. Springer (1999)Google Scholar
  16. 16.
    Oh, H., Brutschy, L., Yi, K.: Access Analysis-Based Tight Localization of Abstract Memories. In: Jhala, R., Schmidt, D. (eds.) VMCAI 2011. LNCS, vol. 6538, pp. 356–370. Springer, Heidelberg (2011)CrossRefGoogle Scholar
  17. 17.
    Oh, H., Heo, K., Lee, W., Lee, W., Yi, K.: Design and implementation of sparse global analyses for C-like languages. In: PLDI, pp. 229–238. ACM (2012)Google Scholar
  18. 18.
    Patterson, J.R.C.: Accurate static branch prediction by value range propagation. In: PLDI, pp. 67–78. ACM (1995)Google Scholar
  19. 19.
    Pereira, F.M.Q., Palsberg, J.: Register allocation by puzzle solving. In: PLDI, pp. 216–226. ACM (2008)Google Scholar
  20. 20.
    Rimsa, A., d’Amorim, M., Pereira, F.M. Q.: Tainted Flow Analysis on e-SSA-Form Programs. In: Knoop, J. (ed.) CC 2011. LNCS, vol. 6601, pp. 124–143. Springer, Heidelberg (2011)CrossRefGoogle Scholar
  21. 21.
    Simon, A.: Value-Range Analysis of C Programs: Towards Proving the Absence of Buffer Overflow Vulnerabilities, 1st edn. Springer (2008)Google Scholar
  22. 22.
    Sol, R., Guillon, C., Pereira, F.M.Q., Bigonha, M.A.S.: Dynamic Elimination of Overflow Tests in a Trace Compiler. In: Knoop, J. (ed.) CC 2011. LNCS, vol. 6601, pp. 2–21. Springer, Heidelberg (2011)CrossRefGoogle Scholar
  23. 23.
    Stephenson, M., Babb, J., Amarasinghe, S.: Bitwidth analysis with application to silicon compilation. In: PLDI, pp. 108–120. ACM (2000)Google Scholar
  24. 24.
    Su, Z., Wagner, D.: A Class of Polynomially Solvable Range Constraints for Interval Analysis without Widenings and Narrowings. In: Jensen, K., Podelski, A. (eds.) TACAS 2004. LNCS, vol. 2988, pp. 280–295. Springer, Heidelberg (2004)CrossRefGoogle Scholar
  25. 25.
    Su, Z., Wagner, D.: A class of polynomially solvable range constraints for interval analysis without widenings. Theoretical Computeter Science 345(1), 122–138 (2005)MathSciNetzbMATHCrossRefGoogle Scholar
  26. 26.
    Tallam, S., Gupta, R.: Bitwidth aware global register allocation. In: POPL, pp. 85–96. ACM (2003)Google Scholar
  27. 27.
    Venet, A., Brat, G.: Precise and efficient static array bound checking for large embedded c programs. SIGPLAN Not. 39, 231–242 (2004)CrossRefGoogle Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2012

Authors and Affiliations

  • Victor Hugo Sperle Campos
    • 1
  • Raphael Ernani Rodrigues
    • 1
  • Igor Rafael de Assis Costa
    • 1
  • Fernando Magno Quintão Pereira
    • 1
  1. 1.Department of Computer ScienceUFMGBrazil

Personalised recommendations