From 504b7882fbb841787e350f2da54b1fa9171ce82a Mon Sep 17 00:00:00 2001 From: Yevgeny Rouban Date: Wed, 1 Oct 2014 18:25:28 +0700 Subject: [PATCH] ART: fix NullCheckElimination to preserve MIR_IGNORE_NULL_CHECK If the MIRGraph::EliminateNullChecksAndInferTypes() function managed to prove that some regs are non-null then it sets the flag MIR_IGNORE_NULL_CHECK and resets this flag for all the other regs. If some previous optimizations have already set MIR_IGNORE_NULL_CHECK then it can be reset by EliminateNullChecksAndInferTypes. This way NullCheckElimination discards some optimization efforts. Optimization passes should not reset MIR_IGNORE_NULL_CHECK unless they 100% sure NullCheck is needed. This patch makes the NCE_TypeInference pass be conservative in resetting MIR_IGNORE_NULL_CHECK. Change-Id: I4ea74020968b5c5bd8e3af48211ffd4c6afd7f80 Signed-off-by: Yevgeny Rouban --- compiler/dex/mir_optimization.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/dex/mir_optimization.cc b/compiler/dex/mir_optimization.cc index dac71f6aa..fda6ef81f 100644 --- a/compiler/dex/mir_optimization.cc +++ b/compiler/dex/mir_optimization.cc @@ -936,7 +936,7 @@ bool MIRGraph::EliminateNullChecksAndInferTypes(BasicBlock* bb) { mir->optimization_flags |= MIR_IGNORE_NULL_CHECK; } else { // Do the null check. - mir->optimization_flags &= ~MIR_IGNORE_NULL_CHECK; + // Do not clear MIR_IGNORE_NULL_CHECK flag as it may be set by another optimization // Mark s_reg as null-checked ssa_regs_to_check->ClearBit(src_sreg); } -- 2.11.0