ART: Detached blocks should not be processed by compiler
It is possible for blocks to be detached. This means that 'successor_block_info->block'
may evaluate to 'NullBasicBlockId' The code should detect this case and handle it
appropriately.
Signed-off-by: vladimir.a.ivanov <vladimir.a.ivanov@intel.com
Signed-off-by: Niranjan Kumar <niranjan.kumar@intel.com
Change-Id: I410059cd2cbda342cc1380050c0972fcaa2b7a8e
diff --git a/compiler/dex/mir_graph.cc b/compiler/dex/mir_graph.cc
index 5741b0b..76c9815 100644
--- a/compiler/dex/mir_graph.cc
+++ b/compiler/dex/mir_graph.cc
@@ -191,14 +191,16 @@
bottom_block->successor_block_list_type = orig_block->successor_block_list_type;
bottom_block->successor_blocks = orig_block->successor_blocks;
orig_block->successor_block_list_type = kNotUsed;
- orig_block->successor_blocks = NULL;
+ orig_block->successor_blocks = nullptr;
GrowableArray<SuccessorBlockInfo*>::Iterator iterator(bottom_block->successor_blocks);
while (true) {
SuccessorBlockInfo* successor_block_info = iterator.Next();
- if (successor_block_info == NULL) break;
+ if (successor_block_info == nullptr) break;
BasicBlock* bb = GetBasicBlock(successor_block_info->block);
- bb->predecessors->Delete(orig_block->id);
- bb->predecessors->Insert(bottom_block->id);
+ if (bb != nullptr) {
+ bb->predecessors->Delete(orig_block->id);
+ bb->predecessors->Insert(bottom_block->id);
+ }
}
}
@@ -1691,11 +1693,13 @@
// We visited both taken and fallthrough. Now check if we have successors we need to visit.
if (have_successors_ == true) {
// Get information about next successor block.
- SuccessorBlockInfo* successor_block_info = successor_iter_.Next();
-
- // If we don't have anymore successors, return nullptr.
- if (successor_block_info != nullptr) {
- return mir_graph_->GetBasicBlock(successor_block_info->block);
+ for (SuccessorBlockInfo* successor_block_info = successor_iter_.Next();
+ successor_block_info != nullptr;
+ successor_block_info = successor_iter_.Next()) {
+ // If block was replaced by zero block, take next one.
+ if (successor_block_info->block != NullBasicBlockId) {
+ return mir_graph_->GetBasicBlock(successor_block_info->block);
+ }
}
}