From 9d50775046a51941f86cced03593c61c89ae615e Mon Sep 17 00:00:00 2001 From: Calin Juravle Date: Mon, 11 May 2015 18:25:51 +0100 Subject: [PATCH] Add new rule to the graph checker. Phis typed as `reference` should not have equivalents after building the SSA. Change-Id: I9cac189362583ef7c9c7defd3da7338f419f2f94 --- compiler/optimizing/graph_checker.cc | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/compiler/optimizing/graph_checker.cc b/compiler/optimizing/graph_checker.cc index fd28f0b83..c660423ef 100644 --- a/compiler/optimizing/graph_checker.cc +++ b/compiler/optimizing/graph_checker.cc @@ -270,15 +270,32 @@ void SSAChecker::VisitBasicBlock(HBasicBlock* block) { } } - // Check Phi uniqueness (no two Phis with the same type refer to the same register). for (HInstructionIterator it(block->GetPhis()); !it.Done(); it.Advance()) { HPhi* phi = it.Current()->AsPhi(); + // Check Phi uniqueness (no two Phis with the same type refer to the same register). if (phi->GetNextEquivalentPhiWithSameType() != nullptr) { std::stringstream type_str; type_str << phi->GetType(); AddError(StringPrintf("Equivalent phi (%d) found for VReg %d with type: %s", phi->GetId(), phi->GetRegNumber(), type_str.str().c_str())); } + // Phis typed as `reference` should not have any equivalents. + if (phi->GetNext() != nullptr) { + HPhi* next = phi->GetNext()->AsPhi(); + if (phi->GetRegNumber() == next->GetRegNumber()) { + if ((phi->GetType() == Primitive::kPrimNot) || (next->GetType() == Primitive::kPrimNot)) { + std::stringstream phi_type_str; + std::stringstream next_type_str; + phi_type_str << phi->GetType(); + next_type_str << next->GetType(); + AddError(StringPrintf( + "Found equivalent for a Phi typed as reference. vReg=%d, phi1=%d, phi1_type=%s, " + "phi2=%d, phi2_type=%s", + phi->GetRegNumber(), phi->GetId(), phi_type_str.str().c_str(), + next->GetId(), next_type_str.str().c_str())); + } + } + } } if (block->IsLoopHeader()) { -- 2.11.0