Remove fdoProfileMutator

Add the dependency on the fdo_profile module in afdoTransitionMutator
and read the provider in GenerateAndroidBuildActions.

This relands Ied8fd7b52d5694a3691652318e87b8fe14dda126 with a fix
to use the correct LTO ldflag when an afdo variant doesn't have a
profile.

Bug: 319288033
Bug: 324141705
Test: afdo_test.go
Change-Id: I024ca316cfb565b5fb0251793f05a54ce16cc1cb
This commit is contained in:
Colin Cross
2024-01-24 14:44:47 -08:00
parent d38feb0d4a
commit 3513fb17cd
4 changed files with 51 additions and 93 deletions

View File

@@ -100,7 +100,7 @@ func (lto *lto) begin(ctx BaseModuleContext) {
lto.Properties.LtoEnabled = ltoEnabled
}
func (lto *lto) flags(ctx BaseModuleContext, flags Flags) Flags {
func (lto *lto) flags(ctx ModuleContext, flags Flags) Flags {
// TODO(b/131771163): CFI and Fuzzer controls LTO flags by themselves.
// This has be checked late because these properties can be mutated.
if ctx.isCfi() || ctx.isFuzzer() {
@@ -139,7 +139,7 @@ func (lto *lto) flags(ctx BaseModuleContext, flags Flags) Flags {
// Reduce the inlining threshold for a better balance of binary size and
// performance.
if !ctx.Darwin() {
if ctx.isAfdoCompile() {
if ctx.isAfdoCompile(ctx) {
ltoLdFlags = append(ltoLdFlags, "-Wl,-plugin-opt,-import-instr-limit=40")
} else {
ltoLdFlags = append(ltoLdFlags, "-Wl,-plugin-opt,-import-instr-limit=5")