Add verify-profile compiler filter

Only verifies and dex2dex compiles classes in the profile. Goal
is to reduce application launch time.

~2x faster than interpret-only for Facebook.

Bug: 27688727

(cherry picked from commit a079e3aa62cceb76c1c1811e6e09bcaf75e20289)

Change-Id: Iad5aa1adee3aa6c2408820e8cbbab2d4412021b8
diff --git a/dex2oat/dex2oat.cc b/dex2oat/dex2oat.cc
index 2981011..c2d5e4d 100644
--- a/dex2oat/dex2oat.cc
+++ b/dex2oat/dex2oat.cc
@@ -256,6 +256,7 @@
   UsageError("  --compiler-filter="
                 "(verify-none"
                 "|verify-at-runtime"
+                "|verify-profile"
                 "|interpret-only"
                 "|space"
                 "|balanced"
@@ -263,6 +264,7 @@
                 "|everything"
                 "|time):");
   UsageError("      select compiler filter.");
+  UsageError("      verify-profile requires a --profile(-fd) to also be passed in.");
   UsageError("      Example: --compiler-filter=everything");
   UsageError("      Default: speed");
   UsageError("");
@@ -805,10 +807,16 @@
       }
     }
 
-    if (!profile_file_.empty() && (profile_file_fd_ != kInvalidFd)) {
+    const bool have_profile_file = !profile_file_.empty();
+    const bool have_profile_fd = profile_file_fd_ != kInvalidFd;
+    if (have_profile_file && have_profile_fd) {
       Usage("Profile file should not be specified with both --profile-file-fd and --profile-file");
     }
 
+    if (compiler_options_->IsVerificationEnabled() && !have_profile_file && !have_profile_fd) {
+      Usage("verify-profile compiler filter must be used with a profile file or fd");
+    }
+
     if (!parser_options->oat_symbols.empty()) {
       oat_unstripped_ = std::move(parser_options->oat_symbols);
     }
@@ -1450,8 +1458,8 @@
     }
 
     /*
-     * If we're not in interpret-only or verify-none or verify-at-runtime mode, go ahead and
-     * compile small applications.  Don't bother to check if we're doing the image.
+     * If we're not in interpret-only or verify-none or verify-at-runtime or verify-profile mode,
+     * go ahead and compile small applications.  Don't bother to check if we're doing the image.
      */
     if (!IsBootImage() &&
         compiler_options_->IsCompilationEnabled() &&