Add ELF index to art::compiler_llvm::CompilationUnit.

We need an ELF index to remember which ELF image contains
the CompiledMethod or CompiledInvokeStub.

Change-Id: Ic17f3e0f5cfcd57f91f2cac91e64faaca48f346d
diff --git a/src/compiler_llvm/compilation_unit.cc b/src/compiler_llvm/compilation_unit.cc
index f654e48..d548976 100644
--- a/src/compiler_llvm/compilation_unit.cc
+++ b/src/compiler_llvm/compilation_unit.cc
@@ -60,8 +60,9 @@
 llvm::Module* makeLLVMModuleContents(llvm::Module* module);
 
 
-CompilationUnit::CompilationUnit(InstructionSet insn_set)
-: insn_set_(insn_set), context_(new llvm::LLVMContext()), mem_usage_(0) {
+CompilationUnit::CompilationUnit(InstructionSet insn_set, size_t elf_idx)
+: insn_set_(insn_set), elf_idx_(elf_idx), context_(new llvm::LLVMContext()),
+  mem_usage_(0) {
 
   // Create the module and include the runtime function declaration
   module_ = new llvm::Module("art", *context_);
diff --git a/src/compiler_llvm/compilation_unit.h b/src/compiler_llvm/compilation_unit.h
index a0882bb..4a23095 100644
--- a/src/compiler_llvm/compilation_unit.h
+++ b/src/compiler_llvm/compilation_unit.h
@@ -36,10 +36,14 @@
 
 class CompilationUnit {
  public:
-  CompilationUnit(InstructionSet insn_set);
+  CompilationUnit(InstructionSet insn_set, size_t elf_idx);
 
   ~CompilationUnit();
 
+  size_t GetElfIndex() const {
+    return elf_idx_;
+  }
+
   InstructionSet GetInstructionSet() const {
     return insn_set_;
   }
@@ -98,6 +102,7 @@
 
  private:
   InstructionSet insn_set_;
+  const size_t elf_idx_;
 
   UniquePtr<llvm::LLVMContext> context_;
   UniquePtr<IRBuilder> irb_;
diff --git a/src/compiler_llvm/compiler_llvm.cc b/src/compiler_llvm/compiler_llvm.cc
index 7563fe0..d528615 100644
--- a/src/compiler_llvm/compiler_llvm.cc
+++ b/src/compiler_llvm/compiler_llvm.cc
@@ -119,7 +119,7 @@
   // Allocate compilation unit
   size_t cunit_idx = cunits_.size();
 
-  curr_cunit_ = new CompilationUnit(insn_set_);
+  curr_cunit_ = new CompilationUnit(insn_set_, cunit_idx);
 
   // Setup output filename
   curr_cunit_->SetElfFileName(