summaryrefslogtreecommitdiff
path: root/compiler/optimizing/graph_checker.cc
diff options
context:
space:
mode:
author Calin Juravle <calin@google.com> 2015-05-11 18:25:51 +0100
committer Calin Juravle <calin@google.com> 2015-05-11 18:25:56 +0100
commit9d50775046a51941f86cced03593c61c89ae615e (patch)
tree0ba58dfe1fec1d49f89797579228ad584759f0f4 /compiler/optimizing/graph_checker.cc
parent6108ed86bb2663e73262e290463f014e2698abc1 (diff)
Add new rule to the graph checker.
Phis typed as `reference` should not have equivalents after building the SSA. Change-Id: I9cac189362583ef7c9c7defd3da7338f419f2f94
Diffstat (limited to 'compiler/optimizing/graph_checker.cc')
-rw-r--r--compiler/optimizing/graph_checker.cc19
1 files changed, 18 insertions, 1 deletions
diff --git a/compiler/optimizing/graph_checker.cc b/compiler/optimizing/graph_checker.cc
index fd28f0b83f..c660423eff 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()) {