From 421e9f9088b51e9680a3dfcae6965fc1854d3ee4 Mon Sep 17 00:00:00 2001 From: Nicolas Geoffray Date: Tue, 11 Nov 2014 18:21:53 +0000 Subject: Remove HTemporary when building the SSA graph. - They are useless afterwards. If we keep them around, they can crash the dump of the graph, where they always assume a previous instruction. - In the call to HTemporary::GetType, check that the previous instruction exists. Change-Id: Ie7bf44d05cb61e3654a69725c1980925580dd3a6 --- compiler/optimizing/nodes.h | 6 +++++- compiler/optimizing/ssa_builder.cc | 5 +++++ compiler/optimizing/ssa_builder.h | 1 + 3 files changed, 11 insertions(+), 1 deletion(-) (limited to 'compiler/optimizing') diff --git a/compiler/optimizing/nodes.h b/compiler/optimizing/nodes.h index 2dab605465..36e286d578 100644 --- a/compiler/optimizing/nodes.h +++ b/compiler/optimizing/nodes.h @@ -2114,7 +2114,11 @@ class HTemporary : public HTemplateInstruction<0> { size_t GetIndex() const { return index_; } - Primitive::Type GetType() const OVERRIDE { return GetPrevious()->GetType(); } + Primitive::Type GetType() const OVERRIDE { + // The previous instruction is the one that will be stored in the temporary location. + DCHECK(GetPrevious() != nullptr); + return GetPrevious()->GetType(); + } DECLARE_INSTRUCTION(Temporary); diff --git a/compiler/optimizing/ssa_builder.cc b/compiler/optimizing/ssa_builder.cc index e83c528fab..fec40f93c7 100644 --- a/compiler/optimizing/ssa_builder.cc +++ b/compiler/optimizing/ssa_builder.cc @@ -253,4 +253,9 @@ void SsaBuilder::VisitInstruction(HInstruction* instruction) { instruction->SetEnvironment(environment); } +void SsaBuilder::VisitTemporary(HTemporary* temp) { + // Temporaries are only used by the baseline register allocator. + temp->GetBlock()->RemoveInstruction(temp); +} + } // namespace art diff --git a/compiler/optimizing/ssa_builder.h b/compiler/optimizing/ssa_builder.h index 24f5ac55f7..2207cd6bfa 100644 --- a/compiler/optimizing/ssa_builder.h +++ b/compiler/optimizing/ssa_builder.h @@ -51,6 +51,7 @@ class SsaBuilder : public HGraphVisitor { void VisitLoadLocal(HLoadLocal* load); void VisitStoreLocal(HStoreLocal* store); void VisitInstruction(HInstruction* instruction); + void VisitTemporary(HTemporary* instruction); static HInstruction* GetFloatOrDoubleEquivalent(HInstruction* user, HInstruction* instruction, -- cgit v1.2.3-59-g8ed1b