From 1d0a03c2eb0e26ded029b84e011458e8466f87de Mon Sep 17 00:00:00 2001 From: David Brazdil Date: Mon, 28 Sep 2015 14:11:09 +0100 Subject: ART: Fix DeadPhiHandling creating >2 equivalents Run test 531 failed a DCHECK because the DeadPhiHandling algorithm would generate three phis of the same type: (0) loop phi [#0, ref] with equivalents void & object (1) type object equivalent by its first input => int & int (2) request object equivalent by a user => int & int & object (3) type second => int & object & object (dead) (4) type first => object & object & object This patch fixes the issue by skipping (1) when the phi already has a type, thus not creating the third equivalent for the phi's user. Change-Id: I00c990a5982ddc1f7de013f72bbcfb1c649a6e5f --- compiler/optimizing/ssa_builder.cc | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'compiler/optimizing/ssa_builder.cc') diff --git a/compiler/optimizing/ssa_builder.cc b/compiler/optimizing/ssa_builder.cc index ad8c682b3a..fb11d76320 100644 --- a/compiler/optimizing/ssa_builder.cc +++ b/compiler/optimizing/ssa_builder.cc @@ -145,8 +145,14 @@ void DeadPhiHandling::VisitBasicBlock(HBasicBlock* block) { if (phi->IsDead() && phi->HasEnvironmentUses()) { phi->SetLive(); if (block->IsLoopHeader()) { - // Give a type to the loop phi, to guarantee convergence of the algorithm. - phi->SetType(phi->InputAt(0)->GetType()); + // Give a type to the loop phi to guarantee convergence of the algorithm. + // Note that the dead phi may already have a type if it is an equivalent + // generated for a typed LoadLocal. In that case we do not change the + // type because it could lead to an unsupported PrimNot/Float/Double -> + // PrimInt/Long transition and create same type equivalents. + if (phi->GetType() == Primitive::kPrimVoid) { + phi->SetType(phi->InputAt(0)->GetType()); + } AddToWorklist(phi); } else { // Because we are doing a reverse post order visit, all inputs of -- cgit v1.2.3-59-g8ed1b