Merge "Limit LTO inlining even when profile is present" into main am: 3ff50d5854

Original change: https://android-review.googlesource.com/c/platform/build/soong/+/2684608

Change-Id: I151f593df6cdc050135125b63a48652da633e03e
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Treehugger Robot
2023-08-02 22:44:38 +00:00
committed by Automerger Merge Worker

View File

@@ -135,11 +135,15 @@ func (lto *lto) flags(ctx BaseModuleContext, flags Flags) Flags {
ltoLdFlags = append(ltoLdFlags, cachePolicyFormat+policy)
}
// If the module does not have a profile, be conservative and limit cross TU inline
// limit to 5 LLVM IR instructions, to balance binary size increase and performance.
if !ctx.Darwin() && !ctx.isPgoCompile() && !ctx.isAfdoCompile() {
// Reduce the inlining threshold for a better balance of binary size and
// performance.
if !ctx.Darwin() {
if ctx.isPgoCompile() || ctx.isAfdoCompile() {
ltoLdFlags = append(ltoLdFlags, "-Wl,-plugin-opt,-import-instr-limit=40")
} else {
ltoLdFlags = append(ltoLdFlags, "-Wl,-plugin-opt,-import-instr-limit=5")
}
}
flags.Local.CFlags = append(flags.Local.CFlags, ltoCFlags...)
flags.Local.AsFlags = append(flags.Local.AsFlags, ltoCFlags...)