diff options
author | 2024-06-06 03:05:04 +0900 | |
---|---|---|
committer | 2024-06-06 15:01:59 +0900 | |
commit | 2cd77d671c365df0c24f867532e67b13ebae5904 (patch) | |
tree | 1e9dc60f1a7f71387475cd2b9acb52ff8151a747 | |
parent | 5786f5cf1df41f3e536bebe1140465b510d85fb9 (diff) |
Enable MLGO inliner optimization for optimize_for_size cases
This helps reduce binary size for these projects by ~3%.
Test: presubmit
Bug: 342090838
Change-Id: Ie1e0586ddf5f40aa1e81fc2628a6499093de9699
-rw-r--r-- | cc/compiler.go | 1 | ||||
-rw-r--r-- | cc/lto.go | 2 |
2 files changed, 2 insertions, 1 deletions
diff --git a/cc/compiler.go b/cc/compiler.go index d13cd9506..83080fd72 100644 --- a/cc/compiler.go +++ b/cc/compiler.go @@ -695,6 +695,7 @@ func (compiler *baseCompiler) compilerFlags(ctx ModuleContext, flags Flags, deps if ctx.optimizeForSize() { flags.Local.CFlags = append(flags.Local.CFlags, "-Oz") + flags.Local.LdFlags = append(flags.Local.LdFlags, "-Wl,-mllvm,-enable-ml-inliner=release") } // Exclude directories from manual binder interface allowed list. @@ -144,7 +144,7 @@ func (lto *lto) flags(ctx ModuleContext, flags Flags) Flags { if !ctx.Config().IsEnvFalse("THINLTO_USE_MLGO") { // Register allocation MLGO flags for ARM64. - if ctx.Arch().ArchType == android.Arm64 { + if ctx.Arch().ArchType == android.Arm64 && !ctx.optimizeForSize() { ltoLdFlags = append(ltoLdFlags, "-Wl,-mllvm,-regalloc-enable-advisor=release") } // Flags for training MLGO model. |