Inlining for Code Size Reduction
Resumo
Function inlining is a compiler optimization that replaces the call of a function with its body. Inlining is typically seen as an optimization that improves performance at the expenses of increasing code size. This paper goes against this intuition, and shows that inlining can be employed, in specific situations, as a way to reduce code size. Towards this end, we bring forward two results. First, we gauge the benefits of a trivial heuristic for code-size reduction: the inlining of functions that are invoked at only one call site in the program, followed by the elimination of the original callee. Second, we present and evaluate an analysis that identifies call sites where inlining enables context-sensitive optimizations that reduce code. We have implemented all these techniques in the LLVM compilation infrastructure. When applied onto MiBench, our inlining heuristics yield an average code size reduction of 2.96%, reaching 11% in the best case, over clang -Os. Moreover, our techniques preserve the performance gains of LLVM’s standard inlining decisions on MiBench: there is no statistically significant difference in the running time of code produced by these different approaches.
Publicado
30/09/2021
Como Citar
DAMÁSIO, Thaís; PACHECO, Vinícius; GOES, Fabrício; PEREIRA, Fernando; ROCHA, Rodrigo.
Inlining for Code Size Reduction. In: SIMPÓSIO BRASILEIRO DE LINGUAGENS DE PROGRAMAÇÃO (SBLP), 25. , 2021, Joinville.
Anais [...].
Porto Alegre: Sociedade Brasileira de Computação,
2021
.
p. 17–24.