From f776b92a0d52bb522043812dacb9c21ac11858e2 Mon Sep 17 00:00:00 2001 From: Nicolas Geoffray Date: Wed, 15 Apr 2015 18:22:45 +0100 Subject: Remove dead blocks for the blocks_ array. This prevents crashing because of structurally incorrect blocks. Also we now don't need to remove its instructions. Test case courtesy of Serguei I Katkov. Change-Id: Ia3ef9580549fc3546e8cd5f346079b1f0ceb2a61 --- compiler/optimizing/dominator_test.cc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'compiler/optimizing/dominator_test.cc') diff --git a/compiler/optimizing/dominator_test.cc b/compiler/optimizing/dominator_test.cc index 7623e421fd..61a7697301 100644 --- a/compiler/optimizing/dominator_test.cc +++ b/compiler/optimizing/dominator_test.cc @@ -36,7 +36,13 @@ static void TestCode(const uint16_t* data, const int* blocks, size_t blocks_leng ASSERT_EQ(graph->GetBlocks().Size(), blocks_length); for (size_t i = 0, e = blocks_length; i < e; ++i) { if (blocks[i] == -1) { - ASSERT_EQ(nullptr, graph->GetBlocks().Get(i)->GetDominator()); + if (graph->GetBlocks().Get(i) == nullptr) { + // Dead block. + } else { + // Only the entry block has no dominator. + ASSERT_EQ(nullptr, graph->GetBlocks().Get(i)->GetDominator()); + ASSERT_TRUE(graph->GetBlocks().Get(i)->IsEntryBlock()); + } } else { ASSERT_NE(nullptr, graph->GetBlocks().Get(i)->GetDominator()); ASSERT_EQ(blocks[i], graph->GetBlocks().Get(i)->GetDominator()->GetBlockId()); -- cgit v1.2.3-59-g8ed1b