ART: Refactor CompileOptimized
Factor out register allocation. Both Clang and GCC inline the
function, but it changes how Clang stack-allocates enough so
that the resulting frame size is below our limit.
Bug: 20139216
Change-Id: I2cf393aed70f2ce0556252b61ae639aacab6f3a7
diff --git a/compiler/optimizing/optimizing_compiler.cc b/compiler/optimizing/optimizing_compiler.cc
index 0e02212..f642dfc 100644
--- a/compiler/optimizing/optimizing_compiler.cc
+++ b/compiler/optimizing/optimizing_compiler.cc
@@ -371,9 +371,20 @@
return ArrayRef<const uint8_t>(vector);
}
-// TODO: The function below uses too much stack space.
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wframe-larger-than="
+static void AllocateRegisters(HGraph* graph,
+ CodeGenerator* codegen,
+ PassInfoPrinter* pass_info_printer) {
+ PrepareForRegisterAllocation(graph).Run();
+ SsaLivenessAnalysis liveness(*graph, codegen);
+ {
+ PassInfo pass_info(SsaLivenessAnalysis::kLivenessPassName, pass_info_printer);
+ liveness.Analyze();
+ }
+ {
+ PassInfo pass_info(RegisterAllocator::kRegisterAllocatorPassName, pass_info_printer);
+ RegisterAllocator(graph->GetArena(), codegen, liveness).AllocateRegisters();
+ }
+}
CompiledMethod* OptimizingCompiler::CompileOptimized(HGraph* graph,
CodeGenerator* codegen,
@@ -385,16 +396,7 @@
RunOptimizations(graph, compiler_driver, &compilation_stats_,
dex_file, dex_compilation_unit, pass_info_printer, &handles);
- PrepareForRegisterAllocation(graph).Run();
- SsaLivenessAnalysis liveness(*graph, codegen);
- {
- PassInfo pass_info(SsaLivenessAnalysis::kLivenessPassName, pass_info_printer);
- liveness.Analyze();
- }
- {
- PassInfo pass_info(RegisterAllocator::kRegisterAllocatorPassName, pass_info_printer);
- RegisterAllocator(graph->GetArena(), codegen, liveness).AllocateRegisters();
- }
+ AllocateRegisters(graph, codegen, pass_info_printer);
CodeVectorAllocator allocator;
codegen->CompileOptimized(&allocator);
@@ -427,8 +429,6 @@
ArrayRef<const LinkerPatch>());
}
-#pragma GCC diagnostic pop
-
CompiledMethod* OptimizingCompiler::CompileBaseline(
CodeGenerator* codegen,
CompilerDriver* compiler_driver,