Move the Compiler to CompilerDriver.

Change-Id: I0bb4d3c2b79b45fd8ef180688c767712b0c55978
diff --git a/src/compiler_llvm/compiler_llvm.cc b/src/compiler_llvm/compiler_llvm.cc
index db2a91b..efa7d97 100644
--- a/src/compiler_llvm/compiler_llvm.cc
+++ b/src/compiler_llvm/compiler_llvm.cc
@@ -20,7 +20,7 @@
 #include "backend_options.h"
 #include "class_linker.h"
 #include "compiled_method.h"
-#include "compiler.h"
+#include "compiler/driver/compiler_driver.h"
 #include "ir_builder.h"
 #include "jni_compiler.h"
 #include "llvm_compilation_unit.h"
@@ -37,7 +37,7 @@
 #include <llvm/Support/Threading.h>
 
 namespace art {
-void CompileOneMethod(Compiler& compiler,
+void CompileOneMethod(CompilerDriver& driver,
                       const CompilerBackend compilerBackend,
                       const DexFile::CodeItem* code_item,
                       uint32_t access_flags, InvokeType invoke_type,
@@ -108,8 +108,8 @@
 llvm::Module* makeLLVMModuleContents(llvm::Module* module);
 
 
-CompilerLLVM::CompilerLLVM(Compiler* compiler, InstructionSet insn_set)
-    : compiler_(compiler), insn_set_(insn_set),
+CompilerLLVM::CompilerLLVM(CompilerDriver* driver, InstructionSet insn_set)
+    : compiler_driver_(driver), insn_set_(insn_set),
       num_cunits_lock_("compilation unit counter lock"), num_cunits_(0),
       plt_(insn_set) {
 
@@ -139,7 +139,7 @@
   std::string methodName(PrettyMethod(oat_compilation_unit->GetDexMethodIndex(),
                                       *oat_compilation_unit->GetDexFile()));
   // TODO: consolidate ArtCompileMethods
-  CompileOneMethod(*compiler_,
+  CompileOneMethod(*compiler_driver_,
                    kPortable,
                    oat_compilation_unit->GetCodeItem(),
                    oat_compilation_unit->access_flags_,
@@ -151,14 +151,14 @@
                    cunit->GetQuickContext()
   );
 
-  cunit->SetCompiler(compiler_);
+  cunit->SetCompiler(compiler_driver_);
   cunit->SetOatCompilationUnit(oat_compilation_unit);
 
   cunit->Materialize();
 
-  Compiler::MethodReference mref(oat_compilation_unit->GetDexFile(),
-                                 oat_compilation_unit->GetDexMethodIndex());
-  return new CompiledMethod(compiler_->GetInstructionSet(),
+  CompilerDriver::MethodReference mref(oat_compilation_unit->GetDexFile(),
+                                       oat_compilation_unit->GetDexMethodIndex());
+  return new CompiledMethod(compiler_driver_->GetInstructionSet(),
                             cunit->GetCompiledCode(),
                             *verifier::MethodVerifier::GetDexGcMap(mref));
 }
@@ -169,7 +169,7 @@
   UniquePtr<LlvmCompilationUnit> cunit(AllocateCompilationUnit());
 
   UniquePtr<JniCompiler> jni_compiler(
-      new JniCompiler(cunit.get(), *compiler_, oat_compilation_unit));
+      new JniCompiler(cunit.get(), *compiler_driver_, oat_compilation_unit));
 
   return jni_compiler->Compile();
 }
@@ -180,7 +180,7 @@
   UniquePtr<LlvmCompilationUnit> cunit(AllocateCompilationUnit());
 
   UniquePtr<StubCompiler> stub_compiler(
-    new StubCompiler(cunit.get(), *compiler_));
+    new StubCompiler(cunit.get(), *compiler_driver_));
 
   return stub_compiler->CreateInvokeStub(is_static, shorty);
 }
@@ -190,7 +190,7 @@
   UniquePtr<LlvmCompilationUnit> cunit(AllocateCompilationUnit());
 
   UniquePtr<StubCompiler> stub_compiler(
-    new StubCompiler(cunit.get(), *compiler_));
+    new StubCompiler(cunit.get(), *compiler_driver_));
 
   return stub_compiler->CreateProxyStub(shorty);
 }
@@ -198,33 +198,33 @@
 } // namespace compiler_llvm
 } // namespace art
 
-inline static art::compiler_llvm::CompilerLLVM* ContextOf(art::Compiler& compiler) {
-  void *compiler_context = compiler.GetCompilerContext();
+inline static art::compiler_llvm::CompilerLLVM* ContextOf(art::CompilerDriver& driver) {
+  void *compiler_context = driver.GetCompilerContext();
   CHECK(compiler_context != NULL);
   return reinterpret_cast<art::compiler_llvm::CompilerLLVM*>(compiler_context);
 }
 
-inline static const art::compiler_llvm::CompilerLLVM* ContextOf(const art::Compiler& compiler) {
-  void *compiler_context = compiler.GetCompilerContext();
+inline static const art::compiler_llvm::CompilerLLVM* ContextOf(const art::CompilerDriver& driver) {
+  void *compiler_context = driver.GetCompilerContext();
   CHECK(compiler_context != NULL);
   return reinterpret_cast<const art::compiler_llvm::CompilerLLVM*>(compiler_context);
 }
 
-extern "C" void ArtInitCompilerContext(art::Compiler& compiler) {
-  CHECK(compiler.GetCompilerContext() == NULL);
+extern "C" void ArtInitCompilerContext(art::CompilerDriver& driver) {
+  CHECK(driver.GetCompilerContext() == NULL);
 
   art::compiler_llvm::CompilerLLVM* compiler_llvm =
-      new art::compiler_llvm::CompilerLLVM(&compiler,
-                                           compiler.GetInstructionSet());
+      new art::compiler_llvm::CompilerLLVM(&driver,
+                                           driver.GetInstructionSet());
 
-  compiler.SetCompilerContext(compiler_llvm);
+  driver.SetCompilerContext(compiler_llvm);
 }
 
-extern "C" void ArtUnInitCompilerContext(art::Compiler& compiler) {
-  delete ContextOf(compiler);
-  compiler.SetCompilerContext(NULL);
+extern "C" void ArtUnInitCompilerContext(art::CompilerDriver& driver) {
+  delete ContextOf(driver);
+  driver.SetCompilerContext(NULL);
 }
-extern "C" art::CompiledMethod* ArtCompileMethod(art::Compiler& compiler,
+extern "C" art::CompiledMethod* ArtCompileMethod(art::CompilerDriver& driver,
                                                  const art::DexFile::CodeItem* code_item,
                                                  uint32_t access_flags,
                                                  art::InvokeType invoke_type,
@@ -238,12 +238,12 @@
   art::OatCompilationUnit oat_compilation_unit(
     class_loader, class_linker, dex_file, code_item,
     class_def_idx, method_idx, access_flags);
-  art::compiler_llvm::CompilerLLVM* compiler_llvm = ContextOf(compiler);
+  art::compiler_llvm::CompilerLLVM* compiler_llvm = ContextOf(driver);
   art::CompiledMethod* result = compiler_llvm->CompileDexMethod(&oat_compilation_unit, invoke_type);
   return result;
 }
 
-extern "C" art::CompiledMethod* ArtLLVMJniCompileMethod(art::Compiler& compiler,
+extern "C" art::CompiledMethod* ArtLLVMJniCompileMethod(art::CompilerDriver& driver,
                                                         uint32_t access_flags, uint32_t method_idx,
                                                         const art::DexFile& dex_file) {
   art::ClassLinker *class_linker = art::Runtime::Current()->GetClassLinker();
@@ -252,29 +252,29 @@
     NULL, class_linker, dex_file, NULL,
     0, method_idx, access_flags);
 
-  art::compiler_llvm::CompilerLLVM* compiler_llvm = ContextOf(compiler);
+  art::compiler_llvm::CompilerLLVM* compiler_llvm = ContextOf(driver);
   art::CompiledMethod* result = compiler_llvm->CompileNativeMethod(&oat_compilation_unit);
   return result;
 }
 
-extern "C" art::CompiledInvokeStub* ArtCreateLLVMInvokeStub(art::Compiler& compiler,
+extern "C" art::CompiledInvokeStub* ArtCreateLLVMInvokeStub(art::CompilerDriver& driver,
                                                             bool is_static,
                                                             const char* shorty,
                                                             uint32_t shorty_len) {
-  art::compiler_llvm::CompilerLLVM* compiler_llvm = ContextOf(compiler);
+  art::compiler_llvm::CompilerLLVM* compiler_llvm = ContextOf(driver);
   art::CompiledInvokeStub* result = compiler_llvm->CreateInvokeStub(is_static, shorty);
   return result;
 }
 
-extern "C" art::CompiledInvokeStub* ArtCreateProxyStub(art::Compiler& compiler,
+extern "C" art::CompiledInvokeStub* ArtCreateProxyStub(art::CompilerDriver& driver,
                                                        const char* shorty,
                                                        uint32_t shorty_len) {
-  art::compiler_llvm::CompilerLLVM* compiler_llvm = ContextOf(compiler);
+  art::compiler_llvm::CompilerLLVM* compiler_llvm = ContextOf(driver);
   art::CompiledInvokeStub* result = compiler_llvm->CreateProxyStub(shorty);
   return result;
 }
 
-extern "C" void compilerLLVMSetBitcodeFileName(art::Compiler& compiler,
+extern "C" void compilerLLVMSetBitcodeFileName(art::CompilerDriver& driver,
                                                std::string const& filename) {
-  ContextOf(compiler)->SetBitcodeFileName(filename);
+  ContextOf(driver)->SetBitcodeFileName(filename);
 }
diff --git a/src/compiler_llvm/compiler_llvm.h b/src/compiler_llvm/compiler_llvm.h
index 0cd08a7..0995a55 100644
--- a/src/compiler_llvm/compiler_llvm.h
+++ b/src/compiler_llvm/compiler_llvm.h
@@ -18,7 +18,7 @@
 #define ART_SRC_COMPILER_LLVM_COMPILER_LLVM_H_
 
 #include "base/macros.h"
-#include "compiler.h"
+#include "compiler/driver/compiler_driver.h"
 #include "dex_file.h"
 #include "instruction_set.h"
 #include "mirror/object.h"
@@ -33,7 +33,7 @@
 namespace art {
   class CompiledInvokeStub;
   class CompiledMethod;
-  class Compiler;
+  class CompilerDriver;
   class OatCompilationUnit;
   namespace mirror {
     class AbstractMethod;
@@ -60,12 +60,12 @@
 
 class CompilerLLVM {
  public:
-  CompilerLLVM(Compiler* compiler, InstructionSet insn_set);
+  CompilerLLVM(CompilerDriver* driver, InstructionSet insn_set);
 
   ~CompilerLLVM();
 
-  Compiler* GetCompiler() const {
-    return compiler_;
+  CompilerDriver* GetCompiler() const {
+    return compiler_driver_;
   }
 
   InstructionSet GetInstructionSet() const {
@@ -94,7 +94,7 @@
  private:
   LlvmCompilationUnit* AllocateCompilationUnit();
 
-  Compiler* compiler_;
+  CompilerDriver* compiler_driver_;
 
   InstructionSet insn_set_;
 
diff --git a/src/compiler_llvm/gbc_expander.cc b/src/compiler_llvm/gbc_expander.cc
index 4a5d5b0..f0d3830 100644
--- a/src/compiler_llvm/gbc_expander.cc
+++ b/src/compiler_llvm/gbc_expander.cc
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-#include "compiler.h"
+#include "compiler/driver/compiler_driver.h"
 #include "intrinsic_helper.h"
 #include "ir_builder.h"
 #include "mirror/abstract_method.h"
@@ -63,7 +63,7 @@
   llvm::Value* old_shadow_frame_;
 
  private:
-  art::Compiler* compiler_;
+  art::CompilerDriver* const driver_;
 
   art::OatCompilationUnit* oat_compilation_unit_;
 
@@ -326,11 +326,11 @@
   static char ID;
 
   GBCExpanderPass(const IntrinsicHelper& intrinsic_helper, IRBuilder& irb,
-                  art::Compiler* compiler, art::OatCompilationUnit* oat_compilation_unit)
+                  art::CompilerDriver* compiler, art::OatCompilationUnit* oat_compilation_unit)
       : llvm::FunctionPass(ID), intrinsic_helper_(intrinsic_helper), irb_(irb),
         context_(irb.getContext()), rtb_(irb.Runtime()),
         shadow_frame_(NULL), old_shadow_frame_(NULL),
-        compiler_(compiler),
+        driver_(compiler),
         oat_compilation_unit_(oat_compilation_unit),
         func_(NULL), current_bb_(NULL), basic_block_unwind_(NULL), changed_(false) {}
 
@@ -1392,7 +1392,7 @@
 
   int field_offset;
   bool is_volatile;
-  bool is_fast_path = compiler_->ComputeInstanceFieldInfo(
+  bool is_fast_path = driver_->ComputeInstanceFieldInfo(
     field_idx, oat_compilation_unit_, field_offset, is_volatile, false);
 
   if (!is_fast_path) {
@@ -1452,7 +1452,7 @@
 
   int field_offset;
   bool is_volatile;
-  bool is_fast_path = compiler_->ComputeInstanceFieldInfo(
+  bool is_fast_path = driver_->ComputeInstanceFieldInfo(
     field_idx, oat_compilation_unit_, field_offset, is_volatile, true);
 
   if (!is_fast_path) {
@@ -1509,7 +1509,7 @@
 
 llvm::Value* GBCExpanderPass::EmitLoadConstantClass(uint32_t dex_pc,
                                                     uint32_t type_idx) {
-  if (!compiler_->CanAccessTypeWithoutChecks(oat_compilation_unit_->method_idx_,
+  if (!driver_->CanAccessTypeWithoutChecks(oat_compilation_unit_->method_idx_,
                                              *oat_compilation_unit_->dex_file_, type_idx)) {
     llvm::Value* type_idx_value = irb_.getInt32(type_idx);
 
@@ -1536,7 +1536,7 @@
 
     llvm::Value* type_object_addr = irb_.CreateLoad(type_field_addr, kTBAARuntimeInfo);
 
-    if (compiler_->CanAssumeTypeIsPresentInDexCache(*oat_compilation_unit_->dex_file_, type_idx)) {
+    if (driver_->CanAssumeTypeIsPresentInDexCache(*oat_compilation_unit_->dex_file_, type_idx)) {
       return type_object_addr;
     }
 
@@ -1652,7 +1652,7 @@
   bool is_referrers_class;
   bool is_volatile;
 
-  bool is_fast_path = compiler_->ComputeStaticFieldInfo(
+  bool is_fast_path = driver_->ComputeStaticFieldInfo(
     field_idx, oat_compilation_unit_, field_offset, ssb_index,
     is_referrers_class, is_volatile, false);
 
@@ -1734,7 +1734,7 @@
   bool is_referrers_class;
   bool is_volatile;
 
-  bool is_fast_path = compiler_->ComputeStaticFieldInfo(
+  bool is_fast_path = driver_->ComputeStaticFieldInfo(
     field_idx, oat_compilation_unit_, field_offset, ssb_index,
     is_referrers_class, is_volatile, true);
 
@@ -1814,7 +1814,7 @@
 
   llvm::Value* string_addr = irb_.CreateLoad(string_field_addr, kTBAARuntimeInfo);
 
-  if (!compiler_->CanAssumeStringIsPresentInDexCache(*oat_compilation_unit_->dex_file_,
+  if (!driver_->CanAssumeStringIsPresentInDexCache(*oat_compilation_unit_->dex_file_,
                                                      string_idx)) {
     llvm::BasicBlock* block_str_exist =
       CreateBasicBlockWithDexPC(dex_pc, "str_exist");
@@ -2037,7 +2037,7 @@
   uint32_t type_idx = LV2UInt(call_inst.getArgOperand(0));
 
   llvm::Function* runtime_func;
-  if (compiler_->CanAccessInstantiableTypeWithoutChecks(oat_compilation_unit_->method_idx_,
+  if (driver_->CanAccessInstantiableTypeWithoutChecks(oat_compilation_unit_->method_idx_,
                                                         *oat_compilation_unit_->dex_file_,
                                                         type_idx)) {
     runtime_func = irb_.GetRuntime(runtime_support::AllocObject);
@@ -2072,7 +2072,7 @@
   int vtable_idx = -1;
   uintptr_t direct_code = 0;
   uintptr_t direct_method = 0;
-  bool is_fast_path = compiler_->
+  bool is_fast_path = driver_->
     ComputeInvokeInfo(callee_method_idx, oat_compilation_unit_,
                       invoke_type, vtable_idx, direct_code, direct_method);
 
@@ -2289,7 +2289,7 @@
   llvm::Function* runtime_func;
 
   bool skip_access_check =
-    compiler_->CanAccessTypeWithoutChecks(oat_compilation_unit_->method_idx_,
+    driver_->CanAccessTypeWithoutChecks(oat_compilation_unit_->method_idx_,
                                           *oat_compilation_unit_->dex_file_, type_idx);
 
 
@@ -3634,8 +3634,8 @@
 
 llvm::FunctionPass*
 CreateGBCExpanderPass(const IntrinsicHelper& intrinsic_helper, IRBuilder& irb,
-                      Compiler* compiler, OatCompilationUnit* oat_compilation_unit) {
-  return new GBCExpanderPass(intrinsic_helper, irb, compiler, oat_compilation_unit);
+                      CompilerDriver* driver, OatCompilationUnit* oat_compilation_unit) {
+  return new GBCExpanderPass(intrinsic_helper, irb, driver, oat_compilation_unit);
 }
 
 } // namespace compiler_llvm
diff --git a/src/compiler_llvm/jni_compiler.cc b/src/compiler_llvm/jni_compiler.cc
index c23c5e2..8b5f1be 100644
--- a/src/compiler_llvm/jni_compiler.cc
+++ b/src/compiler_llvm/jni_compiler.cc
@@ -19,7 +19,7 @@
 #include "base/logging.h"
 #include "class_linker.h"
 #include "compiled_method.h"
-#include "compiler.h"
+#include "compiler/driver/compiler_driver.h"
 #include "compiler_llvm.h"
 #include "ir_builder.h"
 #include "llvm_compilation_unit.h"
@@ -43,14 +43,15 @@
 using namespace runtime_support;
 
 JniCompiler::JniCompiler(LlvmCompilationUnit* cunit,
-                         Compiler const& compiler,
+                         const CompilerDriver& driver,
                          OatCompilationUnit* oat_compilation_unit)
-: cunit_(cunit), compiler_(&compiler), module_(cunit_->GetModule()),
+: cunit_(cunit), driver_(&driver), module_(cunit_->GetModule()),
   context_(cunit_->GetLLVMContext()), irb_(*cunit_->GetIRBuilder()),
   oat_compilation_unit_(oat_compilation_unit),
   access_flags_(oat_compilation_unit->access_flags_),
   method_idx_(oat_compilation_unit->method_idx_),
-  dex_file_(oat_compilation_unit->dex_file_) {
+  dex_file_(oat_compilation_unit->dex_file_),
+  func_(NULL), elf_func_idx_(0) {
 
   // Check: Ensure that JNI compiler will only get "native" method
   CHECK((access_flags_ & kAccNative) != 0);
diff --git a/src/compiler_llvm/jni_compiler.h b/src/compiler_llvm/jni_compiler.h
index 4648180..071229c 100644
--- a/src/compiler_llvm/jni_compiler.h
+++ b/src/compiler_llvm/jni_compiler.h
@@ -22,7 +22,7 @@
 namespace art {
   class ClassLinker;
   class CompiledMethod;
-  class Compiler;
+  class CompilerDriver;
   class DexFile;
   class OatCompilationUnit;
   namespace mirror {
@@ -52,7 +52,7 @@
 class JniCompiler {
  public:
   JniCompiler(LlvmCompilationUnit* cunit,
-              Compiler const& compiler,
+              const CompilerDriver& driver,
               OatCompilationUnit* oat_compilation_unit);
 
   CompiledMethod* Compile();
@@ -65,7 +65,7 @@
 
  private:
   LlvmCompilationUnit* cunit_;
-  const Compiler* compiler_;
+  const CompilerDriver* const driver_;
 
   llvm::Module* module_;
   llvm::LLVMContext* context_;
diff --git a/src/compiler_llvm/llvm_compilation_unit.cc b/src/compiler_llvm/llvm_compilation_unit.cc
index 1c0218f..3f13c18 100644
--- a/src/compiler_llvm/llvm_compilation_unit.cc
+++ b/src/compiler_llvm/llvm_compilation_unit.cc
@@ -82,7 +82,7 @@
 
 llvm::FunctionPass*
 CreateGBCExpanderPass(const IntrinsicHelper& intrinsic_helper, IRBuilder& irb,
-                      Compiler* compiler, OatCompilationUnit* oat_compilation_unit);
+                      CompilerDriver* compiler, OatCompilationUnit* oat_compilation_unit);
 
 llvm::Module* makeLLVMModuleContents(llvm::Module* module);
 
@@ -90,7 +90,7 @@
 LlvmCompilationUnit::LlvmCompilationUnit(const CompilerLLVM* compiler_llvm,
                                  size_t cunit_idx)
 : compiler_llvm_(compiler_llvm), cunit_idx_(cunit_idx) {
-  compiler_ = NULL;
+  driver_ = NULL;
   oat_compilation_unit_ = NULL;
   llvm_info_.reset(new LLVMInfo());
   context_.reset(llvm_info_->GetLLVMContext());
@@ -175,7 +175,7 @@
   std::string target_triple;
   std::string target_cpu;
   std::string target_attr;
-  Compiler::InstructionSetToLLVMTarget(GetInstructionSet(), target_triple, target_cpu, target_attr);
+  CompilerDriver::InstructionSetToLLVMTarget(GetInstructionSet(), target_triple, target_cpu, target_attr);
 
   std::string errmsg;
   const llvm::Target* target =
@@ -214,11 +214,11 @@
     // If we don't need write the bitcode to file, add the AddSuspendCheckToLoopLatchPass to the
     // regular FunctionPass.
     fpm.add(CreateGBCExpanderPass(*llvm_info_->GetIntrinsicHelper(), *irb_.get(),
-                                  compiler_, oat_compilation_unit_));
+                                  driver_, oat_compilation_unit_));
   } else {
     llvm::FunctionPassManager fpm2(module_);
     fpm2.add(CreateGBCExpanderPass(*llvm_info_->GetIntrinsicHelper(), *irb_.get(),
-                                   compiler_, oat_compilation_unit_));
+                                   driver_, oat_compilation_unit_));
     fpm2.doInitialization();
     for (llvm::Module::iterator F = module_->begin(), E = module_->end();
          F != E; ++F) {
diff --git a/src/compiler_llvm/llvm_compilation_unit.h b/src/compiler_llvm/llvm_compilation_unit.h
index 8ea4ea2..801bbef 100644
--- a/src/compiler_llvm/llvm_compilation_unit.h
+++ b/src/compiler_llvm/llvm_compilation_unit.h
@@ -20,7 +20,7 @@
 #include "base/logging.h"
 #include "base/mutex.h"
 #include "compiler/dex/compiler_internals.h"
-#include "compiler.h"
+#include "compiler/driver/compiler_driver.h"
 #include "globals.h"
 #include "instruction_set.h"
 #include "oat_compilation_unit.h"
@@ -78,8 +78,8 @@
   LLVMInfo* GetQuickContext() const {
     return llvm_info_.get();
   }
-  void SetCompiler(Compiler* compiler) {
-    compiler_ = compiler;
+  void SetCompiler(CompilerDriver* driver) {
+    driver_ = driver;
   }
   void SetOatCompilationUnit(OatCompilationUnit* oat_compilation_unit) {
     oat_compilation_unit_ = oat_compilation_unit;
@@ -109,7 +109,7 @@
   llvm::Module* module_; // Managed by context_
   UniquePtr<IntrinsicHelper> intrinsic_helper_;
   UniquePtr<LLVMInfo> llvm_info_;
-  Compiler* compiler_;
+  CompilerDriver* driver_;
   OatCompilationUnit* oat_compilation_unit_;
 
   std::string bitcode_filename_;
diff --git a/src/compiler_llvm/stub_compiler.cc b/src/compiler_llvm/stub_compiler.cc
index e0a3b3c..6639ca7 100644
--- a/src/compiler_llvm/stub_compiler.cc
+++ b/src/compiler_llvm/stub_compiler.cc
@@ -18,7 +18,7 @@
 
 #include "base/logging.h"
 #include "compiled_method.h"
-#include "compiler.h"
+#include "compiler/driver/compiler_driver.h"
 #include "compiler_llvm.h"
 #include "ir_builder.h"
 #include "llvm_compilation_unit.h"
@@ -40,8 +40,8 @@
 using namespace runtime_support;
 
 
-StubCompiler::StubCompiler(LlvmCompilationUnit* cunit, Compiler& compiler)
-: cunit_(cunit), compiler_(&compiler), module_(cunit_->GetModule()),
+StubCompiler::StubCompiler(LlvmCompilationUnit* cunit, const CompilerDriver& driver)
+: cunit_(cunit), driver_(&driver), module_(cunit_->GetModule()),
   context_(cunit_->GetLLVMContext()), irb_(*cunit_->GetIRBuilder()) {
 }
 
diff --git a/src/compiler_llvm/stub_compiler.h b/src/compiler_llvm/stub_compiler.h
index 312b3af..63b283d 100644
--- a/src/compiler_llvm/stub_compiler.h
+++ b/src/compiler_llvm/stub_compiler.h
@@ -22,7 +22,7 @@
 namespace art {
   class CompiledInvokeStub;
   class CompiledProxyStub;
-  class Compiler;
+  class CompilerDriver;
 }
 
 namespace llvm {
@@ -39,14 +39,14 @@
 
 class StubCompiler {
  public:
-  StubCompiler(LlvmCompilationUnit* cunit, Compiler& compiler);
+  StubCompiler(LlvmCompilationUnit* cunit, const CompilerDriver& compiler);
 
   CompiledInvokeStub* CreateInvokeStub(bool is_static, const char* shorty);
   CompiledInvokeStub* CreateProxyStub(const char* shorty);
 
  private:
   LlvmCompilationUnit* cunit_;
-  const Compiler* compiler_;
+  const CompilerDriver* const driver_;
   llvm::Module* module_;
   llvm::LLVMContext* context_;
   IRBuilder& irb_;