Enforce optimizing test marker for verification errors.

Change-Id: Ie7babf162729fa02d285572ee043fa9e588d73cc
diff --git a/compiler/optimizing/optimizing_compiler.cc b/compiler/optimizing/optimizing_compiler.cc
index 28514e1..a34717c 100644
--- a/compiler/optimizing/optimizing_compiler.cc
+++ b/compiler/optimizing/optimizing_compiler.cc
@@ -711,9 +711,6 @@
       &arena, dex_file, method_idx, requires_barrier, compiler_driver->GetInstructionSet(),
       kInvalidInvokeType, compiler_driver->GetCompilerOptions().GetDebuggable());
 
-  // For testing purposes, we put a special marker on method names that should be compiled
-  // with this compiler. This makes sure we're not regressing.
-  bool shouldCompile = method_name.find("$opt$") != std::string::npos;
   bool shouldOptimize = method_name.find("$opt$reg$") != std::string::npos && run_optimizations_;
 
   std::unique_ptr<CodeGenerator> codegen(
@@ -722,7 +719,6 @@
                             *compiler_driver->GetInstructionSetFeatures(),
                             compiler_driver->GetCompilerOptions()));
   if (codegen.get() == nullptr) {
-    CHECK(!shouldCompile) << "Could not find code generator for optimizing compiler";
     MaybeRecordStat(MethodCompilationStat::kNotCompiledNoCodegen);
     return nullptr;
   }
@@ -763,8 +759,6 @@
   {
     PassScope scope(HGraphBuilder::kBuilderPassName, &pass_observer);
     if (!builder.BuildGraph(*code_item)) {
-      DCHECK(!(IsCompilingWithCoreImage() && shouldCompile))
-          << "Could not build graph in optimizing compiler";
       pass_observer.SetGraphInBadState();
       return nullptr;
     }
@@ -857,6 +851,14 @@
     }
   }
 
+  if (kIsDebugBuild && IsCompilingWithCoreImage()) {
+    // For testing purposes, we put a special marker on method names that should be compiled
+    // with this compiler. This makes sure we're not regressing.
+    std::string method_name = PrettyMethod(method_idx, dex_file);
+    bool shouldCompile = method_name.find("$opt$") != std::string::npos;
+    DCHECK((method != nullptr) || !shouldCompile) << "Didn't compile " << method_name;
+  }
+
   return method;
 }