diff options
Diffstat (limited to 'compiler/optimizing')
| -rw-r--r-- | compiler/optimizing/dead_code_elimination.cc | 12 | ||||
| -rw-r--r-- | compiler/optimizing/nodes.cc | 39 |
2 files changed, 15 insertions, 36 deletions
diff --git a/compiler/optimizing/dead_code_elimination.cc b/compiler/optimizing/dead_code_elimination.cc index 02e5dab3d4..9754043f32 100644 --- a/compiler/optimizing/dead_code_elimination.cc +++ b/compiler/optimizing/dead_code_elimination.cc @@ -123,21 +123,20 @@ void HDeadCodeElimination::RemoveDeadBlocks() { } // If we removed at least one block, we need to recompute the full - // dominator tree and try block membership. + // dominator tree. if (removed_one_or_more_blocks) { graph_->ClearDominanceInformation(); graph_->ComputeDominanceInformation(); - graph_->ComputeTryBlockInformation(); } // Connect successive blocks created by dead branches. Order does not matter. for (HReversePostOrderIterator it(*graph_); !it.Done();) { HBasicBlock* block = it.Current(); - if (block->IsEntryBlock() || !block->GetLastInstruction()->IsGoto()) { + if (block->IsEntryBlock() || block->GetSuccessors().size() != 1u) { it.Advance(); continue; } - HBasicBlock* successor = block->GetSingleSuccessor(); + HBasicBlock* successor = block->GetSuccessors()[0]; if (successor->IsExitBlock() || successor->GetPredecessors().size() != 1u) { it.Advance(); continue; @@ -177,7 +176,10 @@ void HDeadCodeElimination::RemoveDeadInstructions() { } void HDeadCodeElimination::Run() { - RemoveDeadBlocks(); + if (!graph_->HasTryCatch()) { + // TODO: Update dead block elimination and enable for try/catch. + RemoveDeadBlocks(); + } SsaRedundantPhiElimination(graph_).Run(); RemoveDeadInstructions(); } diff --git a/compiler/optimizing/nodes.cc b/compiler/optimizing/nodes.cc index 4d79b55771..68fb0acf7f 100644 --- a/compiler/optimizing/nodes.cc +++ b/compiler/optimizing/nodes.cc @@ -366,11 +366,7 @@ void HGraph::ComputeTryBlockInformation() { HBasicBlock* first_predecessor = block->GetPredecessors()[0]; DCHECK(!block->IsLoopHeader() || !block->GetLoopInformation()->IsBackEdge(*first_predecessor)); const HTryBoundary* try_entry = first_predecessor->ComputeTryEntryOfSuccessors(); - if (try_entry != nullptr && - (block->GetTryCatchInformation() == nullptr || - try_entry != &block->GetTryCatchInformation()->GetTryEntry())) { - // We are either setting try block membership for the first time or it - // has changed. + if (try_entry != nullptr) { block->SetTryCatchInformation(new (arena_) TryCatchInformation(*try_entry)); } } @@ -1376,30 +1372,13 @@ void HBasicBlock::DisconnectAndDelete() { // instructions. for (HBasicBlock* predecessor : predecessors_) { HInstruction* last_instruction = predecessor->GetLastInstruction(); - if (last_instruction->IsTryBoundary() && !IsCatchBlock()) { - // This block is the only normal-flow successor of the TryBoundary which - // makes `predecessor` dead. Since DCE removes blocks in post order, - // exception handlers of this TryBoundary were already visited and any - // remaining handlers therefore must be live. We remove `predecessor` from - // their list of predecessors. - DCHECK_EQ(last_instruction->AsTryBoundary()->GetNormalFlowSuccessor(), this); - while (predecessor->GetSuccessors().size() > 1) { - HBasicBlock* handler = predecessor->GetSuccessors()[1]; - DCHECK(handler->IsCatchBlock()); - predecessor->RemoveSuccessor(handler); - handler->RemovePredecessor(predecessor); - } - } - predecessor->RemoveSuccessor(this); uint32_t num_pred_successors = predecessor->GetSuccessors().size(); if (num_pred_successors == 1u) { // If we have one successor after removing one, then we must have - // had an HIf, HPackedSwitch or HTryBoundary, as they have more than one - // successor. Replace those with a HGoto. - DCHECK(last_instruction->IsIf() || - last_instruction->IsPackedSwitch() || - (last_instruction->IsTryBoundary() && IsCatchBlock())); + // had an HIf or HPackedSwitch, as they have more than one successor. + // Replace those with a HGoto. + DCHECK(last_instruction->IsIf() || last_instruction->IsPackedSwitch()); predecessor->RemoveInstruction(last_instruction); predecessor->AddInstruction(new (graph_->GetArena()) HGoto(last_instruction->GetDexPc())); } else if (num_pred_successors == 0u) { @@ -1408,12 +1387,10 @@ void HBasicBlock::DisconnectAndDelete() { // SSAChecker fails unless it is not removed during the pass too. predecessor->RemoveInstruction(last_instruction); } else { - // There are multiple successors left. The removed block might be a successor - // of a PackedSwitch which will be completely removed (perhaps replaced with - // a Goto), or we are deleting a catch block from a TryBoundary. In either - // case, leave `last_instruction` as is for now. - DCHECK(last_instruction->IsPackedSwitch() || - (last_instruction->IsTryBoundary() && IsCatchBlock())); + // There are multiple successors left. This must come from a HPackedSwitch + // and we are in the middle of removing the HPackedSwitch. Like above, leave + // this alone, and the SSAChecker will fail if it is not removed as well. + DCHECK(last_instruction->IsPackedSwitch()); } } predecessors_.clear(); |