  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.
