Quick: Finding upper half of kMirOpCheckPart2 should passthough empty blocks
Mir2Lir::InitReferenceVRegs trying to find throwing instruction for
kMirOpCheckPart2 should traverse possible empty blocks which compiler
optimizations could generate between them.
Change-Id: I2ab29dd36635fd4c4ef2dd81b51e571e206775e6
Signed-off-by: Pavel Vyssotski <pavel.n.vyssotski@intel.com>
diff --git a/compiler/dex/quick/codegen_util.cc b/compiler/dex/quick/codegen_util.cc
index bd479be..df72830 100644
--- a/compiler/dex/quick/codegen_util.cc
+++ b/compiler/dex/quick/codegen_util.cc
@@ -1378,11 +1378,16 @@
// In Mir2Lir::MethodBlockCodeGen() we have artificially moved the throwing
// instruction to the previous block. However, the MIRGraph data used above
// doesn't reflect that, so we still need to process that MIR insn here.
- DCHECK_EQ(bb->predecessors.size(), 1u);
- BasicBlock* pred_bb = mir_graph_->GetBasicBlock(bb->predecessors[0]);
- DCHECK(pred_bb != nullptr);
- DCHECK(pred_bb->last_mir_insn != nullptr);
- UpdateReferenceVRegsLocal(nullptr, pred_bb->last_mir_insn, references);
+ MIR* mir = nullptr;
+ BasicBlock* pred_bb = bb;
+ // Traverse empty blocks.
+ while (mir == nullptr && pred_bb->predecessors.size() == 1u) {
+ pred_bb = mir_graph_->GetBasicBlock(bb->predecessors[0]);
+ DCHECK(pred_bb != nullptr);
+ mir = pred_bb->last_mir_insn;
+ }
+ DCHECK(mir != nullptr);
+ UpdateReferenceVRegsLocal(nullptr, mir, references);
}
}