skip to main content
research-article
Open Access
Artifacts Available / v1.1

The road not taken: exploring alias analysis based optimizations missed by the compiler

Published:31 October 2022Publication History
Skip Abstract Section

Abstract

Context-sensitive inter-procedural alias analyses are more precise than intra-procedural alias analyses. However, context-sensitive inter-procedural alias analyses are not scalable. As a consequence, most of the production compilers sacrifice precision for scalability and implement intra-procedural alias analysis. The alias analysis is used by many compiler optimizations, including loop transformations. Due to the imprecision of alias analysis, the program’s performance may suffer, especially in the presence of loops.

Previous work proposed a general approach based on code-versioning with dynamic checks to disambiguate pointers at runtime. However, the overhead of dynamic checks in this approach is O(log n), which is substantially high to enable interesting optimizations. Other suggested approaches, e.g., polyhedral and symbolic range analysis, have O(1) overheads, but they only work for loops with certain constraints. The production compilers, such as LLVM and GCC, use scalar evolution analysis to compute an O(1) range check for loops to resolve memory dependencies at runtime. However, this approach also can only be applied to loops with certain constraints.

In this work, we present our tool, Scout, that can disambiguate two pointers at runtime using single memory access. Scout is based on the key idea to constrain the allocation size and alignment during memory allocations. Scout can also disambiguate array accesses within a loop for which the existing O(1) range checks technique cannot be applied. In addition, Scout uses feedback from static optimizations to reduce the number of dynamic checks needed for optimizations.

Our technique enabled new opportunities for loop-invariant code motion, dead store elimination, loop vectorization, and load elimination in an already optimized code. Our performance improvements are up to 51.11% for Polybench and up to 0.89% for CPU SPEC 2017 suites. The geometric means for our allocator’s CPU and memory overheads for CPU SPEC 2017 benchmarks are 1.05%, and 7.47%, respectively. For Polybench benchmarks, the geometric mean of CPU and memory overheads are 0.21% and 0.13%, respectively.

References

  1. 2016 (accessed Apr 14, 2022). Intel 64 and ia-32 architectures software developer’s manual volume 2b. https://www.intel.com/content/dam/www/public/us/en/documents/manuals/64-ia-32-architectures-software-developer-vol-2b-manual.pdf Google ScholarGoogle Scholar
  2. 2019 (accessed Apr 13, 2022). Restrict Keyword in LLVM. https://lists.llvm.org/pipermail/llvm-dev/2019-March/131127.html Google ScholarGoogle Scholar
  3. 2021 (accessed Apr 13, 2022). CPU SPEC 2017 benchmark suite. https://www.spec.org/cpu2017/Docs/overview.html##benchmarks Google ScholarGoogle Scholar
  4. 2022 (accessed Apr 13, 2022). Intrinsic Functions. https://llvm.org/docs/LangRef.html##intrinsic-functions Google ScholarGoogle Scholar
  5. 2022 (accessed Apr 13, 2022). Runtime Checks of Pointers. https://llvm.org/docs/Vectorizers.html##runtime-checks-of-pointers Google ScholarGoogle Scholar
  6. 2022 (accessed Apr 13, 2022). ‘noalias’ and ‘alias.scope’ Metadata. https://llvm.org/docs/LangRef.html##noalias-and-alias-scope-metadata Google ScholarGoogle Scholar
  7. 2022 (accessed Sep 9, 2022). Scout Artifact DOI. https://doi.org/10.5281/zenodo.7089827 Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. 2022 (accessed Sep 9, 2022). Scout Artifact Github Repository. https://github.com/khushboochitre/Scout-Artifact.git Google ScholarGoogle Scholar
  9. Péricles Alves, Fabian Gruber, Johannes Doerfert, Alexandros Lamprineas, Tobias Grosser, Fabrice Rastello, and Fernando Magno Quintão Pereira. 2015. Runtime Pointer Disambiguation. In Proceedings of the 2015 ACM SIGPLAN International Conference on Object-Oriented Programming, Systems, Languages, and Applications (OOPSLA 2015). Association for Computing Machinery, New York, NY, USA. 589–606. isbn:9781450336895 https://doi.org/10.1145/2814270.2814285 Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. Lars Ole Andersen and Peter Lee. 2005. Program Analysis and Specialization for the C Programming Language. Google ScholarGoogle Scholar
  11. Marc Berndl, Ondrej Lhoták, Feng Qian, Laurie Hendren, and Navindra Umanee. 2003. Points-to analysis using BDDs. ACM SIGPLAN Notices, 38, 5 (2003), 103–114. Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. Uday Bondhugula, Albert Hartono, J. Ramanujam, and P. Sadayappan. 2008. A Practical Automatic Polyhedral Parallelizer and Locality Optimizer. In Proceedings of the 29th ACM SIGPLAN Conference on Programming Language Design and Implementation (PLDI ’08). Association for Computing Machinery, New York, NY, USA. 101–113. isbn:9781595938602 https://doi.org/10.1145/1375581.1375595 Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. James Bucek, Klaus-Dieter Lange, and Jóakim v. Kistowski. 2018. SPEC CPU2017: Next-generation compute benchmark. In Companion of the 2018 ACM/SPEC International Conference on Performance Engineering. 41–42. https://doi.org/10.1145/3185768.3185771 Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. Tong Chen, Jin Lin, Xiaoru Dai, Wei-Chung Hsu, and Pen-Chung Yew. 2004. Data dependence profiling for speculative optimizations. In International Conference on Compiler Construction. 57–72. https://doi.org/10.1007/978-3-540-24723-4_5 Google ScholarGoogle ScholarCross RefCross Ref
  15. Fred Chow, Sun Chan, Robert Kennedy, Shin-Ming Liu, Raymond Lo, and Peng Tu. 1997. A New Algorithm for Partial Redundancy Elimination Based on SSA Form. In Proceedings of the ACM SIGPLAN 1997 Conference on Programming Language Design and Implementation (PLDI ’97). Association for Computing Machinery, New York, NY, USA. 273–286. isbn:0897919076 https://doi.org/10.1145/258915.258940 Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. K. D. Cooper and K. Kennedy. 1989. Fast Interprocedual Alias Analysis. In Proceedings of the 16th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL ’89). Association for Computing Machinery, New York, NY, USA. 49–59. isbn:0897912942 https://doi.org/10.1145/75277.75282 Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. Jeff Da Silva and J. Gregory Steffan. 2006. A Probabilistic Pointer Analysis for Speculative Optimizations. In Proceedings of the 12th International Conference on Architectural Support for Programming Languages and Operating Systems (ASPLOS XII). Association for Computing Machinery, New York, NY, USA. 416–425. isbn:1595934510 https://doi.org/10.1145/1168857.1168908 Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. Amer Diwan, Kathryn S. McKinley, and J. Eliot B. Moss. 1998. Type-Based Alias Analysis. In Proceedings of the ACM SIGPLAN 1998 Conference on Programming Language Design and Implementation (PLDI ’98). Association for Computing Machinery, New York, NY, USA. 106–117. isbn:0897919874 https://doi.org/10.1145/277650.277670 Google ScholarGoogle ScholarDigital LibraryDigital Library
  19. Johannes Doerfert, Tobias Grosser, and Sebastian Hack. 2017. Optimistic loop optimization. In 2017 IEEE/ACM International Symposium on Code Generation and Optimization (CGO). 292–304. Google ScholarGoogle ScholarCross RefCross Ref
  20. Paul Feautrier. 1992. Some efficient solutions to the affine scheduling problem. I. One-dimensional time. International journal of parallel programming, 21, 5 (1992), 313–347. https://doi.org/10.1007/BF01407835 Google ScholarGoogle ScholarDigital LibraryDigital Library
  21. Manel Fernández and Roger Espasa. 2002. Speculative Alias Analysis for Executable Code. In Proceedings of the 2002 International Conference on Parallel Architectures and Compilation Techniques (PACT ’02). IEEE Computer Society, USA. 222–231. isbn:0769516203 Google ScholarGoogle ScholarDigital LibraryDigital Library
  22. Ben Hardekopf and Calvin Lin. 2007. The Ant and the Grasshopper: Fast and Accurate Pointer Analysis for Millions of Lines of Code. In Proceedings of the 28th ACM SIGPLAN Conference on Programming Language Design and Implementation (PLDI ’07). Association for Computing Machinery, New York, NY, USA. 290–299. isbn:9781595936332 https://doi.org/10.1145/1250734.1250767 Google ScholarGoogle ScholarDigital LibraryDigital Library
  23. Ben Hardekopf and Calvin Lin. 2009. Semi-Sparse Flow-Sensitive Pointer Analysis. In Proceedings of the 36th Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL ’09). Association for Computing Machinery, New York, NY, USA. 226–238. isbn:9781605583792 https://doi.org/10.1145/1480881.1480911 Google ScholarGoogle ScholarDigital LibraryDigital Library
  24. Ben Hardekopf and Calvin Lin. 2011. Flow-sensitive pointer analysis for millions of lines of code. In International Symposium on Code Generation and Optimization (CGO 2011). 289–298. https://doi.org/10.1109/CGO.2011.5764696 Google ScholarGoogle ScholarCross RefCross Ref
  25. Michael Hind, Michael Burke, Paul Carini, and Jong-Deok Choi. 1999. Interprocedural Pointer Alias Analysis. ACM Trans. Program. Lang. Syst., 21, 4 (1999), July, 848–894. issn:0164-0925 https://doi.org/10.1145/325478.325519 Google ScholarGoogle ScholarDigital LibraryDigital Library
  26. A. S. Huang, G. Slavenburg, and J. P. Shen. 1994. Speculative Disambiguation: A Compilation Technique for Dynamic Memory Disambiguation. In Proceedings of the 21st Annual International Symposium on Computer Architecture (ISCA ’94). IEEE Computer Society Press, Washington, DC, USA. 200–210. isbn:0818655100 https://doi.org/10.1145/192007.192012 Google ScholarGoogle ScholarDigital LibraryDigital Library
  27. S. Jaiswal, Uday P. Khedker, and Supratik Chakraborty. 2018. Demand-driven Alias Analysis : Formalizing Bidirectional Analyses for Soundness and Precision. ArXiv, abs/1802.00932 (2018). Google ScholarGoogle Scholar
  28. Ralf Karrenberg and Sebastian Hack. 2011. Whole-Function Vectorization. In Proceedings of the 9th Annual IEEE/ACM International Symposium on Code Generation and Optimization (CGO ’11). IEEE Computer Society, USA. 141–150. isbn:9781612843568 Google ScholarGoogle ScholarDigital LibraryDigital Library
  29. W LANDI. 1992. Undecidahility of static analysis. 1992. Lett. Program. Lang. Syst, 1, 4 (1992), https://doi.org/10.1145/161494.161501 Google ScholarGoogle ScholarDigital LibraryDigital Library
  30. Chris Lattner, Andrew Lenharth, and Vikram Adve. 2007. Making Context-Sensitive Points-to Analysis with Heap Cloning Practical for the Real World. In Proceedings of the 28th ACM SIGPLAN Conference on Programming Language Design and Implementation (PLDI ’07). Association for Computing Machinery, New York, NY, USA. 278–289. isbn:9781595936332 https://doi.org/10.1145/1250734.1250766 Google ScholarGoogle ScholarDigital LibraryDigital Library
  31. Jin Lin, Tong Chen, Wei-Chung Hsu, Pen-Chung Yew, Roy Dz-Ching Ju, Tin-Fook Ngai, and Sun Chan. 2003. A Compiler Framework for Speculative Analysis and Optimizations. In Proceedings of the ACM SIGPLAN 2003 Conference on Programming Language Design and Implementation (PLDI ’03). Association for Computing Machinery, New York, NY, USA. 289–299. isbn:1581136625 https://doi.org/10.1145/781131.781164 Google ScholarGoogle ScholarDigital LibraryDigital Library
  32. Vitaliy B Lvin, Gene Novark, Emery D Berger, and Benjamin G Zorn. 2008. Archipelago: trading address space for reliability and security. ACM SIGARCH Computer Architecture News, 36, 1 (2008), 115–124. Google ScholarGoogle ScholarDigital LibraryDigital Library
  33. Dorit Naishlos. 2004. Autovectorization in GCC. In Proceedings of the 2004 GCC Developers Summit. 105–118. Google ScholarGoogle Scholar
  34. Henrique Nazaré, Izabela Maffra, Willer Santos, Leonardo Barbosa, Laure Gonnord, and Fernando Magno Quintão Pereira. 2014. Validation of Memory Accesses through Symbolic Analyses. SIGPLAN Not., 49, 10 (2014), Oct., 791–809. issn:0362-1340 https://doi.org/10.1145/2714064.2660205 Google ScholarGoogle ScholarDigital LibraryDigital Library
  35. Vitor Paisante, Maroua Maalej, Leonardo Barbosa, Laure Gonnord, and Fernando Magno Quintão Pereira. 2016. Symbolic range analysis of pointers. In 2016 IEEE/ACM International Symposium on Code Generation and Optimization (CGO). 171–181. https://doi.org/10.1145/2854038.2854050 Google ScholarGoogle ScholarDigital LibraryDigital Library
  36. David J. Pearce, Paul H.J. Kelly, and Chris Hankin. 2007. Efficient Field-Sensitive Pointer Analysis of C. ACM Trans. Program. Lang. Syst., 30, 1 (2007), Nov., 4–es. issn:0164-0925 https://doi.org/10.1145/1290520.1290524 Google ScholarGoogle ScholarDigital LibraryDigital Library
  37. Ganesan Ramalingam. 1994. The undecidability of aliasing. ACM Transactions on Programming Languages and Systems (TOPLAS), 16, 5 (1994), 1467–1471. https://doi.org/10.1145/186025.186041 Google ScholarGoogle ScholarDigital LibraryDigital Library
  38. Radu Rugina and Martin Rinard. 2000. Symbolic bounds analysis of pointers, array indices, and accessed memory regions. ACM Sigplan Notices, 35, 5 (2000), 182–195. https://doi.org/10.1145/358438.349325 Google ScholarGoogle ScholarDigital LibraryDigital Library
  39. Diogo N. Sampaio, Louis-Noël Pouchet, and Fabrice Rastello. 2017. Simplification and Runtime Resolution of Data Dependence Constraints for Loop Transformations. In Proceedings of the International Conference on Supercomputing (ICS ’17). Association for Computing Machinery, New York, NY, USA. Article 10, 11 pages. isbn:9781450350204 https://doi.org/10.1145/3079079.3079098 Google ScholarGoogle ScholarDigital LibraryDigital Library
  40. Marc Shapiro and Susan Horwitz. 1997. The Effects of the Precision of Pointer Analysis. In Proceedings of the 4th International Symposium on Static Analysis (SAS ’97). Springer-Verlag, Berlin, Heidelberg. 16–34. isbn:3540634681 Google ScholarGoogle ScholarDigital LibraryDigital Library
  41. Victor Hugo Sperle Campos, Péricles Rafael Alves, Henrique Nazaré Santos, and Fernando Magno Quintão Pereira. 2016. Restrictification of Function Arguments. In Proceedings of the 25th International Conference on Compiler Construction (CC 2016). Association for Computing Machinery, New York, NY, USA. 163–173. isbn:9781450342414 https://doi.org/10.1145/2892208.2892225 Google ScholarGoogle ScholarDigital LibraryDigital Library
  42. Bjarne Steensgaard. 1996. Points-to Analysis in Almost Linear Time. In Proceedings of the 23rd ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL ’96). Association for Computing Machinery, New York, NY, USA. 32–41. isbn:0897917693 https://doi.org/10.1145/237721.237727 Google ScholarGoogle ScholarDigital LibraryDigital Library
  43. Rishi Surendran, Rajkishore Barik, Jisheng Zhao, and Vivek Sarkar. 2014. Inter-iteration Scalar Replacement Using Array SSA Form. In CC. Google ScholarGoogle Scholar
  44. R Van Engelen. 2000. Symbolic evaluation of chains of recurrences for loop optimization. Citeseer. Google ScholarGoogle Scholar
  45. Robert A Van Engelen. 2001. Efficient symbolic analysis for optimizing compilers. In International Conference on Compiler Construction. 118–132. Google ScholarGoogle ScholarCross RefCross Ref
  46. John Whaley and Monica S Lam. 2004. Cloning-based context-sensitive pointer alias analysis using binary decision diagrams. In Proceedings of the ACM SIGPLAN 2004 conference on Programming Language Design and Implementation. 131–144. https://doi.org/10.1145/996841.996859 Google ScholarGoogle ScholarDigital LibraryDigital Library
  47. Xin Zheng and Radu Rugina. 2008. Demand-driven alias analysis for C. In Proceedings of the 35th annual ACM SIGPLAN-SIGACT symposium on Principles of programming languages. 197–208. https://doi.org/10.1145/1328897.1328464 Google ScholarGoogle ScholarDigital LibraryDigital Library
  48. Jianwen Zhu. 2005. Towards scalable flow and context sensitive pointer analysis. In Proceedings. 42nd Design Automation Conference, 2005.. 831–836. https://doi.org/10.1145/1065579.1065798 Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. The road not taken: exploring alias analysis based optimizations missed by the compiler

    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

    • Article Metrics

      • Downloads (Last 12 months)775
      • Downloads (Last 6 weeks)56

      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!