From 0a810d2eab27cd097ebd09a44f0ce83aa608285b Mon Sep 17 00:00:00 2001 From: Vladimir Marko Date: Fri, 11 Jul 2014 14:44:36 +0100 Subject: Fix null pointer check elimination for catch entries. Remove the special treatment of catch blocks for null pointer check elimination and class initialization check elimination. In both cases this can help optimizing previously missed cases. In the null check case, this avoids incorrect optimization as exposed by the new test. Bug: 16230771 Change-Id: I834b7a1835d9ca8572f4f8d8516d93913c701ad1 --- compiler/dex/mir_optimization.cc | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'compiler/dex/mir_optimization.cc') diff --git a/compiler/dex/mir_optimization.cc b/compiler/dex/mir_optimization.cc index 869c48f66c..f69eea7fb0 100644 --- a/compiler/dex/mir_optimization.cc +++ b/compiler/dex/mir_optimization.cc @@ -737,11 +737,9 @@ bool MIRGraph::EliminateNullChecksAndInferTypes(BasicBlock* bb) { ArenaBitVector* ssa_regs_to_check = temp_bit_vector_; if (do_nce) { /* - * Set initial state. Be conservative with catch - * blocks and start with no assumptions about null check - * status (except for "this"). + * Set initial state. Catch blocks don't need any special treatment. */ - if ((bb->block_type == kEntryBlock) | bb->catch_entry) { + if (bb->block_type == kEntryBlock) { ssa_regs_to_check->ClearAllBits(); // Assume all ins are objects. for (uint16_t in_reg = cu_->num_dalvik_registers - cu_->num_ins; @@ -1047,12 +1045,11 @@ bool MIRGraph::EliminateClassInitChecks(BasicBlock* bb) { } /* - * Set initial state. Be conservative with catch - * blocks and start with no assumptions about class init check status. + * Set initial state. Catch blocks don't need any special treatment. */ ArenaBitVector* classes_to_check = temp_bit_vector_; DCHECK(classes_to_check != nullptr); - if ((bb->block_type == kEntryBlock) | bb->catch_entry) { + if (bb->block_type == kEntryBlock) { classes_to_check->SetInitialBits(temp_bit_vector_size_); } else if (bb->predecessors->Size() == 1) { BasicBlock* pred_bb = GetBasicBlock(bb->predecessors->Get(0)); -- cgit v1.2.3-59-g8ed1b