diff options
Diffstat (limited to 'compiler/optimizing/inliner.cc')
-rw-r--r-- | compiler/optimizing/inliner.cc | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/compiler/optimizing/inliner.cc b/compiler/optimizing/inliner.cc index 1de5b78121..532167c179 100644 --- a/compiler/optimizing/inliner.cc +++ b/compiler/optimizing/inliner.cc @@ -27,6 +27,7 @@ #include "mirror/class_loader.h" #include "mirror/dex_cache.h" #include "nodes.h" +#include "register_allocator.h" #include "ssa_phi_elimination.h" #include "scoped_thread_state_change.h" #include "thread.h" @@ -43,10 +44,10 @@ void HInliner::Run() { instr_it.Advance()) { HInvokeStaticOrDirect* current = instr_it.Current()->AsInvokeStaticOrDirect(); if (current != nullptr) { - if (!TryInline(current, current->GetIndexInDexCache(), current->GetInvokeType())) { + if (!TryInline(current, current->GetDexMethodIndex(), current->GetInvokeType())) { if (kIsDebugBuild) { std::string callee_name = - PrettyMethod(current->GetIndexInDexCache(), *outer_compilation_unit_.GetDexFile()); + PrettyMethod(current->GetDexMethodIndex(), *outer_compilation_unit_.GetDexFile()); bool should_inline = callee_name.find("$inline$") != std::string::npos; CHECK(!should_inline) << "Could not inline " << callee_name; } @@ -143,6 +144,13 @@ bool HInliner::TryInline(HInvoke* invoke_instruction, return false; } + if (!RegisterAllocator::CanAllocateRegistersFor(*callee_graph, + compiler_driver_->GetInstructionSet())) { + VLOG(compiler) << "Method " << PrettyMethod(method_index, outer_dex_file) + << " cannot be inlined because of the register allocator"; + return false; + } + if (!callee_graph->TryBuildingSsa()) { VLOG(compiler) << "Method " << PrettyMethod(method_index, outer_dex_file) << " could not be transformed to SSA"; @@ -200,6 +208,11 @@ bool HInliner::TryInline(HInvoke* invoke_instruction, } callee_graph->InlineInto(graph_, invoke_instruction); + + // Now that we have inlined the callee, we need to update the next + // instruction id of the caller, so that new instructions added + // after optimizations get a unique id. + graph_->SetCurrentInstructionId(callee_graph->GetNextInstructionId()); VLOG(compiler) << "Successfully inlined " << PrettyMethod(method_index, outer_dex_file); outer_stats_->RecordStat(kInlinedInvoke); return true; |