Revert "Revert "If generating an image, run initialization and other optimizations.""

This reverts commit bbec8a6fc720ee5ce572d3fb63617fb0af6addc7.

Reason for revert: Fix vdex compilation with app images.

Test: 628-vdex
Bug: 150193586

Change-Id: Ic4d0445f277caf9405c18938c1f39ee08b9bf2fd
diff --git a/compiler/driver/compiler_options.h b/compiler/driver/compiler_options.h
index 747205e..79ba1c2 100644
--- a/compiler/driver/compiler_options.h
+++ b/compiler/driver/compiler_options.h
@@ -195,6 +195,10 @@
     return implicit_suspend_checks_;
   }
 
+  bool IsGeneratingImage() const {
+    return IsBootImage() || IsBootImageExtension() || IsAppImage();
+  }
+
   // Are we compiling a boot image?
   bool IsBootImage() const {
     return image_type_ == ImageType::kBootImage;