From fecc4659d0a4ac1e0e16e82b47e5592fff1d827f Mon Sep 17 00:00:00 2001 From: Nicolas Geoffray Date: Mon, 29 Jun 2015 14:34:46 +0100 Subject: Do not replace a live phi with a dead phi. A dead phi is not properly typed. Therefore, always use the live phi equivalent instead. bug:21865466 (cherry picked from commit 4230e1895b915a22363452823b0e51eabe92cb60) Change-Id: If9a3313fc953c2eb4be85b625676e48112fcb1f6 --- compiler/optimizing/ssa_builder.cc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'compiler') diff --git a/compiler/optimizing/ssa_builder.cc b/compiler/optimizing/ssa_builder.cc index 9236f7c..3814e8f 100644 --- a/compiler/optimizing/ssa_builder.cc +++ b/compiler/optimizing/ssa_builder.cc @@ -213,7 +213,13 @@ void SsaBuilder::EquivalentPhisCleanup() { HPhi* phi = it.Current()->AsPhi(); HPhi* next = phi->GetNextEquivalentPhiWithSameType(); if (next != nullptr) { - phi->ReplaceWith(next); + // Make sure we do not replace a live phi with a dead phi. A live phi has been + // handled by the type propagation phase, unlike a dead phi. + if (next->IsLive()) { + phi->ReplaceWith(next); + } else { + next->ReplaceWith(phi); + } DCHECK(next->GetNextEquivalentPhiWithSameType() == nullptr) << "More then one phi equivalent with type " << phi->GetType() << " found for phi" << phi->GetId(); -- cgit v1.1