2 ms·
With LTO the compiler should be free to fudge the calling convention for most calls even between translation units. Here is GCC doing that optimization for a s
by account42 5y ago
With LTO the compiler should be free to fudge the calling convention for most calls even between translation units.
Here is GCC doing that optimization for a static noinline function: https://godbolt.org/z/cn6Wz9Kvn https://godbolt.org/z/cn6Wz9Kvn
Similarly, compilers can also clone functions if it makes sense to propagate constants from call sites into the function. Example: https://godbolt.org/z/59z6xT75n https://godbolt.org/z/59z6xT75n
I'm sure there is more room for improvement. A perfect compiler would always optimized programs as a whole and only regard function boundaries as hints at best. In practice, you have to keep complexity in check somehow.