diff options
author | 2016-03-22 11:54:37 +0000 | |
---|---|---|
committer | 2016-03-22 11:54:37 +0000 | |
commit | 937e6cd515bbe7ff2f255c8fcd40bf1a575a9a16 (patch) | |
tree | 90660b3d679cfbd87327e9cda5c783128f1b9a92 /compiler/optimizing/graph_checker.cc | |
parent | 1153282aa91292b740289ab7612a481e5c6bc167 (diff) |
Tighten art::HNeg type constraints on its input.
Ensure art::HNeg is only passed a type having the kind of
its input. For a boolean, byte, short, or char input, it
means HNeg's type should be int.
Bug: 27684275
Change-Id: Ic8442c62090a8ab65590754874a14a0deb7acd8d
Diffstat (limited to 'compiler/optimizing/graph_checker.cc')
-rw-r--r-- | compiler/optimizing/graph_checker.cc | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/compiler/optimizing/graph_checker.cc b/compiler/optimizing/graph_checker.cc index 11e3689a82..9c1ded2de9 100644 --- a/compiler/optimizing/graph_checker.cc +++ b/compiler/optimizing/graph_checker.cc @@ -917,6 +917,19 @@ void GraphChecker::VisitCondition(HCondition* op) { } } +void GraphChecker::VisitNeg(HNeg* instruction) { + VisitInstruction(instruction); + Primitive::Type input_type = instruction->InputAt(0)->GetType(); + Primitive::Type result_type = instruction->GetType(); + if (result_type != Primitive::PrimitiveKind(input_type)) { + AddError(StringPrintf("Binary operation %s %d has a result type different " + "from its input kind: %s vs %s.", + instruction->DebugName(), instruction->GetId(), + Primitive::PrettyDescriptor(result_type), + Primitive::PrettyDescriptor(input_type))); + } +} + void GraphChecker::VisitBinaryOperation(HBinaryOperation* op) { VisitInstruction(op); Primitive::Type lhs_type = op->InputAt(0)->GetType(); |