summaryrefslogtreecommitdiff
path: root/compiler/optimizing/graph_checker.cc
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/optimizing/graph_checker.cc')
-rw-r--r--compiler/optimizing/graph_checker.cc59
1 files changed, 27 insertions, 32 deletions
diff --git a/compiler/optimizing/graph_checker.cc b/compiler/optimizing/graph_checker.cc
index 9ea4b2dab4..96837a8266 100644
--- a/compiler/optimizing/graph_checker.cc
+++ b/compiler/optimizing/graph_checker.cc
@@ -342,36 +342,34 @@ void GraphChecker::VisitInstruction(HInstruction* instruction) {
// Ensure the uses of `instruction` are defined in a block of the graph,
// and the entry in the use list is consistent.
- for (HUseIterator<HInstruction*> use_it(instruction->GetUses());
- !use_it.Done(); use_it.Advance()) {
- HInstruction* use = use_it.Current()->GetUser();
- const HInstructionList& list = use->IsPhi()
- ? use->GetBlock()->GetPhis()
- : use->GetBlock()->GetInstructions();
- if (!list.Contains(use)) {
+ for (const HUseListNode<HInstruction*>& use : instruction->GetUses()) {
+ HInstruction* user = use.GetUser();
+ const HInstructionList& list = user->IsPhi()
+ ? user->GetBlock()->GetPhis()
+ : user->GetBlock()->GetInstructions();
+ if (!list.Contains(user)) {
AddError(StringPrintf("User %s:%d of instruction %d is not defined "
"in a basic block of the control-flow graph.",
- use->DebugName(),
- use->GetId(),
+ user->DebugName(),
+ user->GetId(),
instruction->GetId()));
}
- size_t use_index = use_it.Current()->GetIndex();
- if ((use_index >= use->InputCount()) || (use->InputAt(use_index) != instruction)) {
+ size_t use_index = use.GetIndex();
+ if ((use_index >= user->InputCount()) || (user->InputAt(use_index) != instruction)) {
AddError(StringPrintf("User %s:%d of instruction %s:%d has a wrong "
"UseListNode index.",
- use->DebugName(),
- use->GetId(),
+ user->DebugName(),
+ user->GetId(),
instruction->DebugName(),
instruction->GetId()));
}
}
// Ensure the environment uses entries are consistent.
- for (HUseIterator<HEnvironment*> use_it(instruction->GetEnvUses());
- !use_it.Done(); use_it.Advance()) {
- HEnvironment* use = use_it.Current()->GetUser();
- size_t use_index = use_it.Current()->GetIndex();
- if ((use_index >= use->Size()) || (use->GetInstructionAt(use_index) != instruction)) {
+ for (const HUseListNode<HEnvironment*>& use : instruction->GetEnvUses()) {
+ HEnvironment* user = use.GetUser();
+ size_t use_index = use.GetIndex();
+ if ((use_index >= user->Size()) || (user->GetInstructionAt(use_index) != instruction)) {
AddError(StringPrintf("Environment user of %s:%d has a wrong "
"UseListNode index.",
instruction->DebugName(),
@@ -383,13 +381,11 @@ void GraphChecker::VisitInstruction(HInstruction* instruction) {
for (size_t i = 0, e = instruction->InputCount(); i < e; ++i) {
HUserRecord<HInstruction*> input_record = instruction->InputRecordAt(i);
HInstruction* input = input_record.GetInstruction();
- HUseListNode<HInstruction*>* use_node = input_record.GetUseNode();
- size_t use_index = use_node->GetIndex();
- if ((use_node == nullptr)
- || !input->GetUses().Contains(use_node)
- || (use_index >= e)
- || (use_index != i)) {
- AddError(StringPrintf("Instruction %s:%d has an invalid pointer to use entry "
+ if ((input_record.GetBeforeUseNode() == input->GetUses().end()) ||
+ (input_record.GetUseNode() == input->GetUses().end()) ||
+ !input->GetUses().ContainsNode(*input_record.GetUseNode()) ||
+ (input_record.GetUseNode()->GetIndex() != i)) {
+ AddError(StringPrintf("Instruction %s:%d has an invalid iterator before use entry "
"at input %u (%s:%d).",
instruction->DebugName(),
instruction->GetId(),
@@ -400,18 +396,17 @@ void GraphChecker::VisitInstruction(HInstruction* instruction) {
}
// Ensure an instruction dominates all its uses.
- for (HUseIterator<HInstruction*> use_it(instruction->GetUses());
- !use_it.Done(); use_it.Advance()) {
- HInstruction* use = use_it.Current()->GetUser();
- if (!use->IsPhi() && !instruction->StrictlyDominates(use)) {
+ for (const HUseListNode<HInstruction*>& use : instruction->GetUses()) {
+ HInstruction* user = use.GetUser();
+ if (!user->IsPhi() && !instruction->StrictlyDominates(user)) {
AddError(StringPrintf("Instruction %s:%d in block %d does not dominate "
"use %s:%d in block %d.",
instruction->DebugName(),
instruction->GetId(),
current_block_->GetBlockId(),
- use->DebugName(),
- use->GetId(),
- use->GetBlock()->GetBlockId()));
+ user->DebugName(),
+ user->GetId(),
+ user->GetBlock()->GetBlockId()));
}
}