Merge "Only enable MLGO for ARM64 ThinLTO targets" into main am: 6a8eb37d90

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

Change-Id: I7e49577418fdf4f564534f73b15e064318585df2
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Treehugger Robot
2023-11-08 03:32:00 +00:00
committed by Automerger Merge Worker
2 changed files with 9 additions and 9 deletions

View File

@@ -174,9 +174,6 @@ var (
"-Werror=format-security",
"-nostdlibinc",
// Enable MLGO for register allocation.
"-mllvm -regalloc-enable-advisor=release",
// Emit additional debug info for AutoFDO
"-fdebug-info-for-profiling",
}
@@ -205,8 +202,6 @@ var (
"-Wl,--exclude-libs,libgcc_stripped.a",
"-Wl,--exclude-libs,libunwind_llvm.a",
"-Wl,--exclude-libs,libunwind.a",
// Enable MLGO for register allocation.
"-Wl,-mllvm,-regalloc-enable-advisor=release",
}
deviceGlobalLldflags = append(append(deviceGlobalLdflags, commonGlobalLldflags...),

View File

@@ -147,10 +147,15 @@ func (lto *lto) flags(ctx BaseModuleContext, flags Flags) Flags {
}
}
// For ML training
if ctx.Config().IsEnvTrue("THINLTO_EMIT_INDEXES_AND_IMPORTS") {
ltoLdFlags = append(ltoLdFlags, "-Wl,--save-temps=import")
ltoLdFlags = append(ltoLdFlags, "-Wl,--thinlto-emit-index-files")
// Register allocation MLGO flags for ARM64.
if ctx.Arch().ArchType == android.Arm64 {
ltoCFlags = append(ltoCFlags, "-mllvm -regalloc-enable-advisor=release")
ltoLdFlags = append(ltoLdFlags, "-Wl,-mllvm,-regalloc-enable-advisor=release")
// Flags for training MLGO model.
if ctx.Config().IsEnvTrue("THINLTO_EMIT_INDEXES_AND_IMPORTS") {
ltoLdFlags = append(ltoLdFlags, "-Wl,--save-temps=import")
ltoLdFlags = append(ltoLdFlags, "-Wl,--thinlto-emit-index-files")
}
}
flags.Local.CFlags = append(flags.Local.CFlags, ltoCFlags...)