From 21c7e6fbcabef2f22b467e1e89f4abe1aa43e459 Mon Sep 17 00:00:00 2001 From: Artem Serov Date: Thu, 27 Jul 2017 16:04:42 +0100 Subject: ART: Fix SimplifyInduction for an instruction with HEnvironment. After an instruction is removed during RemoveFromCycle its environment isn't properly cleaned: it still has input instructions present and registered (those instructions still hold records for that). Test: test-art-target, test-art-host. Change-Id: Iea315bdf735d75fe477f43671f05b40dfecc63a8 --- compiler/optimizing/loop_optimization.cc | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'compiler/optimizing/loop_optimization.cc') diff --git a/compiler/optimizing/loop_optimization.cc b/compiler/optimizing/loop_optimization.cc index 274f065084..0ef7dcdb59 100644 --- a/compiler/optimizing/loop_optimization.cc +++ b/compiler/optimizing/loop_optimization.cc @@ -40,6 +40,8 @@ static void RemoveFromCycle(HInstruction* instruction) { instruction->RemoveAsUserOfAllInputs(); instruction->RemoveEnvironmentUsers(); instruction->GetBlock()->RemoveInstructionOrPhi(instruction, /*ensure_safety=*/ false); + RemoveEnvironmentUses(instruction); + ResetEnvironmentInputRecords(instruction); } // Detect a goto block and sets succ to the single successor. @@ -267,6 +269,21 @@ static HInstruction* Insert(HBasicBlock* block, HInstruction* instruction) { return instruction; } +// Check that instructions from the induction sets are fully removed: have no uses +// and no other instructions use them. +static bool CheckInductionSetFullyRemoved(ArenaSet* iset) { + for (HInstruction* instr : *iset) { + if (instr->GetBlock() != nullptr || + !instr->GetUses().empty() || + !instr->GetEnvUses().empty() || + HasEnvironmentUsedByOthers(instr)) { + return false; + } + } + + return true; +} + // // Class methods. // @@ -448,6 +465,9 @@ void HLoopOptimization::SimplifyInduction(LoopNode* node) { for (HInstruction* i : *iset_) { RemoveFromCycle(i); } + + // Check that there are no records of the deleted instructions. + DCHECK(CheckInductionSetFullyRemoved(iset_)); simplified_ = true; } } -- cgit v1.2.3-59-g8ed1b