Disable inlining and loop unrolling in LTO without PGO profile

Such optimisations may significantly increase the binary size when
compiler heuristics are off. Disabling these helps cut down the
binary sizes with negligible decrease in performance, but allows us to
be more comfortable enabling LTO across various projects.

Test: m
Test: dex2oat, hwui, skia benchmark
Bug: 62839002
Change-Id: Id63e8dd295df2972f76ae4e29ee367080fff8429
diff --git a/cc/pgo.go b/cc/pgo.go
index 1e70339..779ef39 100644
--- a/cc/pgo.go
+++ b/cc/pgo.go
@@ -45,7 +45,7 @@
 	})
 }
 
-func recordMissingProfileFile(ctx ModuleContext, missing string) {
+func recordMissingProfileFile(ctx BaseModuleContext, missing string) {
 	getNamedMapForConfig(ctx.Config(), modulesMissingProfileFile).Store(missing, true)
 }
 
@@ -63,6 +63,7 @@
 
 	PgoPresent          bool `blueprint:"mutated"`
 	ShouldProfileModule bool `blueprint:"mutated"`
+	PgoCompile          bool `blueprint:"mutated"`
 }
 
 type pgo struct {
@@ -98,7 +99,7 @@
 	return flags
 }
 
-func (props *PgoProperties) getPgoProfileFile(ctx ModuleContext) android.OptionalPath {
+func (props *PgoProperties) getPgoProfileFile(ctx BaseModuleContext) android.OptionalPath {
 	// Test if the profile_file is present in any of the PGO profile projects
 	for _, profileProject := range getPgoProfileProjects(ctx.DeviceConfig()) {
 		path := android.ExistentPathForSource(ctx, "", profileProject, *props.Pgo.Profile_file)
@@ -232,6 +233,12 @@
 			}
 		}
 	}
+
+	if !ctx.Config().IsEnvTrue("ANDROID_PGO_NO_PROFILE_USE") {
+		if profileFile := pgo.Properties.getPgoProfileFile(ctx); profileFile.Valid() {
+			pgo.Properties.PgoCompile = true
+		}
+	}
 }
 
 func (pgo *pgo) deps(ctx BaseModuleContext, deps Deps) Deps {