From 937e6cd515bbe7ff2f255c8fcd40bf1a575a9a16 Mon Sep 17 00:00:00 2001 From: Roland Levillain Date: Tue, 22 Mar 2016 11:54:37 +0000 Subject: 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 --- compiler/optimizing/graph_checker.cc | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'compiler/optimizing/graph_checker.cc') 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(); -- cgit v1.2.3-59-g8ed1b