Do not release the driver_ if we are dumping stats

When using the --dump-stats option, we get those stats logged when the optimizing compiler gets destroyed. If we release the driver_, the destructor will never be called.

Change-Id: I04c4c808627f0eb96d5f5f67ff123c678287c8a5
diff --git a/dex2oat/dex2oat.cc b/dex2oat/dex2oat.cc
index 0175eda..6f01329 100644
--- a/dex2oat/dex2oat.cc
+++ b/dex2oat/dex2oat.cc
@@ -559,7 +559,11 @@
     if (!kIsDebugBuild && !(kRunningOnMemoryTool && kMemoryToolDetectsLeaks)) {
       // We want to just exit on non-debug builds, not bringing the runtime down
       // in an orderly fashion. So release the following fields.
-      driver_.release();                // NOLINT
+      if (!compiler_options_->GetDumpStats()) {
+        // The --dump-stats get logged when the optimizing compiler gets destroyed, so we can't
+        // release the driver_.
+        driver_.release();              // NOLINT
+      }
       image_writer_.release();          // NOLINT
       for (std::unique_ptr<const DexFile>& dex_file : opened_dex_files_) {
         dex_file.release();             // NOLINT