diff options
author | 2014-11-24 15:28:45 +0000 | |
---|---|---|
committer | 2014-11-25 00:55:07 +0000 | |
commit | 3159674c0863f53cfbc1913d493550221ac47f02 (patch) | |
tree | 5dc34e8da8dc695cf80040ba0dbc5312060c10c1 /compiler/optimizing/optimizing_compiler.cc | |
parent | 4d3ed1a6f34bd31ed30faaca0433cf2a4b19bb7b (diff) |
Fix a bug in the type analysis phase of optimizing.
Dex code can lead to the creation of a phi with one
float input and one integer input. Since the SSA builder trusts
the verifier, it assumes that the integer input must be converted
to float. However, when the register is not used afterwards, the
verifier hasn't ensured that. Therefore, the compiler must remove
the phi prior to doing type propagation.
Change-Id: Idcd51c4dccce827c59d1f2b253bc1c919bc07df5
Diffstat (limited to 'compiler/optimizing/optimizing_compiler.cc')
-rw-r--r-- | compiler/optimizing/optimizing_compiler.cc | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/compiler/optimizing/optimizing_compiler.cc b/compiler/optimizing/optimizing_compiler.cc index 42ac77d1d8..d8533eb8bf 100644 --- a/compiler/optimizing/optimizing_compiler.cc +++ b/compiler/optimizing/optimizing_compiler.cc @@ -35,6 +35,7 @@ #include "nodes.h" #include "prepare_for_register_allocation.h" #include "register_allocator.h" +#include "ssa_builder.h" #include "ssa_phi_elimination.h" #include "ssa_liveness_analysis.h" #include "utils/arena_allocator.h" @@ -191,21 +192,31 @@ static bool CanOptimize(const DexFile::CodeItem& code_item) { } static void RunOptimizations(HGraph* graph, const HGraphVisualizer& visualizer) { + TransformToSsa ssa(graph); HDeadCodeElimination opt1(graph); HConstantFolding opt2(graph); SsaRedundantPhiElimination opt3(graph); SsaDeadPhiElimination opt4(graph); InstructionSimplifier opt5(graph); - GlobalValueNumberer opt6(graph->GetArena(), graph); + GVNOptimization opt6(graph); InstructionSimplifier opt7(graph); - HOptimization* optimizations[] = { &opt1, &opt2, &opt3, &opt4, &opt5, &opt6, &opt7 }; + HOptimization* optimizations[] = { + &ssa, + &opt1, + &opt2, + &opt3, + &opt4, + &opt5, + &opt6, + &opt7 + }; for (size_t i = 0; i < arraysize(optimizations); ++i) { HOptimization* optimization = optimizations[i]; optimization->Run(); - optimization->Check(); visualizer.DumpGraph(optimization->GetPassName()); + optimization->Check(); } } @@ -271,11 +282,6 @@ CompiledMethod* OptimizingCompiler::Compile(const DexFile::CodeItem* code_item, && CanOptimize(*code_item) && RegisterAllocator::CanAllocateRegistersFor(*graph, instruction_set)) { optimized_compiled_methods_++; - graph->BuildDominatorTree(); - graph->TransformToSSA(); - visualizer.DumpGraph("ssa"); - graph->FindNaturalLoops(); - RunOptimizations(graph, visualizer); PrepareForRegisterAllocation(graph).Run(); @@ -321,7 +327,7 @@ CompiledMethod* OptimizingCompiler::Compile(const DexFile::CodeItem* code_item, graph->FindNaturalLoops(); SsaRedundantPhiElimination(graph).Run(); SsaDeadPhiElimination(graph).Run(); - GlobalValueNumberer(graph->GetArena(), graph).Run(); + GVNOptimization(graph).Run(); SsaLivenessAnalysis liveness(*graph, codegen); liveness.Analyze(); visualizer.DumpGraph(kLivenessPassName); |