diff options
| author | 2013-05-30 18:59:12 -0700 | |
|---|---|---|
| committer | 2013-05-30 19:10:44 -0700 | |
| commit | 817e45a26552bc8420fbea9e657ea7884d1010d5 (patch) | |
| tree | a1f5297cfdfd76d2f14aea367469c77e91cbee96 | |
| parent | 4e2fadad876b5f2ea5b5790b8a31dab300c685ff (diff) | |
Compiler: type inference bug.
The recent MIR-level select optimization failed to properly manage
the type information of the new kMirOpSelect node, resulting in a
type inference mismatch that trigered a reduction of optimization
level (should not have affected correctness).
Change-Id: I4e104050674c8667b9dff15a401ab230a46e7968
| -rw-r--r-- | src/compiler/dex/mir_optimization.cc | 7 | ||||
| -rw-r--r-- | src/compiler/dex/vreg_analysis.cc | 16 |
2 files changed, 11 insertions, 12 deletions
diff --git a/src/compiler/dex/mir_optimization.cc b/src/compiler/dex/mir_optimization.cc index 534550112a..74b13fe47e 100644 --- a/src/compiler/dex/mir_optimization.cc +++ b/src/compiler/dex/mir_optimization.cc @@ -418,6 +418,13 @@ bool MIRGraph::BasicBlockOpt(BasicBlock* bb) static_cast<bool*>(arena_->NewMem(sizeof(bool) * 1, false, ArenaAllocator::kAllocDFInfo)); mir->ssa_rep->fp_def[0] = if_true->ssa_rep->fp_def[0]; + // Match type of uses to def. + mir->ssa_rep->fp_use = + static_cast<bool*>(arena_->NewMem(sizeof(bool) * mir->ssa_rep->num_uses, false, + ArenaAllocator::kAllocDFInfo)); + for (int i = 0; i < mir->ssa_rep->num_uses; i++) { + mir->ssa_rep->fp_use[i] = mir->ssa_rep->fp_def[0]; + } /* * There is usually a Phi node in the join block for our two cases. If the * Phi node only contains our two cases as input, we will use the result diff --git a/src/compiler/dex/vreg_analysis.cc b/src/compiler/dex/vreg_analysis.cc index d4223f1ab1..c260933b3e 100644 --- a/src/compiler/dex/vreg_analysis.cc +++ b/src/compiler/dex/vreg_analysis.cc @@ -292,18 +292,10 @@ bool MIRGraph::InferTypeAndSize(BasicBlock* bb) is_high |= is_phi && rl_temp.wide && rl_temp.high_word; } /* - * TODO: cleaner fix - * We don't normally expect to see a Dalvik register - * definition used both as a floating point and core - * value. However, the instruction rewriting that occurs - * during verification can eliminate some type information, - * leaving us confused. The real fix here is either to - * add explicit type information to Dalvik byte codes, - * or to recognize THROW_VERIFICATION_ERROR as - * an unconditional branch and support dead code elimination. - * As a workaround we can detect this situation and - * disable register promotion (which is the only thing that - * relies on distinctions between core and fp usages. + * We don't normally expect to see a Dalvik register definition used both as a + * floating point and core value, though technically it could happen with constants. + * Until we have proper typing, detect this situation and disable register promotion + * (which relies on the distinction between core a fp usages). */ if ((defined_fp && (defined_core | defined_ref)) && ((cu_->disable_opt & (1 << kPromoteRegs)) == 0)) { |