diff options
Diffstat (limited to 'compiler/optimizing/ssa_liveness_analysis.cc')
-rw-r--r-- | compiler/optimizing/ssa_liveness_analysis.cc | 25 |
1 files changed, 11 insertions, 14 deletions
diff --git a/compiler/optimizing/ssa_liveness_analysis.cc b/compiler/optimizing/ssa_liveness_analysis.cc index 40502c173b..0c1831b45f 100644 --- a/compiler/optimizing/ssa_liveness_analysis.cc +++ b/compiler/optimizing/ssa_liveness_analysis.cc @@ -73,7 +73,7 @@ void SsaLivenessAnalysis::LinearizeGraph() { forward_predecessors.SetSize(graph_->GetBlocks().Size()); for (HReversePostOrderIterator it(*graph_); !it.Done(); it.Advance()) { HBasicBlock* block = it.Current(); - size_t number_of_forward_predecessors = block->GetPredecessors().Size(); + size_t number_of_forward_predecessors = block->GetPredecessors().size(); if (block->IsLoopHeader()) { number_of_forward_predecessors -= block->GetLoopInformation()->NumberOfBackEdges(); } @@ -89,8 +89,7 @@ void SsaLivenessAnalysis::LinearizeGraph() { do { HBasicBlock* current = worklist.Pop(); graph_->linear_order_.Add(current); - for (size_t i = 0, e = current->GetSuccessors().Size(); i < e; ++i) { - HBasicBlock* successor = current->GetSuccessors().Get(i); + for (HBasicBlock* successor : current->GetSuccessors()) { int block_id = successor->GetBlockId(); size_t number_of_remaining_predecessors = forward_predecessors.Get(block_id); if (number_of_remaining_predecessors == 1) { @@ -185,8 +184,7 @@ void SsaLivenessAnalysis::ComputeLiveRanges() { // Set phi inputs of successors of this block corresponding to this block // as live_in. - for (size_t i = 0, e = block->GetSuccessors().Size(); i < e; ++i) { - HBasicBlock* successor = block->GetSuccessors().Get(i); + for (HBasicBlock* successor : block->GetSuccessors()) { live_in->Union(GetLiveInSet(*successor)); size_t phi_input_index = successor->GetPredecessorIndexOf(block); for (HInstructionIterator inst_it(successor->GetPhis()); !inst_it.Done(); inst_it.Advance()) { @@ -296,8 +294,7 @@ bool SsaLivenessAnalysis::UpdateLiveOut(const HBasicBlock& block) { BitVector* live_out = GetLiveOutSet(block); bool changed = false; // The live_out set of a block is the union of live_in sets of its successors. - for (size_t i = 0, e = block.GetSuccessors().Size(); i < e; ++i) { - HBasicBlock* successor = block.GetSuccessors().Get(i); + for (HBasicBlock* successor : block.GetSuccessors()) { if (live_out->Union(GetLiveInSet(*successor))) { changed = true; } @@ -342,8 +339,8 @@ int LiveInterval::FindFirstRegisterHint(size_t* free_until, // will avoid a move between the two blocks. HBasicBlock* block = liveness.GetBlockFromPosition(GetStart() / 2); size_t next_register_use = FirstRegisterUse(); - for (size_t i = 0; i < block->GetPredecessors().Size(); ++i) { - size_t position = block->GetPredecessors().Get(i)->GetLifetimeEnd() - 1; + for (HBasicBlock* predecessor : block->GetPredecessors()) { + size_t position = predecessor->GetLifetimeEnd() - 1; // We know positions above GetStart() do not have a location yet. if (position < GetStart()) { LiveInterval* existing = GetParent()->GetSiblingAt(position); @@ -376,17 +373,16 @@ int LiveInterval::FindFirstRegisterHint(size_t* free_until, return reg; } } - const GrowableArray<HBasicBlock*>& predecessors = user->GetBlock()->GetPredecessors(); // If the instruction dies at the phi assignment, we can try having the // same register. - if (end == predecessors.Get(input_index)->GetLifetimeEnd()) { + if (end == user->GetBlock()->GetPredecessor(input_index)->GetLifetimeEnd()) { for (size_t i = 0, e = user->InputCount(); i < e; ++i) { if (i == input_index) { continue; } HInstruction* input = user->InputAt(i); Location location = input->GetLiveInterval()->GetLocationAt( - predecessors.Get(i)->GetLifetimeEnd() - 1); + user->GetBlock()->GetPredecessor(i)->GetLifetimeEnd() - 1); if (location.IsRegisterKind()) { int reg = RegisterOrLowRegister(location); if (free_until[reg] >= use_position) { @@ -420,10 +416,11 @@ int LiveInterval::FindFirstRegisterHint(size_t* free_until, int LiveInterval::FindHintAtDefinition() const { if (defined_by_->IsPhi()) { // Try to use the same register as one of the inputs. - const GrowableArray<HBasicBlock*>& predecessors = defined_by_->GetBlock()->GetPredecessors(); + const ArenaVector<HBasicBlock*>& predecessors = defined_by_->GetBlock()->GetPredecessors(); for (size_t i = 0, e = defined_by_->InputCount(); i < e; ++i) { HInstruction* input = defined_by_->InputAt(i); - size_t end = predecessors.Get(i)->GetLifetimeEnd(); + DCHECK_LT(i, predecessors.size()); + size_t end = predecessors[i]->GetLifetimeEnd(); LiveInterval* input_interval = input->GetLiveInterval()->GetSiblingAt(end - 1); if (input_interval->GetEnd() == end) { // If the input dies at the end of the predecessor, we know its register can |