Merge changes I90df9c04,I70bb8dc2

* changes:
  [pgo] Allow profile gather and use flags to coexist for sampling PGO
  [pgo] Sampling PGO does not require benchmark property
This commit is contained in:
Yi Kong 2020-07-22 00:46:42 +00:00 committed by Gerrit Code Review
commit f9a78248b0

View file

@ -199,8 +199,8 @@ func (props *PgoProperties) isPGO(ctx BaseModuleContext) bool {
return false
}
// If at least one property exists, validate that all properties exist
if !profileKindPresent || !filePresent || !benchmarksPresent {
// profileKindPresent and filePresent are mandatory properties.
if !profileKindPresent || !filePresent {
var missing []string
if !profileKindPresent {
missing = append(missing, "profile kind (either \"instrumentation\" or \"sampling\" property)")
@ -208,13 +208,15 @@ func (props *PgoProperties) isPGO(ctx BaseModuleContext) bool {
if !filePresent {
missing = append(missing, "profile_file property")
}
if !benchmarksPresent {
missing = append(missing, "non-empty benchmarks property")
}
missingProps := strings.Join(missing, ", ")
ctx.ModuleErrorf("PGO specification is missing properties: " + missingProps)
}
// Benchmark property is mandatory for instrumentation PGO.
if isInstrumentation && !benchmarksPresent {
ctx.ModuleErrorf("Instrumentation PGO specification is missing benchmark property")
}
if isSampling && isInstrumentation {
ctx.PropertyErrorf("pgo", "Exactly one of \"instrumentation\" and \"sampling\" properties must be set")
}
@ -288,15 +290,17 @@ func (pgo *pgo) flags(ctx ModuleContext, flags Flags) Flags {
// Add flags to profile this module based on its profile_kind
if props.ShouldProfileModule && props.isInstrumentation() {
return props.addInstrumentationProfileGatherFlags(ctx, flags)
props.addInstrumentationProfileGatherFlags(ctx, flags)
// Instrumentation PGO use and gather flags cannot coexist.
return flags
} else if props.ShouldProfileModule && props.isSampling() {
return props.addSamplingProfileGatherFlags(ctx, flags)
props.addSamplingProfileGatherFlags(ctx, flags)
} else if ctx.DeviceConfig().SamplingPGO() {
return props.addSamplingProfileGatherFlags(ctx, flags)
props.addSamplingProfileGatherFlags(ctx, flags)
}
if !ctx.Config().IsEnvTrue("ANDROID_PGO_NO_PROFILE_USE") {
return props.addProfileUseFlags(ctx, flags)
props.addProfileUseFlags(ctx, flags)
}
return flags