<
 
Academy & Industry Research Collaboration Center (AIRCC)

Volume 12, Number 06, March 2022

Mutual Inlining: An Inlining Algorithm to Reduce the Executable Size

  Authors

Yosi Ben-Asher1, Nidal Faour2 and Ofer Shinaar2, 1Western Digital Tefen and The University of Haifa CS, Israel 2Western Digital Tefen, Israel

  Abstract

We consider the problem of selecting an optimized subset of inlinings (replacing a call to a function by its body) that minimize the resulting code size. Frequently, in embedded systems, the program’s executable file size must fit into a small size memory. In such cases, the compiler should generate as small as possible executables. In particular, we seek to improve the code size obtained by the LLVM inliner executed with the -Oz option. One important aspect is whether or not this problem requires a global solution that considers the full span of the call graph or a local solution (as is the case with the LLVM inliner) that decides whether to apply inlining to each call separately based on the expected code-size improvement. We have implemented a global type of inlining algorithm called Mutual Inlining that selects the next call-site (f()callsg() to be inline based on its global properties. The first property is the number of calls to g(). Next property is determining if inlining g() to f() may prevent inlining other more beneficial neighboring callsites. Finaly repeated inlining iterations over the call graph are performed until there are no more beneficial inlinings to perform. Hence, considering the effect of previously made inlinings on the next call-site to be inline. Our results show small but consistant improvement compare to LLVM’s Oz.