blob: 4ebb1363cc83930c85e4ecd92ebb606de0f7847d [file] [log] [blame]
Roland Levillainccc07a92014-09-16 14:48:16 +01001/*
2 * Copyright (C) 2014 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#include "graph_checker.h"
18
Roland Levillainccc07a92014-09-16 14:48:16 +010019#include <map>
Nicolas Geoffray7c5367b2014-12-17 10:13:46 +000020#include <string>
Roland Levillainccc07a92014-09-16 14:48:16 +010021
Roland Levillain7e53b412014-09-23 10:50:22 +010022#include "base/bit_vector-inl.h"
Roland Levillain5c4405e2015-01-21 11:39:58 +000023#include "base/stringprintf.h"
Roland Levillain7e53b412014-09-23 10:50:22 +010024
Roland Levillainccc07a92014-09-16 14:48:16 +010025namespace art {
26
27void GraphChecker::VisitBasicBlock(HBasicBlock* block) {
28 current_block_ = block;
29
30 // Check consistency with respect to predecessors of `block`.
31 const GrowableArray<HBasicBlock*>& predecessors = block->GetPredecessors();
32 std::map<HBasicBlock*, size_t> predecessors_count;
33 for (size_t i = 0, e = predecessors.Size(); i < e; ++i) {
34 HBasicBlock* p = predecessors.Get(i);
35 ++predecessors_count[p];
36 }
37 for (auto& pc : predecessors_count) {
38 HBasicBlock* p = pc.first;
39 size_t p_count_in_block_predecessors = pc.second;
40 const GrowableArray<HBasicBlock*>& p_successors = p->GetSuccessors();
41 size_t block_count_in_p_successors = 0;
42 for (size_t j = 0, f = p_successors.Size(); j < f; ++j) {
43 if (p_successors.Get(j) == block) {
44 ++block_count_in_p_successors;
45 }
46 }
47 if (p_count_in_block_predecessors != block_count_in_p_successors) {
Roland Levillain5c4405e2015-01-21 11:39:58 +000048 AddError(StringPrintf(
49 "Block %d lists %zu occurrences of block %d in its predecessors, whereas "
50 "block %d lists %zu occurrences of block %d in its successors.",
51 block->GetBlockId(), p_count_in_block_predecessors, p->GetBlockId(),
52 p->GetBlockId(), block_count_in_p_successors, block->GetBlockId()));
Roland Levillainccc07a92014-09-16 14:48:16 +010053 }
54 }
55
56 // Check consistency with respect to successors of `block`.
57 const GrowableArray<HBasicBlock*>& successors = block->GetSuccessors();
58 std::map<HBasicBlock*, size_t> successors_count;
59 for (size_t i = 0, e = successors.Size(); i < e; ++i) {
60 HBasicBlock* s = successors.Get(i);
61 ++successors_count[s];
62 }
63 for (auto& sc : successors_count) {
64 HBasicBlock* s = sc.first;
65 size_t s_count_in_block_successors = sc.second;
66 const GrowableArray<HBasicBlock*>& s_predecessors = s->GetPredecessors();
67 size_t block_count_in_s_predecessors = 0;
68 for (size_t j = 0, f = s_predecessors.Size(); j < f; ++j) {
69 if (s_predecessors.Get(j) == block) {
70 ++block_count_in_s_predecessors;
71 }
72 }
73 if (s_count_in_block_successors != block_count_in_s_predecessors) {
Roland Levillain5c4405e2015-01-21 11:39:58 +000074 AddError(StringPrintf(
75 "Block %d lists %zu occurrences of block %d in its successors, whereas "
76 "block %d lists %zu occurrences of block %d in its predecessors.",
77 block->GetBlockId(), s_count_in_block_successors, s->GetBlockId(),
78 s->GetBlockId(), block_count_in_s_predecessors, block->GetBlockId()));
Roland Levillainccc07a92014-09-16 14:48:16 +010079 }
80 }
81
82 // Ensure `block` ends with a branch instruction.
83 HInstruction* last_inst = block->GetLastInstruction();
84 if (last_inst == nullptr || !last_inst->IsControlFlow()) {
Roland Levillain5c4405e2015-01-21 11:39:58 +000085 AddError(StringPrintf("Block %d does not end with a branch instruction.",
86 block->GetBlockId()));
Roland Levillainccc07a92014-09-16 14:48:16 +010087 }
88
89 // Visit this block's list of phis.
90 for (HInstructionIterator it(block->GetPhis()); !it.Done(); it.Advance()) {
91 // Ensure this block's list of phis contains only phis.
92 if (!it.Current()->IsPhi()) {
Roland Levillain5c4405e2015-01-21 11:39:58 +000093 AddError(StringPrintf("Block %d has a non-phi in its phi list.",
94 current_block_->GetBlockId()));
Roland Levillainccc07a92014-09-16 14:48:16 +010095 }
96 it.Current()->Accept(this);
97 }
98
99 // Visit this block's list of instructions.
100 for (HInstructionIterator it(block->GetInstructions()); !it.Done();
101 it.Advance()) {
102 // Ensure this block's list of instructions does not contains phis.
103 if (it.Current()->IsPhi()) {
Roland Levillain5c4405e2015-01-21 11:39:58 +0000104 AddError(StringPrintf("Block %d has a phi in its non-phi list.",
105 current_block_->GetBlockId()));
Roland Levillainccc07a92014-09-16 14:48:16 +0100106 }
107 it.Current()->Accept(this);
108 }
109}
110
111void GraphChecker::VisitInstruction(HInstruction* instruction) {
Nicolas Geoffray7c5367b2014-12-17 10:13:46 +0000112 if (seen_ids_.IsBitSet(instruction->GetId())) {
Roland Levillain5c4405e2015-01-21 11:39:58 +0000113 AddError(StringPrintf("Instruction id %d is duplicate in graph.",
114 instruction->GetId()));
Nicolas Geoffray7c5367b2014-12-17 10:13:46 +0000115 } else {
116 seen_ids_.SetBit(instruction->GetId());
117 }
118
Roland Levillainccc07a92014-09-16 14:48:16 +0100119 // Ensure `instruction` is associated with `current_block_`.
Roland Levillain5c4405e2015-01-21 11:39:58 +0000120 if (instruction->GetBlock() == nullptr) {
121 AddError(StringPrintf("%s %d in block %d not associated with any block.",
122 instruction->IsPhi() ? "Phi" : "Instruction",
123 instruction->GetId(),
124 current_block_->GetBlockId()));
125 } else if (instruction->GetBlock() != current_block_) {
126 AddError(StringPrintf("%s %d in block %d associated with block %d.",
127 instruction->IsPhi() ? "Phi" : "Instruction",
128 instruction->GetId(),
129 current_block_->GetBlockId(),
130 instruction->GetBlock()->GetBlockId()));
Roland Levillainccc07a92014-09-16 14:48:16 +0100131 }
Roland Levillain6b469232014-09-25 10:10:38 +0100132
133 // Ensure the inputs of `instruction` are defined in a block of the graph.
134 for (HInputIterator input_it(instruction); !input_it.Done();
135 input_it.Advance()) {
136 HInstruction* input = input_it.Current();
137 const HInstructionList& list = input->IsPhi()
138 ? input->GetBlock()->GetPhis()
139 : input->GetBlock()->GetInstructions();
140 if (!list.Contains(input)) {
Roland Levillain5c4405e2015-01-21 11:39:58 +0000141 AddError(StringPrintf("Input %d of instruction %d is not defined "
142 "in a basic block of the control-flow graph.",
143 input->GetId(),
144 instruction->GetId()));
Roland Levillain6b469232014-09-25 10:10:38 +0100145 }
146 }
147
148 // Ensure the uses of `instruction` are defined in a block of the graph.
David Brazdiled596192015-01-23 10:39:45 +0000149 for (HUseIterator<HInstruction*> use_it(instruction->GetUses());
Roland Levillain6b469232014-09-25 10:10:38 +0100150 !use_it.Done(); use_it.Advance()) {
151 HInstruction* use = use_it.Current()->GetUser();
152 const HInstructionList& list = use->IsPhi()
153 ? use->GetBlock()->GetPhis()
154 : use->GetBlock()->GetInstructions();
155 if (!list.Contains(use)) {
Nicolas Geoffray276d9da2015-02-02 18:24:11 +0000156 AddError(StringPrintf("User %s:%d of instruction %d is not defined "
Roland Levillain5c4405e2015-01-21 11:39:58 +0000157 "in a basic block of the control-flow graph.",
Nicolas Geoffray276d9da2015-02-02 18:24:11 +0000158 use->DebugName(),
Roland Levillain5c4405e2015-01-21 11:39:58 +0000159 use->GetId(),
160 instruction->GetId()));
Roland Levillain6b469232014-09-25 10:10:38 +0100161 }
162 }
Roland Levillainccc07a92014-09-16 14:48:16 +0100163}
164
165void SSAChecker::VisitBasicBlock(HBasicBlock* block) {
166 super_type::VisitBasicBlock(block);
167
168 // Ensure there is no critical edge (i.e., an edge connecting a
169 // block with multiple successors to a block with multiple
170 // predecessors).
171 if (block->GetSuccessors().Size() > 1) {
172 for (size_t j = 0; j < block->GetSuccessors().Size(); ++j) {
173 HBasicBlock* successor = block->GetSuccessors().Get(j);
174 if (successor->GetPredecessors().Size() > 1) {
Roland Levillain5c4405e2015-01-21 11:39:58 +0000175 AddError(StringPrintf("Critical edge between blocks %d and %d.",
176 block->GetBlockId(),
177 successor->GetBlockId()));
Roland Levillainccc07a92014-09-16 14:48:16 +0100178 }
179 }
180 }
Roland Levillain6b879dd2014-09-22 17:13:44 +0100181
182 if (block->IsLoopHeader()) {
183 CheckLoop(block);
184 }
185}
186
187void SSAChecker::CheckLoop(HBasicBlock* loop_header) {
188 int id = loop_header->GetBlockId();
189
190 // Ensure the pre-header block is first in the list of
191 // predecessors of a loop header.
192 if (!loop_header->IsLoopPreHeaderFirstPredecessor()) {
Roland Levillain5c4405e2015-01-21 11:39:58 +0000193 AddError(StringPrintf(
194 "Loop pre-header is not the first predecessor of the loop header %d.",
195 id));
Roland Levillain6b879dd2014-09-22 17:13:44 +0100196 }
197
198 // Ensure the loop header has only two predecessors and that only the
199 // second one is a back edge.
Roland Levillain5c4405e2015-01-21 11:39:58 +0000200 size_t num_preds = loop_header->GetPredecessors().Size();
201 if (num_preds < 2) {
202 AddError(StringPrintf(
203 "Loop header %d has less than two predecessors: %zu.",
204 id,
205 num_preds));
206 } else if (num_preds > 2) {
207 AddError(StringPrintf(
208 "Loop header %d has more than two predecessors: %zu.",
209 id,
210 num_preds));
Roland Levillain6b879dd2014-09-22 17:13:44 +0100211 } else {
212 HLoopInformation* loop_information = loop_header->GetLoopInformation();
213 HBasicBlock* first_predecessor = loop_header->GetPredecessors().Get(0);
214 if (loop_information->IsBackEdge(first_predecessor)) {
Roland Levillain5c4405e2015-01-21 11:39:58 +0000215 AddError(StringPrintf(
216 "First predecessor of loop header %d is a back edge.",
217 id));
Roland Levillain6b879dd2014-09-22 17:13:44 +0100218 }
219 HBasicBlock* second_predecessor = loop_header->GetPredecessors().Get(1);
220 if (!loop_information->IsBackEdge(second_predecessor)) {
Roland Levillain5c4405e2015-01-21 11:39:58 +0000221 AddError(StringPrintf(
222 "Second predecessor of loop header %d is not a back edge.",
223 id));
Roland Levillain6b879dd2014-09-22 17:13:44 +0100224 }
225 }
226
227 // Ensure there is only one back edge per loop.
228 size_t num_back_edges =
229 loop_header->GetLoopInformation()->GetBackEdges().Size();
Roland Levillain5c4405e2015-01-21 11:39:58 +0000230 if (num_back_edges == 0) {
231 AddError(StringPrintf(
232 "Loop defined by header %d has no back edge.",
233 id));
234 } else if (num_back_edges > 1) {
235 AddError(StringPrintf(
236 "Loop defined by header %d has several back edges: %zu.",
237 id,
238 num_back_edges));
Roland Levillain6b879dd2014-09-22 17:13:44 +0100239 }
Roland Levillain7e53b412014-09-23 10:50:22 +0100240
241 // Ensure all blocks in the loop are dominated by the loop header.
242 const ArenaBitVector& loop_blocks =
243 loop_header->GetLoopInformation()->GetBlocks();
244 for (uint32_t i : loop_blocks.Indexes()) {
245 HBasicBlock* loop_block = GetGraph()->GetBlocks().Get(i);
246 if (!loop_header->Dominates(loop_block)) {
Roland Levillain5c4405e2015-01-21 11:39:58 +0000247 AddError(StringPrintf("Loop block %d not dominated by loop header %d.",
248 loop_block->GetBlockId(),
249 id));
Roland Levillain7e53b412014-09-23 10:50:22 +0100250 }
251 }
Roland Levillainccc07a92014-09-16 14:48:16 +0100252}
253
254void SSAChecker::VisitInstruction(HInstruction* instruction) {
255 super_type::VisitInstruction(instruction);
256
Roland Levillaina8069ce2014-10-01 10:48:29 +0100257 // Ensure an instruction dominates all its uses.
David Brazdiled596192015-01-23 10:39:45 +0000258 for (HUseIterator<HInstruction*> use_it(instruction->GetUses());
Roland Levillaina8069ce2014-10-01 10:48:29 +0100259 !use_it.Done(); use_it.Advance()) {
260 HInstruction* use = use_it.Current()->GetUser();
Roland Levillain6c82d402014-10-13 16:10:27 +0100261 if (!use->IsPhi() && !instruction->StrictlyDominates(use)) {
Roland Levillain5c4405e2015-01-21 11:39:58 +0000262 AddError(StringPrintf("Instruction %d in block %d does not dominate "
263 "use %d in block %d.",
264 instruction->GetId(), current_block_->GetBlockId(),
265 use->GetId(), use->GetBlock()->GetBlockId()));
Roland Levillainccc07a92014-09-16 14:48:16 +0100266 }
267 }
Roland Levillaina8069ce2014-10-01 10:48:29 +0100268
269 // Ensure an instruction having an environment is dominated by the
270 // instructions contained in the environment.
271 HEnvironment* environment = instruction->GetEnvironment();
272 if (environment != nullptr) {
273 for (size_t i = 0, e = environment->Size(); i < e; ++i) {
274 HInstruction* env_instruction = environment->GetInstructionAt(i);
275 if (env_instruction != nullptr
Roland Levillain6c82d402014-10-13 16:10:27 +0100276 && !env_instruction->StrictlyDominates(instruction)) {
Roland Levillain5c4405e2015-01-21 11:39:58 +0000277 AddError(StringPrintf("Instruction %d in environment of instruction %d "
278 "from block %d does not dominate instruction %d.",
279 env_instruction->GetId(),
280 instruction->GetId(),
281 current_block_->GetBlockId(),
282 instruction->GetId()));
Roland Levillaina8069ce2014-10-01 10:48:29 +0100283 }
284 }
285 }
Roland Levillainccc07a92014-09-16 14:48:16 +0100286}
287
Roland Levillain6b879dd2014-09-22 17:13:44 +0100288void SSAChecker::VisitPhi(HPhi* phi) {
289 VisitInstruction(phi);
290
291 // Ensure the first input of a phi is not itself.
292 if (phi->InputAt(0) == phi) {
Roland Levillain5c4405e2015-01-21 11:39:58 +0000293 AddError(StringPrintf("Loop phi %d in block %d is its own first input.",
294 phi->GetId(),
295 phi->GetBlock()->GetBlockId()));
Roland Levillain6b879dd2014-09-22 17:13:44 +0100296 }
297
Roland Levillain5c4405e2015-01-21 11:39:58 +0000298 // Ensure the number of inputs of a phi is the same as the number of
Roland Levillain6b879dd2014-09-22 17:13:44 +0100299 // its predecessors.
300 const GrowableArray<HBasicBlock*>& predecessors =
301 phi->GetBlock()->GetPredecessors();
302 if (phi->InputCount() != predecessors.Size()) {
Roland Levillain5c4405e2015-01-21 11:39:58 +0000303 AddError(StringPrintf(
304 "Phi %d in block %d has %zu inputs, "
305 "but block %d has %zu predecessors.",
306 phi->GetId(), phi->GetBlock()->GetBlockId(), phi->InputCount(),
307 phi->GetBlock()->GetBlockId(), predecessors.Size()));
Roland Levillain6b879dd2014-09-22 17:13:44 +0100308 } else {
309 // Ensure phi input at index I either comes from the Ith
310 // predecessor or from a block that dominates this predecessor.
311 for (size_t i = 0, e = phi->InputCount(); i < e; ++i) {
312 HInstruction* input = phi->InputAt(i);
313 HBasicBlock* predecessor = predecessors.Get(i);
314 if (!(input->GetBlock() == predecessor
315 || input->GetBlock()->Dominates(predecessor))) {
Roland Levillain5c4405e2015-01-21 11:39:58 +0000316 AddError(StringPrintf(
317 "Input %d at index %zu of phi %d from block %d is not defined in "
318 "predecessor number %zu nor in a block dominating it.",
319 input->GetId(), i, phi->GetId(), phi->GetBlock()->GetBlockId(),
320 i));
Roland Levillain6b879dd2014-09-22 17:13:44 +0100321 }
322 }
323 }
324}
325
Nicolas Geoffray31596742014-11-24 15:28:45 +0000326static Primitive::Type PrimitiveKind(Primitive::Type type) {
327 switch (type) {
328 case Primitive::kPrimBoolean:
329 case Primitive::kPrimByte:
330 case Primitive::kPrimShort:
331 case Primitive::kPrimChar:
332 case Primitive::kPrimInt:
333 return Primitive::kPrimInt;
334 default:
335 return type;
336 }
337}
338
Nicolas Geoffray9ee66182015-01-16 12:35:40 +0000339void SSAChecker::VisitIf(HIf* instruction) {
340 VisitInstruction(instruction);
341 HInstruction* input = instruction->InputAt(0);
342 if (input->IsIntConstant()) {
343 int value = input->AsIntConstant()->GetValue();
344 if (value != 0 && value != 1) {
Roland Levillain5c4405e2015-01-21 11:39:58 +0000345 AddError(StringPrintf(
346 "If instruction %d has a non-Boolean constant input "
347 "whose value is: %d.",
348 instruction->GetId(),
349 value));
Nicolas Geoffray9ee66182015-01-16 12:35:40 +0000350 }
351 } else if (instruction->InputAt(0)->GetType() != Primitive::kPrimBoolean) {
Roland Levillain5c4405e2015-01-21 11:39:58 +0000352 AddError(StringPrintf(
353 "If instruction %d has a non-Boolean input type: %s.",
354 instruction->GetId(),
355 Primitive::PrettyDescriptor(instruction->InputAt(0)->GetType())));
Nicolas Geoffray9ee66182015-01-16 12:35:40 +0000356 }
357}
358
Nicolas Geoffray31596742014-11-24 15:28:45 +0000359void SSAChecker::VisitCondition(HCondition* op) {
360 VisitInstruction(op);
Nicolas Geoffray31596742014-11-24 15:28:45 +0000361 if (op->GetType() != Primitive::kPrimBoolean) {
Roland Levillain5c4405e2015-01-21 11:39:58 +0000362 AddError(StringPrintf(
363 "Condition %s %d has a non-Boolean result type: %s.",
364 op->DebugName(), op->GetId(),
365 Primitive::PrettyDescriptor(op->GetType())));
Nicolas Geoffray31596742014-11-24 15:28:45 +0000366 }
Nicolas Geoffray9ee66182015-01-16 12:35:40 +0000367 HInstruction* lhs = op->InputAt(0);
368 HInstruction* rhs = op->InputAt(1);
Roland Levillainaecbd262015-01-19 12:44:01 +0000369 if (lhs->GetType() == Primitive::kPrimNot) {
370 if (!op->IsEqual() && !op->IsNotEqual()) {
Roland Levillain5c4405e2015-01-21 11:39:58 +0000371 AddError(StringPrintf(
372 "Condition %s %d uses an object as left-hand side input.",
373 op->DebugName(), op->GetId()));
Roland Levillainaecbd262015-01-19 12:44:01 +0000374 }
375 if (rhs->IsIntConstant() && rhs->AsIntConstant()->GetValue() != 0) {
Roland Levillain5c4405e2015-01-21 11:39:58 +0000376 AddError(StringPrintf(
377 "Condition %s %d compares an object with a non-zero integer: %d.",
378 op->DebugName(), op->GetId(),
379 rhs->AsIntConstant()->GetValue()));
Nicolas Geoffray9ee66182015-01-16 12:35:40 +0000380 }
Roland Levillainaecbd262015-01-19 12:44:01 +0000381 } else if (rhs->GetType() == Primitive::kPrimNot) {
382 if (!op->IsEqual() && !op->IsNotEqual()) {
Roland Levillain5c4405e2015-01-21 11:39:58 +0000383 AddError(StringPrintf(
384 "Condition %s %d uses an object as right-hand side input.",
385 op->DebugName(), op->GetId()));
Roland Levillainaecbd262015-01-19 12:44:01 +0000386 }
387 if (lhs->IsIntConstant() && lhs->AsIntConstant()->GetValue() != 0) {
Roland Levillain5c4405e2015-01-21 11:39:58 +0000388 AddError(StringPrintf(
389 "Condition %s %d compares a non-zero integer with an object: %d.",
390 op->DebugName(), op->GetId(),
391 lhs->AsIntConstant()->GetValue()));
Nicolas Geoffray9ee66182015-01-16 12:35:40 +0000392 }
393 } else if (PrimitiveKind(lhs->GetType()) != PrimitiveKind(rhs->GetType())) {
Roland Levillain5c4405e2015-01-21 11:39:58 +0000394 AddError(StringPrintf(
395 "Condition %s %d has inputs of different types: "
396 "%s, and %s.",
397 op->DebugName(), op->GetId(),
398 Primitive::PrettyDescriptor(lhs->GetType()),
399 Primitive::PrettyDescriptor(rhs->GetType())));
Nicolas Geoffray9ee66182015-01-16 12:35:40 +0000400 }
Nicolas Geoffray31596742014-11-24 15:28:45 +0000401}
402
403void SSAChecker::VisitBinaryOperation(HBinaryOperation* op) {
404 VisitInstruction(op);
405 if (op->IsUShr() || op->IsShr() || op->IsShl()) {
406 if (PrimitiveKind(op->InputAt(1)->GetType()) != Primitive::kPrimInt) {
Roland Levillain5c4405e2015-01-21 11:39:58 +0000407 AddError(StringPrintf(
408 "Shift operation %s %d has a non-int kind second input: "
409 "%s of type %s.",
410 op->DebugName(), op->GetId(),
411 op->InputAt(1)->DebugName(),
412 Primitive::PrettyDescriptor(op->InputAt(1)->GetType())));
Nicolas Geoffray31596742014-11-24 15:28:45 +0000413 }
414 } else {
415 if (PrimitiveKind(op->InputAt(1)->GetType()) != PrimitiveKind(op->InputAt(0)->GetType())) {
Roland Levillain5c4405e2015-01-21 11:39:58 +0000416 AddError(StringPrintf(
417 "Binary operation %s %d has inputs of different types: "
418 "%s, and %s.",
419 op->DebugName(), op->GetId(),
420 Primitive::PrettyDescriptor(op->InputAt(0)->GetType()),
421 Primitive::PrettyDescriptor(op->InputAt(1)->GetType())));
Nicolas Geoffray31596742014-11-24 15:28:45 +0000422 }
423 }
424
425 if (op->IsCompare()) {
426 if (op->GetType() != Primitive::kPrimInt) {
Roland Levillain5c4405e2015-01-21 11:39:58 +0000427 AddError(StringPrintf(
428 "Compare operation %d has a non-int result type: %s.",
429 op->GetId(),
430 Primitive::PrettyDescriptor(op->GetType())));
Nicolas Geoffray31596742014-11-24 15:28:45 +0000431 }
432 } else {
433 // Use the first input, so that we can also make this check for shift operations.
434 if (PrimitiveKind(op->GetType()) != PrimitiveKind(op->InputAt(0)->GetType())) {
Roland Levillain5c4405e2015-01-21 11:39:58 +0000435 AddError(StringPrintf(
436 "Binary operation %s %d has a result type different "
437 "from its input type: %s vs %s.",
438 op->DebugName(), op->GetId(),
439 Primitive::PrettyDescriptor(op->GetType()),
440 Primitive::PrettyDescriptor(op->InputAt(1)->GetType())));
Nicolas Geoffray31596742014-11-24 15:28:45 +0000441 }
442 }
443}
444
Roland Levillainccc07a92014-09-16 14:48:16 +0100445} // namespace art