Papers
Topics
Authors
Recent
Search
2000 character limit reached

Optimistic Global Function Merger

Published 6 Dec 2023 in cs.PL | (2312.03214v1)

Abstract: Function merging is a pivotal technique for reducing code size by combining identical or similar functions into a single function. While prior research has extensively explored this technique, it has not been assessed in conjunction with function outlining and linker's identical code folding, despite substantial common ground. The traditional approaches necessitate the complete intermediate representation to compare functions. Consequently, none of these approaches offer a scalable solution compatible with separate compilations while achieving global function merging, which is critical for large app development. In this paper, we introduce our global function merger, leveraging global merge information from previous code generation runs to optimistically create merging instances within each module context independently. Notably, our approach remains sound even when intermediate representations change, making it well-suited for distributed build environments. We present a comprehensive code generation framework that can run both the state-of-the-art global function outliner and our global function merger. These components complement each other, resulting in a positive impact on code size reduction. Our evaluation demonstrates that when integrating the global function merger with a state-of-the-art global function outliner that is fully optimized with ThinLTO, a further reduction of up to 3.5% in code size can be attained. This is in addition to the initial average reduction of 17.3% achieved through global function outlining for real-world iOS apps, all with minimal extra build time.

Definition Search Book Streamline Icon: https://streamlinehq.com
References (35)
  1. J. Michael Ashley. 1997. The Effectiveness of Flow Analysis for Inlining. SIGPLAN Not. 32, 8 (aug 1997), 99–111. https://doi.org/10.1145/258949.258959
  2. Survey of Code-Size Reduction Methods. ACM Comput. Surv. 35, 3 (sep 2003), 223–267. https://doi.org/10.1145/937503.937504
  3. An Experience with Code-Size Optimization for Production IOS Mobile Applications. In Proceedings of the 2021 IEEE/ACM International Symposium on Code Generation and Optimization (Virtual Event, Republic of Korea) (CGO ’21). IEEE Press, 363–366. https://doi.org/10.1109/CGO51591.2021.9370306
  4. AutoFDO: Automatic feedback-directed optimization for warehouse-scale applications. In 2016 IEEE/ACM International Symposium on Code Generation and Optimization (CGO). 12–23.
  5. John Cocke. 1970. Global Common Subexpression Elimination. SIGPLAN Not. 5, 7 (jul 1970), 20–24. https://doi.org/10.1145/390013.808480
  6. Large Language Models for Compiler Optimization. arXiv:2309.07062 [cs.PL]
  7. Optimistic Loop Optimization. In Proceedings of the 2017 International Symposium on Code Generation and Optimization (Austin, USA) (CGO ’17). IEEE Press, 292–304.
  8. dwarfstd.org. 2009. DWARF Extensions for Unwinding Across Merged Functions. https://wiki.dwarfstd.org/ICF.md
  9. Exploiting Function Similarity for Code Size Reduction. SIGPLAN Not. 49, 5 (jun 2014), 85–94. https://doi.org/10.1145/2666357.2597811
  10. ComPile: A Large IR Dataset from Production Sources. arXiv:2309.15432 [cs.PL]
  11. Optimizing Function Layout for Mobile Applications. In Proceedings of the 24th ACM SIGPLAN/SIGBED International Conference on Languages, Compilers, and Tools for Embedded Systems (Orlando, FL, USA) (LCTES 2023). Association for Computing Machinery, New York, NY, USA, 52–63. https://doi.org/10.1145/3589610.3596277
  12. The LLVM Compiler Infrastructure. 2020. MergeFunctions pass, how it works. https://llvm.org/docs/MergeFunctions.html
  13. ThinLTO: Scalable and Incremental LTO. In Proceedings of the 2017 International Symposium on Code Generation and Optimization (Austin, USA) (CGO ’17). IEEE Press, 111–121.
  14. Partial Redundancy Elimination in SSA Form. ACM Trans. Program. Lang. Syst. 21, 3 (may 1999), 627–676. https://doi.org/10.1145/319301.319348
  15. Partial Dead Code Elimination. SIGPLAN Not. 29, 6 (jun 1994), 147–158. https://doi.org/10.1145/773473.178256
  16. Efficient Profile-Guided Size Optimization for Native Mobile Applications. In Proceedings of the 31st ACM SIGPLAN International Conference on Compiler Construction (Seoul, South Korea) (CC 2022). Association for Computing Machinery, New York, NY, USA, 243–253. https://doi.org/10.1145/3497776.3517764
  17. Scalable Size Inliner for Mobile Applications (WIP). In Proceedings of the 23rd ACM SIGPLAN/SIGBED International Conference on Languages, Compilers, and Tools for Embedded Systems (San Diego, CA, USA) (LCTES 2022). Association for Computing Machinery, New York, NY, USA, 116–120. https://doi.org/10.1145/3519941.3535074
  18. Arm Limited. 2021. Arm A64 Instruction Set Architecture. https://developer.arm.com/documentation/ddi0596/2021-09
  19. Linker code size optimization for native mobile applications. In International Conference on Compiler Construction. ACM, New York, NY, USA, 168–179. https://doi.org/10.1145/3578360.3580256
  20. Meta. 2022. ComponentKit and ComponentUI. https://www.internalfb.com/intern/staticdocs/componentkit/
  21. Practical Automatic Loop Specialization. SIGARCH Comput. Archit. News 41, 1 (mar 2013), 419–430. https://doi.org/10.1145/2490301.2451161
  22. Guilherme Ottoni and Bertrand Maher. 2017. Optimizing function placement for large-scale data-center applications. In 2017 IEEE/ACM International Symposium on Code Generation and Optimization (CGO). 233–244. https://doi.org/10.1109/CGO.2017.7863743
  23. BOLT: A Practical Binary Optimizer for Data Centers and Beyond. In 2019 IEEE/ACM International Symposium on Code Generation and Optimization (CGO). 2–14. https://doi.org/10.1109/CGO.2019.8661201
  24. Jessica Paquette. 2016. Reducing Code Size Using Outling. https://llvm.org/devmtg/2016-11/Slides/Paquette-Outliner.pdf
  25. Peter Reinhardt. 2016. Effect of Mobile App Size on Downloads. https://segment.com/blog/mobile-app-size-effect-on-downloads/
  26. HyFM: Function Merging for Free. In Proceedings of the 22nd ACM SIGPLAN/SIGBED International Conference on Languages, Compilers, and Tools for Embedded Systems (Virtual, Canada) (LCTES 2021). Association for Computing Machinery, New York, 110–121. https://doi.org/10.1145/3461648.3463852
  27. Function Merging by Sequence Alignment. In 2019 IEEE/ACM International Symposium on Code Generation and Optimization (CGO). 149–163. https://doi.org/10.1109/CGO.2019.8661174
  28. Effective Function Merging in the SSA Form. In Proceedings of the 41st ACM SIGPLAN Conference on Programming Language Design and Implementation (London, UK) (PLDI 2020). Association for Computing Machinery, New York, NY, USA, 854–868. https://doi.org/10.1145/3385412.3386030
  29. HyBF: A Hybrid Branch Fusion Strategy for Code Size Reduction. In Proceedings of the 32nd ACM SIGPLAN International Conference on Compiler Construction (Montréal, QC, Canada) (CC 2023). Association for Computing Machinery, New York, NY, USA, 156–167. https://doi.org/10.1145/3578360.3580267
  30. Propeller: A Profile Guided, Relinking Optimizer for Warehouse-Scale Applications. In Proceedings of the 28th ACM International Conference on Architectural Support for Programming Languages and Operating Systems, Volume 2 (Vancouver, BC, Canada) (ASPLOS 2023). Association for Computing Machinery, New York, NY, USA, 617–631. https://doi.org/10.1145/3575693.3575727
  31. Standard Performance Evaluation Corporation (SPEC) 2017. SPEC CPU 2017 Benchmark Suite. Standard Performance Evaluation Corporation (SPEC). https://www.spec.org/cpu2017/
  32. swift.org. 2023. Merge similar functions for swift. https://github.com/apple/swift/blob/main/lib/LLVMPasses/LLVMMergeFunctions.cpp
  33. Safe ICF: Pointer Safe and Unwinding aware Identical Code Folding in the Gold Linker. https://static.googleusercontent.com/media/research.google.com/en//pubs/archive/36912.pdf
  34. MLGO: a Machine Learning Guided Compiler Optimizations Framework. CoRR abs/2101.04808 (2021). arXiv:2101.04808 https://arxiv.org/abs/2101.04808
  35. Mark N. Wegman and F. Kenneth Zadeck. 1991. Constant Propagation with Conditional Branches. ACM Trans. Program. Lang. Syst. 13, 2 (apr 1991), 181–210. https://doi.org/10.1145/103135.103136

Summary

Whiteboard

No one has generated a whiteboard explanation for this paper yet.

Open Problems

We haven't generated a list of open problems mentioned in this paper yet.

Continue Learning

We haven't generated follow-up questions for this paper yet.

Authors (3)

Collections

Sign up for free to add this paper to one or more collections.