From 6aeed8b4392eb75412f44f6b54d7504c8319e7d3 Mon Sep 17 00:00:00 2001 From: Pirama Arumuga Nainar Date: Mon, 16 Oct 2017 13:31:40 -0700 Subject: [PATCH] Add enable_profile_use property Bug: http://b/65598278 This property defaults to 'true' and setting it to false skips profile use. This escape hatch lets us disable PGO for a module without completely removing the 'pgo' property. Additionally, this also helps selectively disabling PGO for some architectures, if desired. Test: Test that -fprofile-use is not added for a test module if 'enable_profile_use: false' is set. Change-Id: Ifcf1a48c194bc86efd88a529cc2d66a47b7ab080 --- cc/pgo.go | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/cc/pgo.go b/cc/pgo.go index c5e4e86fd..ea23124cf 100644 --- a/cc/pgo.go +++ b/cc/pgo.go @@ -37,10 +37,11 @@ const profileUseSamplingFormat = "-fprofile-sample-use=%s" type PgoProperties struct { Pgo struct { - Instrumentation *bool - Sampling *bool - Profile_file *string `android:"arch_variant"` - Benchmarks []string + Instrumentation *bool + Sampling *bool + Profile_file *string `android:"arch_variant"` + Benchmarks []string + Enable_profile_use *bool `android:"arch_variant"` } `android:"arch_variant"` PgoPresent bool `blueprint:"mutated"` @@ -95,6 +96,11 @@ func (props *PgoProperties) profileUseFlags(ctx ModuleContext, file string) []st } func (props *PgoProperties) addProfileUseFlags(ctx ModuleContext, flags Flags) Flags { + // Skip -fprofile-use if 'enable_profile_use' property is set + if props.Pgo.Enable_profile_use != nil && *props.Pgo.Enable_profile_use == false { + return flags + } + // If the PGO profiles project is found, and this module has PGO // enabled, add flags to use the profile if profilesDir := getPgoProfilesDir(ctx); props.PgoPresent && profilesDir.Valid() {