diff options
Diffstat (limited to 'compiler/optimizing')
-rw-r--r-- | compiler/optimizing/code_generator_arm.cc | 6 | ||||
-rw-r--r-- | compiler/optimizing/code_generator_arm.h | 2 | ||||
-rw-r--r-- | compiler/optimizing/code_generator_x86.cc | 6 | ||||
-rw-r--r-- | compiler/optimizing/code_generator_x86_64.cc | 6 | ||||
-rw-r--r-- | compiler/optimizing/graph_checker.cc | 32 | ||||
-rw-r--r-- | compiler/optimizing/locations.h | 2 | ||||
-rw-r--r-- | compiler/optimizing/nodes.cc | 9 | ||||
-rw-r--r-- | compiler/optimizing/nodes.h | 7 |
8 files changed, 57 insertions, 13 deletions
diff --git a/compiler/optimizing/code_generator_arm.cc b/compiler/optimizing/code_generator_arm.cc index dd60745a55..1876cb9ca4 100644 --- a/compiler/optimizing/code_generator_arm.cc +++ b/compiler/optimizing/code_generator_arm.cc @@ -129,9 +129,9 @@ class SuspendCheckSlowPathARM : public SlowPathCode { class BoundsCheckSlowPathARM : public SlowPathCode { public: - explicit BoundsCheckSlowPathARM(HBoundsCheck* instruction, - Location index_location, - Location length_location) + BoundsCheckSlowPathARM(HBoundsCheck* instruction, + Location index_location, + Location length_location) : instruction_(instruction), index_location_(index_location), length_location_(length_location) {} diff --git a/compiler/optimizing/code_generator_arm.h b/compiler/optimizing/code_generator_arm.h index 949d9aeeeb..8c86b7a237 100644 --- a/compiler/optimizing/code_generator_arm.h +++ b/compiler/optimizing/code_generator_arm.h @@ -83,7 +83,7 @@ class ParallelMoveResolverARM : public ParallelMoveResolver { class LocationsBuilderARM : public HGraphVisitor { public: - explicit LocationsBuilderARM(HGraph* graph, CodeGeneratorARM* codegen) + LocationsBuilderARM(HGraph* graph, CodeGeneratorARM* codegen) : HGraphVisitor(graph), codegen_(codegen) {} #define DECLARE_VISIT_INSTRUCTION(name) \ diff --git a/compiler/optimizing/code_generator_x86.cc b/compiler/optimizing/code_generator_x86.cc index f1716a32c6..ea67dfda32 100644 --- a/compiler/optimizing/code_generator_x86.cc +++ b/compiler/optimizing/code_generator_x86.cc @@ -92,9 +92,9 @@ class StackOverflowCheckSlowPathX86 : public SlowPathCode { class BoundsCheckSlowPathX86 : public SlowPathCode { public: - explicit BoundsCheckSlowPathX86(HBoundsCheck* instruction, - Location index_location, - Location length_location) + BoundsCheckSlowPathX86(HBoundsCheck* instruction, + Location index_location, + Location length_location) : instruction_(instruction), index_location_(index_location), length_location_(length_location) {} virtual void EmitNativeCode(CodeGenerator* codegen) OVERRIDE { diff --git a/compiler/optimizing/code_generator_x86_64.cc b/compiler/optimizing/code_generator_x86_64.cc index 5df8ed978d..78c7d9d81b 100644 --- a/compiler/optimizing/code_generator_x86_64.cc +++ b/compiler/optimizing/code_generator_x86_64.cc @@ -129,9 +129,9 @@ class SuspendCheckSlowPathX86_64 : public SlowPathCode { class BoundsCheckSlowPathX86_64 : public SlowPathCode { public: - explicit BoundsCheckSlowPathX86_64(HBoundsCheck* instruction, - Location index_location, - Location length_location) + BoundsCheckSlowPathX86_64(HBoundsCheck* instruction, + Location index_location, + Location length_location) : instruction_(instruction), index_location_(index_location), length_location_(length_location) {} diff --git a/compiler/optimizing/graph_checker.cc b/compiler/optimizing/graph_checker.cc index e36b1cdcfd..589b44a167 100644 --- a/compiler/optimizing/graph_checker.cc +++ b/compiler/optimizing/graph_checker.cc @@ -141,6 +141,38 @@ void GraphChecker::VisitInstruction(HInstruction* instruction) { } errors_.Insert(error.str()); } + + // Ensure the inputs of `instruction` are defined in a block of the graph. + for (HInputIterator input_it(instruction); !input_it.Done(); + input_it.Advance()) { + HInstruction* input = input_it.Current(); + const HInstructionList& list = input->IsPhi() + ? input->GetBlock()->GetPhis() + : input->GetBlock()->GetInstructions(); + if (!list.Contains(input)) { + std::stringstream error; + error << "Input " << input->GetId() + << " of instruction " << instruction->GetId() + << " is not defined in a basic block of the control-flow graph."; + errors_.Insert(error.str()); + } + } + + // Ensure the uses of `instruction` are defined in a block of the graph. + 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)) { + std::stringstream error; + error << "User " << use->GetId() + << " of instruction " << instruction->GetId() + << " is not defined in a basic block of the control-flow graph."; + errors_.Insert(error.str()); + } + } } void SSAChecker::VisitBasicBlock(HBasicBlock* block) { diff --git a/compiler/optimizing/locations.h b/compiler/optimizing/locations.h index 3a769dfd3c..a2f5bfaace 100644 --- a/compiler/optimizing/locations.h +++ b/compiler/optimizing/locations.h @@ -310,7 +310,7 @@ class LocationSummary : public ArenaObject { kCall }; - explicit LocationSummary(HInstruction* instruction, CallKind call_kind = kNoCall); + LocationSummary(HInstruction* instruction, CallKind call_kind = kNoCall); void SetInAt(uint32_t at, Location location) { inputs_.Put(at, location); diff --git a/compiler/optimizing/nodes.cc b/compiler/optimizing/nodes.cc index 9ed7ef7153..5c4ab8e4c0 100644 --- a/compiler/optimizing/nodes.cc +++ b/compiler/optimizing/nodes.cc @@ -441,6 +441,15 @@ void HInstructionList::RemoveInstruction(HInstruction* instruction) { } } +bool HInstructionList::Contains(HInstruction* instruction) const { + for (HInstructionIterator it(*this); !it.Done(); it.Advance()) { + if (it.Current() == instruction) { + return true; + } + } + return false; +} + bool HInstructionList::FoundBefore(const HInstruction* instruction1, const HInstruction* instruction2) const { DCHECK_EQ(instruction1->GetBlock(), instruction2->GetBlock()); diff --git a/compiler/optimizing/nodes.h b/compiler/optimizing/nodes.h index 7c8e7e2bdd..faed1ef992 100644 --- a/compiler/optimizing/nodes.h +++ b/compiler/optimizing/nodes.h @@ -58,6 +58,9 @@ class HInstructionList { void AddInstruction(HInstruction* instruction); void RemoveInstruction(HInstruction* instruction); + // Return true if this list contains `instruction`. + bool Contains(HInstruction* instruction) const; + // Return true if `instruction1` is found before `instruction2` in // this instruction list and false otherwise. Abort if none // of these instructions is found. @@ -1293,7 +1296,7 @@ class HLocal : public HTemplateInstruction<0> { // Load a given local. The local is an input of this instruction. class HLoadLocal : public HExpression<1> { public: - explicit HLoadLocal(HLocal* local, Primitive::Type type) + HLoadLocal(HLocal* local, Primitive::Type type) : HExpression(type, SideEffects::None()) { SetRawInputAt(0, local); } @@ -1611,7 +1614,7 @@ class HNullCheck : public HExpression<1> { class FieldInfo : public ValueObject { public: - explicit FieldInfo(MemberOffset field_offset, Primitive::Type field_type) + FieldInfo(MemberOffset field_offset, Primitive::Type field_type) : field_offset_(field_offset), field_type_(field_type) {} MemberOffset GetFieldOffset() const { return field_offset_; } |