Merge "Remove sampling profile support from pgo rule"
This commit is contained in:
37
cc/pgo.go
37
cc/pgo.go
@@ -41,7 +41,6 @@ var pgoProfileProjectsConfigKey = android.NewOnceKey("PgoProfileProjects")
|
|||||||
|
|
||||||
const profileInstrumentFlag = "-fprofile-generate=/data/local/tmp"
|
const profileInstrumentFlag = "-fprofile-generate=/data/local/tmp"
|
||||||
const profileUseInstrumentFormat = "-fprofile-use=%s"
|
const profileUseInstrumentFormat = "-fprofile-use=%s"
|
||||||
const profileUseSamplingFormat = "-fprofile-sample-accurate -fprofile-sample-use=%s"
|
|
||||||
|
|
||||||
func getPgoProfileProjects(config android.DeviceConfig) []string {
|
func getPgoProfileProjects(config android.DeviceConfig) []string {
|
||||||
return config.OnceStringSlice(pgoProfileProjectsConfigKey, func() []string {
|
return config.OnceStringSlice(pgoProfileProjectsConfigKey, func() []string {
|
||||||
@@ -56,12 +55,11 @@ func recordMissingProfileFile(ctx BaseModuleContext, missing string) {
|
|||||||
type PgoProperties struct {
|
type PgoProperties struct {
|
||||||
Pgo struct {
|
Pgo struct {
|
||||||
Instrumentation *bool
|
Instrumentation *bool
|
||||||
Sampling *bool `android:"arch_variant"`
|
|
||||||
Profile_file *string `android:"arch_variant"`
|
Profile_file *string `android:"arch_variant"`
|
||||||
Benchmarks []string
|
Benchmarks []string
|
||||||
Enable_profile_use *bool `android:"arch_variant"`
|
Enable_profile_use *bool `android:"arch_variant"`
|
||||||
// Additional compiler flags to use when building this module
|
// Additional compiler flags to use when building this module
|
||||||
// for profiling (either instrumentation or sampling).
|
// for profiling.
|
||||||
Cflags []string `android:"arch_variant"`
|
Cflags []string `android:"arch_variant"`
|
||||||
} `android:"arch_variant"`
|
} `android:"arch_variant"`
|
||||||
|
|
||||||
@@ -79,10 +77,6 @@ func (props *PgoProperties) isInstrumentation() bool {
|
|||||||
return props.Pgo.Instrumentation != nil && *props.Pgo.Instrumentation == true
|
return props.Pgo.Instrumentation != nil && *props.Pgo.Instrumentation == true
|
||||||
}
|
}
|
||||||
|
|
||||||
func (props *PgoProperties) isSampling() bool {
|
|
||||||
return props.Pgo.Sampling != nil && *props.Pgo.Sampling == true
|
|
||||||
}
|
|
||||||
|
|
||||||
func (pgo *pgo) props() []interface{} {
|
func (pgo *pgo) props() []interface{} {
|
||||||
return []interface{}{&pgo.Properties}
|
return []interface{}{&pgo.Properties}
|
||||||
}
|
}
|
||||||
@@ -135,18 +129,8 @@ func (props *PgoProperties) getPgoProfileFile(ctx BaseModuleContext) android.Opt
|
|||||||
return android.OptionalPathForPath(nil)
|
return android.OptionalPathForPath(nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (props *PgoProperties) profileUseFlag(ctx ModuleContext, file string) string {
|
|
||||||
if props.isInstrumentation() {
|
|
||||||
return fmt.Sprintf(profileUseInstrumentFormat, file)
|
|
||||||
}
|
|
||||||
if props.isSampling() {
|
|
||||||
return fmt.Sprintf(profileUseSamplingFormat, file)
|
|
||||||
}
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
|
|
||||||
func (props *PgoProperties) profileUseFlags(ctx ModuleContext, file string) []string {
|
func (props *PgoProperties) profileUseFlags(ctx ModuleContext, file string) []string {
|
||||||
flags := []string{props.profileUseFlag(ctx, file)}
|
flags := []string{fmt.Sprintf(profileUseInstrumentFormat, file)}
|
||||||
flags = append(flags, profileUseOtherFlags...)
|
flags = append(flags, profileUseOtherFlags...)
|
||||||
return flags
|
return flags
|
||||||
}
|
}
|
||||||
@@ -169,19 +153,14 @@ func (props *PgoProperties) addProfileUseFlags(ctx ModuleContext, flags Flags) F
|
|||||||
// if profileFile gets updated
|
// if profileFile gets updated
|
||||||
flags.CFlagsDeps = append(flags.CFlagsDeps, profileFilePath)
|
flags.CFlagsDeps = append(flags.CFlagsDeps, profileFilePath)
|
||||||
flags.LdFlagsDeps = append(flags.LdFlagsDeps, profileFilePath)
|
flags.LdFlagsDeps = append(flags.LdFlagsDeps, profileFilePath)
|
||||||
|
|
||||||
if props.isSampling() {
|
|
||||||
flags.Local.LdFlags = append(flags.Local.LdFlags, "-Wl,-mllvm,-no-warn-sample-unused=true")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return flags
|
return flags
|
||||||
}
|
}
|
||||||
|
|
||||||
func (props *PgoProperties) isPGO(ctx BaseModuleContext) bool {
|
func (props *PgoProperties) isPGO(ctx BaseModuleContext) bool {
|
||||||
isInstrumentation := props.isInstrumentation()
|
isInstrumentation := props.isInstrumentation()
|
||||||
isSampling := props.isSampling()
|
|
||||||
|
|
||||||
profileKindPresent := isInstrumentation || isSampling
|
profileKindPresent := isInstrumentation
|
||||||
filePresent := props.Pgo.Profile_file != nil
|
filePresent := props.Pgo.Profile_file != nil
|
||||||
benchmarksPresent := len(props.Pgo.Benchmarks) > 0
|
benchmarksPresent := len(props.Pgo.Benchmarks) > 0
|
||||||
|
|
||||||
@@ -194,7 +173,7 @@ func (props *PgoProperties) isPGO(ctx BaseModuleContext) bool {
|
|||||||
if !profileKindPresent || !filePresent {
|
if !profileKindPresent || !filePresent {
|
||||||
var missing []string
|
var missing []string
|
||||||
if !profileKindPresent {
|
if !profileKindPresent {
|
||||||
missing = append(missing, "profile kind (either \"instrumentation\" or \"sampling\" property)")
|
missing = append(missing, "profile kind")
|
||||||
}
|
}
|
||||||
if !filePresent {
|
if !filePresent {
|
||||||
missing = append(missing, "profile_file property")
|
missing = append(missing, "profile_file property")
|
||||||
@@ -208,14 +187,6 @@ func (props *PgoProperties) isPGO(ctx BaseModuleContext) bool {
|
|||||||
ctx.ModuleErrorf("Instrumentation PGO specification is missing benchmark property")
|
ctx.ModuleErrorf("Instrumentation PGO specification is missing benchmark property")
|
||||||
}
|
}
|
||||||
|
|
||||||
if isSampling {
|
|
||||||
ctx.ModuleErrorf("Sampling PGO is deprecated, use AFDO instead")
|
|
||||||
}
|
|
||||||
|
|
||||||
if isSampling && isInstrumentation {
|
|
||||||
ctx.PropertyErrorf("pgo", "Exactly one of \"instrumentation\" and \"sampling\" properties must be set")
|
|
||||||
}
|
|
||||||
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user