Separate out PGO profile files per arch

Bug: http://b/78259283

Specify separate PGO profiles for AArch64/ARM and x86_64/x86.  This
allows per-arch profile collection that exercises ART's code generation
for the corresponding 32-bit and 64-bit ABIs.

Test: Build Sailfish and x86_64 targets and verify that corresponding
profile files are read.

Change-Id: Iad3a657411676952de5ed446db4dd4e754ea9e11
diff --git a/compiler/Android.bp b/compiler/Android.bp
index cde64b0..ec9fef7 100644
--- a/compiler/Android.bp
+++ b/compiler/Android.bp
@@ -210,7 +210,10 @@
 
 art_cc_library {
     name: "libart-compiler",
-    defaults: ["libart-compiler-defaults"],
+    defaults: [
+        "libart-compiler-defaults",
+        "dex2oat-pgo-defaults",
+    ],
     codegen: {
         arm: {
             // VIXL assembly support for ARM targets.
@@ -244,11 +247,6 @@
         "libdexfile",
     ],
 
-    pgo: {
-        instrumentation: true,
-        profile_file: "art/dex2oat.profdata",
-        benchmarks: ["dex2oat"],
-    },
     target: {
         android: {
             lto: {
diff --git a/dex2oat/Android.bp b/dex2oat/Android.bp
index 49b65fd..5d3bc4f 100644
--- a/dex2oat/Android.bp
+++ b/dex2oat/Android.bp
@@ -149,10 +149,41 @@
     ],
 }
 
+cc_defaults {
+    name: "dex2oat-pgo-defaults",
+    pgo: {
+        instrumentation: true,
+        benchmarks: ["dex2oat"],
+    },
+    target: {
+        android_arm64: {
+            pgo: {
+                profile_file: "art/dex2oat_arm_arm64.profdata",
+            },
+        },
+        android_arm: {
+            pgo: {
+                profile_file: "art/dex2oat_arm_arm64.profdata",
+            },
+        },
+        android_x86_64: {
+            pgo: {
+                profile_file: "art/dex2oat_x86_x86_64.profdata",
+            },
+        },
+        android_x86: {
+            pgo: {
+                profile_file: "art/dex2oat_x86_x86_64.profdata",
+            },
+        },
+    },
+}
+
 art_cc_binary {
     name: "dex2oat",
     defaults: [
         "dex2oat-defaults",
+        "dex2oat-pgo-defaults",
     ],
     shared_libs: [
         "libart-compiler",
@@ -168,9 +199,7 @@
     ],
 
     pgo: {
-        instrumentation: true,
-        profile_file: "art/dex2oat.profdata",
-        benchmarks: ["dex2oat"],
+        // Additional cflags just for dex2oat during PGO instrumentation
         cflags: [
             // Ignore frame-size increase resulting from instrumentation.
             "-Wno-frame-larger-than=",
diff --git a/dexlayout/Android.bp b/dexlayout/Android.bp
index facda11..33ba58f 100644
--- a/dexlayout/Android.bp
+++ b/dexlayout/Android.bp
@@ -34,17 +34,15 @@
 
 art_cc_library {
     name: "libart-dexlayout",
-    defaults: ["libart-dexlayout-defaults"],
+    defaults: [
+        "libart-dexlayout-defaults",
+        "dex2oat-pgo-defaults",
+    ],
     shared_libs: [
         "libart",
         "libdexfile",
     ],
 
-    pgo: {
-        instrumentation: true,
-        profile_file: "art/dex2oat.profdata",
-        benchmarks: ["dex2oat"],
-    },
     target: {
         android: {
             lto: {