diff --git a/cc/lto.go b/cc/lto.go index fb3b485b6..ad1a1b1cf 100644 --- a/cc/lto.go +++ b/cc/lto.go @@ -147,10 +147,12 @@ func (lto *lto) flags(ctx BaseModuleContext, flags Flags) Flags { } } - // 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") + if !ctx.Config().IsEnvFalse("THINLTO_USE_MLGO") { + // 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")