Lines Matching refs:block

36 static bool IsExitTryBoundaryIntoExitBlock(HBasicBlock* block) {
37 if (!block->IsSingleTryBoundary()) {
41 HTryBoundary* boundary = block->GetLastInstruction()->AsTryBoundary();
42 return block->GetPredecessors().size() == 1u &&
47 void GraphChecker::VisitBasicBlock(HBasicBlock* block) {
48 current_block_ = block;
50 // Check consistency with respect to predecessors of `block`.
54 sorted_predecessors.assign(block->GetPredecessors().begin(), block->GetPredecessors().end());
63 std::count(p->GetSuccessors().begin(), p->GetSuccessors().end(), block);
66 "Block %d lists %zu occurrences of block %d in its predecessors, whereas "
67 "block %d lists %zu occurrences of block %d in its successors.",
68 block->GetBlockId(), p_count_in_block_predecessors, p->GetBlockId(),
69 p->GetBlockId(), block_count_in_p_successors, block->GetBlockId()));
73 // Check consistency with respect to successors of `block`.
77 sorted_successors.assign(block->GetSuccessors().begin(), block->GetSuccessors().end());
86 std::count(s->GetPredecessors().begin(), s->GetPredecessors().end(), block);
89 "Block %d lists %zu occurrences of block %d in its successors, whereas "
90 "block %d lists %zu occurrences of block %d in its predecessors.",
91 block->GetBlockId(), s_count_in_block_successors, s->GetBlockId(),
92 s->GetBlockId(), block_count_in_s_predecessors, block->GetBlockId()));
96 // Ensure `block` ends with a branch instruction.
100 if (GetGraph()->IsInSsaForm() && !block->EndsWithControlFlowInstruction()) {
102 block->GetBlockId()));
106 // may be between the instructions if the Throw/Return(Void) is in a try block.
107 if (block->IsExitBlock()) {
108 for (HBasicBlock* predecessor : block->GetPredecessors()) {
113 AddError(StringPrintf("Unexpected instruction %s:%d jumps into the exit block.",
120 // Visit this block's list of phis.
121 for (HInstructionIterator it(block->GetPhis()); !it.Done(); it.Advance()) {
123 // Ensure this block's list of phis contains only phis.
128 if (current->GetNext() == nullptr && current != block->GetLastPhi()) {
129 AddError(StringPrintf("The recorded last phi of block %d does not match "
137 // Visit this block's list of instructions.
138 for (HInstructionIterator it(block->GetInstructions()); !it.Done(); it.Advance()) {
140 // Ensure this block's list of instructions does not contains phis.
145 if (current->GetNext() == nullptr && current != block->GetLastInstruction()) {
146 AddError(StringPrintf("The recorded last instruction of block %d does not match "
156 for (HBasicBlock* successor : block->GetNormalSuccessors()) {
158 AddError(StringPrintf("Catch block %d is a normal successor of block %d.",
160 block->GetBlockId()));
163 for (HBasicBlock* successor : block->GetExceptionalSuccessors()) {
165 AddError(StringPrintf("Normal block %d is an exceptional successor of block %d.",
167 block->GetBlockId()));
171 // Ensure dominated blocks have `block` as the dominator.
172 for (HBasicBlock* dominated : block->GetDominatedBlocks()) {
173 if (dominated->GetDominator() != block) {
175 block->GetBlockId(),
181 // block with multiple successors to a block with multiple
184 if (block->GetSuccessors().size() > 1) {
185 if (IsExitTryBoundaryIntoExitBlock(block)) {
188 for (HBasicBlock* successor : block->GetNormalSuccessors()) {
191 block->GetBlockId(),
199 if (block->IsCatchBlock()) {
200 if (block->IsTryBlock()) {
201 const HTryBoundary& try_entry = block->GetTryCatchInformation()->GetTryEntry();
202 AddError(StringPrintf("Catch blocks should not be try blocks but catch block %d "
204 block->GetBlockId(),
209 if (block->IsLoopHeader()) {
210 AddError(StringPrintf("Catch blocks should not be loop headers but catch block %d is.",
211 block->GetBlockId()));
214 for (HBasicBlock* predecessor : block->GetPredecessors()) {
216 if (block->IsTryBlock()) {
217 const HTryBoundary& stored_try_entry = block->GetTryCatchInformation()->GetTryEntry();
221 block->GetBlockId(),
228 block->GetBlockId(),
236 AddError(StringPrintf("Block %d is not a try block but try entry %s:%d follows "
238 block->GetBlockId(),
246 if (block->IsLoopHeader()) {
247 HandleLoop(block);
276 // Note that a normal-flow successor may be a catch block before CFG
281 "is not a catch block.",
292 AddError(StringPrintf("Exception handler block %d of %s:%d is listed multiple times.",
303 // Ensure that LoadException is the first instruction in a catch block.
305 AddError(StringPrintf("%s:%d is in a non-catch block %d.",
310 AddError(StringPrintf("%s:%d is not the first instruction in catch block %d.",
327 AddError(StringPrintf("%s %d in block %d not associated with any block.",
332 AddError(StringPrintf("%s %d in block %d associated with block %d.",
339 // Ensure the inputs of `instruction` are defined in a block of the graph.
346 "in a basic block of the control-flow graph.",
352 // Ensure the uses of `instruction` are defined in a block of the graph,
361 "in a basic block of the control-flow graph.",
413 AddError(StringPrintf("Instruction %s:%d in block %d does not dominate "
414 "use %s:%d in block %d.",
425 AddError(StringPrintf("Instruction %s:%d in block %d requires an environment "
442 "from block %d does not dominate instruction %d.",
463 // the catch block since we do not inline methods with try/catch.
476 AddError(StringPrintf("Instruction %s:%d throws into catch block %d "
517 AddError(StringPrintf("%s:%d does not jump to the exit block.",
527 AddError(StringPrintf("%s:%d does not jump to the exit block.",
644 // Ensure the pre-header block is first in the list of predecessors of a loop
645 // header and that the header block is its only successor.
657 AddError(StringPrintf("Loop defined by header %d contains a previously removed block %d.",
661 AddError(StringPrintf("Loop block %d not dominated by loop header %d.",
710 AddError(StringPrintf("Loop phi %d in block %d is its own first input.",
720 "Input %d at index %zu of phi %d from block %d does not have the "
728 AddError(StringPrintf("Phi %d in block %d does not have an expected phi type: %s",
736 // instructions caught by this catch block. We do not enforce this, however,
741 AddError(StringPrintf("Phi %d in catch block %d has zero inputs.",
749 AddError(StringPrintf("Phi %d in catch block %d has %zu inputs, "
765 "Phi %d in block %d has %zu inputs, "
766 "but block %d has %zu predecessors.",
771 // predecessor or from a block that dominates this predecessor.
778 "Input %d at index %zu of phi %d from block %d is not defined in "
779 "predecessor number %zu nor in a block dominating it.",
793 AddError(StringPrintf("Catch phis %d and %d in block %d are not sorted by their "
870 // Check that the number of block successors matches the switch count plus
871 // one for the default block.
872 HBasicBlock* block = instruction->GetBlock();
873 if (instruction->GetNumEntries() + 1u != block->GetSuccessors().size()) {
875 "%s instruction %d in block %d expects %u successors to the block, but found: %zu.",
878 block->GetBlockId(),
880 block->GetSuccessors().size()));
1002 HBasicBlock* block = instruction->GetBlock();
1003 if (!block->IsEntryBlock()) {
1005 "%s %d should be in the entry block but is in block %d.",
1008 block->GetBlockId()));