Lune

OOPSLA2026Top-tier venue

A New Approach to Optimal Function Inlining for Code Size Minimization via E-graphs

Amir K. Goharshady, Chun Kit Lam, Andreas Pavlogiannis, Ahmed Khaled Zaher

Abstract

Minimizing code size is a central problem in compiler optimization, especially in the context of embedded systems and mobile applications. One of the classical optimizations that has recently been adopted to reduce the output code size is function inlining, i.e. repeatedly replacing a function call site by the body of the called function. At first glance, the fact that inlining can help reduce code size is counter-intuitive. However, it enables two types of subsequent optimizations which can affect the code size significantly: (i) the intra-procedural optimizations performed within each function, which make use of the additional context provided by inlining, and (ii) the elimination of dead functions. Many existing heuristics, such as those used by LLVM, focus on a local size analysis based on a few call sites. Thus, they miss the global opportunities to remove dead functions. On the other hand, the current state-of-the-art approach of auto-tuning by Theodoridis et al. [ASPLOS 2022] focuses on global code size but inspects each call site independently in order to avoid a combinatorial explosion. However, inlining decisions are not independent in practice. It is possible that two inlining choices each increase code size on their own, but applying both of them together reduces the size.

In this work, we show that the problem of optimal inlining for code size minimization is NP-hard. We then present a completely different approach to this problem. Our algorithm is based on equality graphs (e-graphs), which are a standard tool in automated theorem proving and have recently been adopted by the compiler optimization community as a key ingredient in equality saturation. We show that optimal function inlining can be reduced to e-graph extraction. Although e-graph extraction is also NP-hard, there are efficient solvers that can handle sparse instances of this problem [OOPSLA 2024]. We build upon these solvers and add further inlining-specific heuristics to design an algorithm for code size reduction.

Finally, we present experimental results on the standard SPEC benchmarks. Compared with LLVM, our approach reduces the code size to 95.34%. This is competitive with the state-of-the-art auto-tuning method of [ASPLOS 2022], which achieves 95.24%. In terms of running time, our approach is 20x faster than auto-tuning. More importantly, due to the two methods having orthogonal strengths, applying both of them leads to a further significant improvement, reducing the code size to 93.94% of LLVM's output.

Ask Lune

Know this paper in minutes, not an afternoon.

Lune can read every page of it and the top-tier papers that cite it, and gives you its claims, its evidence and its limits, each one cited to the paper it comes from. No skimming, no AI slop.

Questions to start from

Lune can draw on

the full paper · related work

Get the answer

Free to start. No credit card required.

Lineage

  • Fast and Optimal Extraction for Sparse Equality Graphs cites Semantic code search via equational reasoning
  • Fast and Optimal Extraction for Sparse Equality Graphs cites Rewrite rule inference using equality saturation
  • Rewrite rule inference using equality saturation cites Semantic code search via equational reasoning
Builds onCited byLeft to right by year; the more cited, the higher.

Builds on4

  1. Semantic code search via equational reasoningVarot Premtoon, James Koppel, Armando Solar-LezamaPLDI 2020 · 49 citations
  2. Rewrite rule inference using equality saturationChandrakana Nandi, Max Willsey, Amy Zhu, Yisu Remy Wang et al.OOPSLA 2021 · 35 citations
  3. Understanding and exploiting optimal function inliningTheodoros Theodoridis, Tobias Grosser, Zhendong SuASPLOS 2022 · 26 citations
  4. Fast and Optimal Extraction for Sparse Equality GraphsAmir Kafshdar Goharshady, Chun Kit Lam, Lionel ParreauxOOPSLA 2024 · 11 citations

Related papers

  1. Parameterized Algorithms and Complexity for Function Merging with Branch ReorderingAmir Kafshdar Goharshady, Kerim Kochekov, Tian Shu, Ahmed Khaled ZaherPLDI 2026
  2. Effective function merging in the SSA formRodrigo C. O. Rocha, Pavlos Petoumenos, Zheng Wang, Murray Cole et al.PLDI 2020 · 29 citations
  3. Modern Llvm-Based Compiler Autotuning for Wcet OptimizationGabriele Magnani, Davide Baroffio, Federico Reghenzani, Giovanni Agosta et al.RTSS 2025 · 1 citation
  4. Guided linking: dynamic linking without the costsSean Bartell, Will Dietz, Vikram S. AdveOOPSLA 2020 · 4 citations
  5. A Deep Dive into Function Inlining and its Security Implications for ML-based Binary AnalysisOmar Abusabha, Jiyong Uhm, Tamer Abuhmed, Hyungjoon KooNDSS 2026 · 3 citations
Dusk over the sea between two cliffs drawn in fine vertical lines