summaryrefslogtreecommitdiff
path: root/src/compiler_llvm/compilation_unit.cc
diff options
context:
space:
mode:
author TDYa127 <tdy@google.com> 2012-09-11 15:14:42 -0700
committer Shih-wei Liao <sliao@google.com> 2012-09-15 04:51:25 -0700
commit55e5e6c5702e3f1f68bd83ae741af769740d9a74 (patch)
tree5f08ced0306436fdfdae2977d643aa5f1f3e09f6 /src/compiler_llvm/compilation_unit.cc
parent920be7cac2aa06f9d5c8b2db87db116b1cad3159 (diff)
Fix quick fly2iceland after rebase.
Change-Id: I844f005782b3ecdcb52dc2484d44f4ae34e1c670
Diffstat (limited to 'src/compiler_llvm/compilation_unit.cc')
-rw-r--r--src/compiler_llvm/compilation_unit.cc38
1 files changed, 21 insertions, 17 deletions
diff --git a/src/compiler_llvm/compilation_unit.cc b/src/compiler_llvm/compilation_unit.cc
index eaa8be1d9d..95073ea39b 100644
--- a/src/compiler_llvm/compilation_unit.cc
+++ b/src/compiler_llvm/compilation_unit.cc
@@ -150,11 +150,11 @@ llvm::RegisterPass<AddSuspendCheckToLoopLatchPass> reg_add_suspend_check_to_loop
namespace art {
namespace compiler_llvm {
-#if defined(ART_USE_DEXLANG_FRONTEND) || defined(ART_USE_QUICK_COMPILER)
+#if defined(ART_USE_DEXLANG_FRONTEND)
llvm::FunctionPass*
CreateGBCExpanderPass(const greenland::IntrinsicHelper& intrinsic_helper,
IRBuilder& irb);
-
+#elif defined(ART_USE_QUICK_COMPILER)
llvm::FunctionPass*
CreateGBCExpanderPass(const greenland::IntrinsicHelper& intrinsic_helper, IRBuilder& irb,
Compiler* compiler, OatCompilationUnit* oat_compilation_unit);
@@ -165,20 +165,24 @@ llvm::Module* makeLLVMModuleContents(llvm::Module* module);
CompilationUnit::CompilationUnit(const CompilerLLVM* compiler_llvm,
size_t cunit_idx)
-: compiler_llvm_(compiler_llvm), cunit_idx_(cunit_idx),
- context_(new llvm::LLVMContext()) {
-
- // Create the module and include the runtime function declaration
+: compiler_llvm_(compiler_llvm), cunit_idx_(cunit_idx) {
+#if !defined(ART_USE_QUICK_COMPILER)
+ context_.reset(new llvm::LLVMContext());
module_ = new llvm::Module("art", *context_);
+#else
+ compiler_ = NULL;
+ oat_compilation_unit_ = NULL;
+ quick_ctx_.reset(new QuickCompiler());
+ context_.reset(quick_ctx_->GetLLVMContext());
+ module_ = quick_ctx_->GetLLVMModule();
+#endif
+
+ // Include the runtime function declaration
makeLLVMModuleContents(module_);
-#if defined(ART_USE_DEXLANG_FRONTEND) || defined(ART_USE_QUICK_COMPILER)
+#if defined(ART_USE_DEXLANG_FRONTEND)
dex_lang_ctx_ = new greenland::DexLang::Context(*module_);
#endif
-#if defined(ART_USE_QUICK_COMPILER)
- compiler_ = NULL;
- oat_compilation_unit_ = NULL;
-#endif
// Create IRBuilder
irb_.reset(new IRBuilder(*context_, *module_));
@@ -204,8 +208,11 @@ CompilationUnit::CompilationUnit(const CompilerLLVM* compiler_llvm,
CompilationUnit::~CompilationUnit() {
-#if defined(ART_USE_DEXLANG_FRONTEND) || defined(ART_USE_QUICK_COMPILER)
+#if defined(ART_USE_DEXLANG_FRONTEND)
delete dex_lang_ctx_;
+#elif defined(ART_USE_QUICK_COMPILER)
+ llvm::LLVMContext* llvm_context = context_.release(); // Managed by quick_ctx_
+ CHECK(llvm_context != NULL);
#endif
}
@@ -221,7 +228,6 @@ bool CompilationUnit::Materialize() {
// Compile and prelink llvm::Module
if (!MaterializeToString(elf_image)) {
LOG(ERROR) << "Failed to materialize compilation unit " << cunit_idx_;
- DeleteResources();
return false;
}
@@ -237,11 +243,9 @@ bool CompilationUnit::Materialize() {
// Extract the .text section and prelink the code
if (!ExtractCodeAndPrelink(elf_image)) {
LOG(ERROR) << "Failed to extract code from compilation unit " << cunit_idx_;
- DeleteResources();
return false;
}
- DeleteResources();
return true;
}
@@ -327,7 +331,7 @@ bool CompilationUnit::MaterializeToRawOStream(llvm::raw_ostream& out_stream) {
#if defined(ART_USE_DEXLANG_FRONTEND)
fpm.add(CreateGBCExpanderPass(dex_lang_ctx_->GetIntrinsicHelper(), *irb_.get()));
#elif defined(ART_USE_QUICK_COMPILER)
- fpm.add(CreateGBCExpanderPass(dex_lang_ctx_->GetIntrinsicHelper(), *irb_.get(),
+ fpm.add(CreateGBCExpanderPass(*quick_ctx_->GetIntrinsicHelper(), *irb_.get(),
compiler_, oat_compilation_unit_));
#endif
fpm.add(new ::AddSuspendCheckToLoopLatchPass(irb_.get()));
@@ -337,7 +341,7 @@ bool CompilationUnit::MaterializeToRawOStream(llvm::raw_ostream& out_stream) {
#if defined(ART_USE_DEXLANG_FRONTEND)
fpm2.add(CreateGBCExpanderPass(dex_lang_ctx_->GetIntrinsicHelper(), *irb_.get()));
#elif defined(ART_USE_QUICK_COMPILER)
- fpm2.add(CreateGBCExpanderPass(dex_lang_ctx_->GetIntrinsicHelper(), *irb_.get(),
+ fpm2.add(CreateGBCExpanderPass(*quick_ctx_->GetIntrinsicHelper(), *irb_.get(),
compiler_, oat_compilation_unit_));
#endif
fpm2.add(new ::AddSuspendCheckToLoopLatchPass(irb_.get()));