Bug 1592981 - Use -import-instr-limit to mitigate size growth from ThinLTO r=froydnj

When we first enabled ThinLTO on our builds, we got great performance gains, but also large size increases due to aggressive inlining. There is an LLVM option called -import-instr-limit that limits the size of functions that may be imported (the threshold is subject to modification by PGO). Chromium found a good balance between speed and performance by using a value of 10. In initial testing, on Windows and Linux that value can save us many megabytes from libxul without noticeable speed regressions. For Mac, which doesn't yet have PGO, we have to use a higher limit to avoid over-restricting the optimizer which caused slowdowns on my try pushes.

Differential Revision: https://phabricator.services.mozilla.com/D51463

--HG--
extra : moz-landing-system : lando
This commit is contained in:
David Major 2019-11-04 15:58:54 +00:00
parent d93b9de014
commit 896094e44a

View File

@ -234,6 +234,17 @@ def lto(value, c_compiler, ld64_known_good, target):
ldflags.append("-flto=%s" % num_cores)
ldflags.append("-flifetime-dse=1")
# Tell LTO not to inline functions above a certain size, to mitigate
# binary size growth while still getting good performance.
# (For hot functions, PGO will put a multiplier on this limit.)
if target.os == 'WINNT':
ldflags.append('-mllvm:-import-instr-limit=10');
elif target.os == 'OSX':
# Until OSX gets PGO, too small of a limit will cause slowdowns.
ldflags.append('-Wl,-mllvm,-import-instr-limit=40');
else:
ldflags.append('-Wl,-plugin-opt=-import-instr-limit=10');
return namespace(
enabled=enabled,
cflags=cflags,