From 7e53b415e5e587cd7961978f6da7347248f40b29 Mon Sep 17 00:00:00 2001 From: Roland Levillain Date: Tue, 23 Sep 2014 10:50:22 +0100 Subject: Optimizing compiler: ensure loop header dominates loop's blocks. Change-Id: I6b2f1fdaac9f91dc5d9901cc2ad4c83745e90e70 --- compiler/optimizing/graph_checker.cc | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'compiler/optimizing/graph_checker.cc') diff --git a/compiler/optimizing/graph_checker.cc b/compiler/optimizing/graph_checker.cc index b05090b6a9..e36b1cdcfd 100644 --- a/compiler/optimizing/graph_checker.cc +++ b/compiler/optimizing/graph_checker.cc @@ -20,6 +20,8 @@ #include #include +#include "base/bit_vector-inl.h" + namespace art { void GraphChecker::VisitBasicBlock(HBasicBlock* block) { @@ -212,6 +214,19 @@ void SSAChecker::CheckLoop(HBasicBlock* loop_header) { << num_back_edges << " back edge(s)."; errors_.Insert(error.str()); } + + // Ensure all blocks in the loop are dominated by the loop header. + const ArenaBitVector& loop_blocks = + loop_header->GetLoopInformation()->GetBlocks(); + for (uint32_t i : loop_blocks.Indexes()) { + HBasicBlock* loop_block = GetGraph()->GetBlocks().Get(i); + if (!loop_header->Dominates(loop_block)) { + std::stringstream error; + error << "Loop block " << loop_block->GetBlockId() + << " not dominated by loop header " << id; + errors_.Insert(error.str()); + } + } } void SSAChecker::VisitInstruction(HInstruction* instruction) { -- cgit v1.2.3-59-g8ed1b