Lines Matching refs:block

34 static bool IsExitTryBoundaryIntoExitBlock(HBasicBlock* block) {
35 if (!block->IsSingleTryBoundary()) {
39 HTryBoundary* boundary = block->GetLastInstruction()->AsTryBoundary();
40 return block->GetPredecessors().size() == 1u &&
45 void GraphChecker::VisitBasicBlock(HBasicBlock* block) {
46 current_block_ = block;
48 // Check consistency with respect to predecessors of `block`.
52 sorted_predecessors.assign(block->GetPredecessors().begin(), block->GetPredecessors().end());
61 std::count(p->GetSuccessors().begin(), p->GetSuccessors().end(), block);
64 "Block %d lists %zu occurrences of block %d in its predecessors, whereas "
65 "block %d lists %zu occurrences of block %d in its successors.",
66 block->GetBlockId(), p_count_in_block_predecessors, p->GetBlockId(),
67 p->GetBlockId(), block_count_in_p_successors, block->GetBlockId()));
71 // Check consistency with respect to successors of `block`.
75 sorted_successors.assign(block->GetSuccessors().begin(), block->GetSuccessors().end());
84 std::count(s->GetPredecessors().begin(), s->GetPredecessors().end(), block);
87 "Block %d lists %zu occurrences of block %d in its successors, whereas "
88 "block %d lists %zu occurrences of block %d in its predecessors.",
89 block->GetBlockId(), s_count_in_block_successors, s->GetBlockId(),
90 s->GetBlockId(), block_count_in_s_predecessors, block->GetBlockId()));
94 // Ensure `block` ends with a branch instruction.
98 if (GetGraph()->IsInSsaForm() && !block->EndsWithControlFlowInstruction()) {
100 block->GetBlockId()));
104 // may be between the instructions if the Throw/Return(Void) is in a try block.
105 if (block->IsExitBlock()) {
106 for (HBasicBlock* predecessor : block->GetPredecessors()) {
111 AddError(StringPrintf("Unexpected instruction %s:%d jumps into the exit block.",
118 // Visit this block's list of phis.
119 for (HInstructionIterator it(block->GetPhis()); !it.Done(); it.Advance()) {
121 // Ensure this block's list of phis contains only phis.
126 if (current->GetNext() == nullptr && current != block->GetLastPhi()) {
127 AddError(StringPrintf("The recorded last phi of block %d does not match "
135 // Visit this block's list of instructions.
136 for (HInstructionIterator it(block->GetInstructions()); !it.Done(); it.Advance()) {
138 // Ensure this block's list of instructions does not contains phis.
143 if (current->GetNext() == nullptr && current != block->GetLastInstruction()) {
144 AddError(StringPrintf("The recorded last instruction of block %d does not match "
154 for (HBasicBlock* successor : block->GetNormalSuccessors()) {
156 AddError(StringPrintf("Catch block %d is a normal successor of block %d.",
158 block->GetBlockId()));
161 for (HBasicBlock* successor : block->GetExceptionalSuccessors()) {
163 AddError(StringPrintf("Normal block %d is an exceptional successor of block %d.",
165 block->GetBlockId()));
169 // Ensure dominated blocks have `block` as the dominator.
170 for (HBasicBlock* dominated : block->GetDominatedBlocks()) {
171 if (dominated->GetDominator() != block) {
173 block->GetBlockId(),
179 // block with multiple successors to a block with multiple
182 if (block->GetSuccessors().size() > 1) {
183 if (IsExitTryBoundaryIntoExitBlock(block)) {
186 for (HBasicBlock* successor : block->GetNormalSuccessors()) {
189 block->GetBlockId(),
197 if (block->IsCatchBlock()) {
198 if (block->IsTryBlock()) {
199 const HTryBoundary& try_entry = block->GetTryCatchInformation()->GetTryEntry();
200 AddError(StringPrintf("Catch blocks should not be try blocks but catch block %d "
202 block->GetBlockId(),
207 if (block->IsLoopHeader()) {
208 AddError(StringPrintf("Catch blocks should not be loop headers but catch block %d is.",
209 block->GetBlockId()));
212 for (HBasicBlock* predecessor : block->GetPredecessors()) {
214 if (block->IsTryBlock()) {
215 const HTryBoundary& stored_try_entry = block->GetTryCatchInformation()->GetTryEntry();
219 block->GetBlockId(),
226 block->GetBlockId(),
234 AddError(StringPrintf("Block %d is not a try block but try entry %s:%d follows "
236 block->GetBlockId(),
244 if (block->IsLoopHeader()) {
245 HandleLoop(block);
274 // Note that a normal-flow successor may be a catch block before CFG
279 "is not a catch block.",
290 AddError(StringPrintf("Exception handler block %d of %s:%d is listed multiple times.",
301 // Ensure that LoadException is the first instruction in a catch block.
303 AddError(StringPrintf("%s:%d is in a non-catch block %d.",
308 AddError(StringPrintf("%s:%d is not the first instruction in catch block %d.",
325 AddError(StringPrintf("%s %d in block %d not associated with any block.",
330 AddError(StringPrintf("%s %d in block %d associated with block %d.",
337 // 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.",
411 AddError(StringPrintf("Instruction %s:%d in block %d does not dominate "
412 "use %s:%d in block %d.",
423 AddError(StringPrintf("Instruction %s:%d in block %d requires an environment "
440 "from block %d does not dominate instruction %d.",
462 // the catch block since we do not inline methods with try/catch.
475 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.",
702 AddError(StringPrintf("Loop phi %d in block %d is its own first input.",
712 "Input %d at index %zu of phi %d from block %d does not have the "
720 AddError(StringPrintf("Phi %d in block %d does not have an expected phi type: %s",
728 // instructions caught by this catch block. We do not enforce this, however,
734 AddError(StringPrintf("Phi %d in catch block %d has zero inputs.",
742 AddError(StringPrintf("Phi %d in catch block %d has %zu inputs, "
758 "Phi %d in block %d has %zu inputs, "
759 "but block %d has %zu predecessors.",
764 // predecessor or from a block that dominates this predecessor.
771 "Input %d at index %zu of phi %d from block %d is not defined in "
772 "predecessor number %zu nor in a block dominating it.",
786 AddError(StringPrintf("Catch phis %d and %d in block %d are not sorted by their "
863 // Check that the number of block successors matches the switch count plus
864 // one for the default block.
865 HBasicBlock* block = instruction->GetBlock();
866 if (instruction->GetNumEntries() + 1u != block->GetSuccessors().size()) {
868 "%s instruction %d in block %d expects %u successors to the block, but found: %zu.",
871 block->GetBlockId(),
873 block->GetSuccessors().size()));
995 HBasicBlock* block = instruction->GetBlock();
996 if (!block->IsEntryBlock()) {
998 "%s %d should be in the entry block but is in block %d.",
1001 block->GetBlockId()));