Add -fprofile-sample-accurate flag for sampling PGO
This flag indicates that the sample profile data matches the source
and can be fully trusted. The compiler will make aggressive
assumption that functions without any samples are cold functions,
and will optimize for size for them.
Test: binary size reduces to match instr PGO
Bug: 79161490
Change-Id: I53d6d05be70c39e5eb28b2f5b0549d9eb6b5cc62
diff --git a/cc/pgo.go b/cc/pgo.go
index 6c39d83..8eb3400 100644
--- a/cc/pgo.go
+++ b/cc/pgo.go
@@ -43,7 +43,7 @@
const profileInstrumentFlag = "-fprofile-generate=/data/local/tmp"
const profileSamplingFlag = "-gmlt -fdebug-info-for-profiling"
const profileUseInstrumentFormat = "-fprofile-use=%s"
-const profileUseSamplingFormat = "-fprofile-sample-use=%s"
+const profileUseSamplingFormat = "-fprofile-sample-accurate -fprofile-sample-use=%s"
func getPgoProfileProjects(config android.DeviceConfig) []string {
return config.OnceStringSlice(pgoProfileProjectsConfigKey, func() []string {