diff options
author | 2017-05-04 14:15:08 -0700 | |
---|---|---|
committer | 2017-05-04 14:15:08 -0700 | |
commit | 4ae432df025804031ea89285dd9f89051124a966 (patch) | |
tree | 7eae9b85539dd305d7c0aa02c061e960719e9389 /compiler/optimizing/graph_checker.cc | |
parent | acac09dad3d5aa3922e6cdf54ff2e4fa6f176484 (diff) |
optimizing: Fix undefined behavior in graph checker
Checking a variable being null after dereference is undefed behavior
and the null check is often optimized out.
Change-Id: I4d80510af6d49def1f9f7bd82c25eb366169babb
Diffstat (limited to 'compiler/optimizing/graph_checker.cc')
-rw-r--r-- | compiler/optimizing/graph_checker.cc | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/compiler/optimizing/graph_checker.cc b/compiler/optimizing/graph_checker.cc index 6a140458a6..aea901dec7 100644 --- a/compiler/optimizing/graph_checker.cc +++ b/compiler/optimizing/graph_checker.cc @@ -338,19 +338,21 @@ void GraphChecker::VisitInstruction(HInstruction* instruction) { // Ensure the inputs of `instruction` are defined in a block of the graph. for (HInstruction* input : instruction->GetInputs()) { - const HInstructionList& list = input->IsPhi() - ? input->GetBlock()->GetPhis() - : input->GetBlock()->GetInstructions(); if (input->GetBlock() == nullptr) { AddError(StringPrintf("Input %d of instruction %d is not in any " "basic block of the control-flow graph.", input->GetId(), instruction->GetId())); - } else if (!list.Contains(input)) { - AddError(StringPrintf("Input %d of instruction %d is not defined " - "in a basic block of the control-flow graph.", - input->GetId(), - instruction->GetId())); + } else { + const HInstructionList& list = input->IsPhi() + ? input->GetBlock()->GetPhis() + : input->GetBlock()->GetInstructions(); + if (!list.Contains(input)) { + AddError(StringPrintf("Input %d of instruction %d is not defined " + "in a basic block of the control-flow graph.", + input->GetId(), + instruction->GetId())); + } } } |