diff options
author | 2015-04-15 14:17:44 +0100 | |
---|---|---|
committer | 2015-04-15 14:17:44 +0100 | |
commit | 0d9f17de8f21a10702de1510b73e89d07b3b9bbf (patch) | |
tree | 3d58a2a165ee2bc5af0e813b1ffa893fba72ed6d /compiler/optimizing/ssa_liveness_analysis.cc | |
parent | 9bb3e8e10d7d9230a323511094a9e260062a1473 (diff) |
Move the linear order to the HGraph.
Bug found by Zheng Xu: SsaLivenessAnalysis being a stack allocated
object, we should not refer to it in later phases of the compiler.
Specifically, the code generator was using the linear order, which
was stored in the liveness analysis object.
Change-Id: I574641f522b7b86fc43f3914166108efc72edb3b
Diffstat (limited to 'compiler/optimizing/ssa_liveness_analysis.cc')
-rw-r--r-- | compiler/optimizing/ssa_liveness_analysis.cc | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/compiler/optimizing/ssa_liveness_analysis.cc b/compiler/optimizing/ssa_liveness_analysis.cc index 95da6ef551..302df2a1d2 100644 --- a/compiler/optimizing/ssa_liveness_analysis.cc +++ b/compiler/optimizing/ssa_liveness_analysis.cc @@ -69,9 +69,9 @@ void SsaLivenessAnalysis::LinearizeGraph() { // current reverse post order in the graph, but it would require making // order queries to a GrowableArray, which is not the best data structure // for it. - GrowableArray<uint32_t> forward_predecessors(graph_.GetArena(), graph_.GetBlocks().Size()); - forward_predecessors.SetSize(graph_.GetBlocks().Size()); - for (HReversePostOrderIterator it(graph_); !it.Done(); it.Advance()) { + GrowableArray<uint32_t> forward_predecessors(graph_->GetArena(), graph_->GetBlocks().Size()); + 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(); if (block->IsLoopHeader()) { @@ -86,11 +86,11 @@ void SsaLivenessAnalysis::LinearizeGraph() { // iterate over the successors. When all non-back edge predecessors of a // successor block are visited, the successor block is added in the worklist // following an order that satisfies the requirements to build our linear graph. - GrowableArray<HBasicBlock*> worklist(graph_.GetArena(), 1); - worklist.Add(graph_.GetEntryBlock()); + GrowableArray<HBasicBlock*> worklist(graph_->GetArena(), 1); + worklist.Add(graph_->GetEntryBlock()); do { HBasicBlock* current = worklist.Pop(); - linear_order_.Add(current); + graph_->linear_order_.Add(current); for (size_t i = 0, e = current->GetSuccessors().Size(); i < e; ++i) { HBasicBlock* successor = current->GetSuccessors().Get(i); int block_id = successor->GetBlockId(); @@ -115,7 +115,7 @@ void SsaLivenessAnalysis::NumberInstructions() { // to differentiate between the start and end of an instruction. Adding 2 to // the lifetime position for each instruction ensures the start of an // instruction is different than the end of the previous instruction. - for (HLinearOrderIterator it(*this); !it.Done(); it.Advance()) { + for (HLinearOrderIterator it(*graph_); !it.Done(); it.Advance()) { HBasicBlock* block = it.Current(); block->SetLifetimeStart(lifetime_position); @@ -127,7 +127,7 @@ void SsaLivenessAnalysis::NumberInstructions() { instructions_from_ssa_index_.Add(current); current->SetSsaIndex(ssa_index++); current->SetLiveInterval( - LiveInterval::MakeInterval(graph_.GetArena(), current->GetType(), current)); + LiveInterval::MakeInterval(graph_->GetArena(), current->GetType(), current)); } current->SetLifetimePosition(lifetime_position); } @@ -145,7 +145,7 @@ void SsaLivenessAnalysis::NumberInstructions() { instructions_from_ssa_index_.Add(current); current->SetSsaIndex(ssa_index++); current->SetLiveInterval( - LiveInterval::MakeInterval(graph_.GetArena(), current->GetType(), current)); + LiveInterval::MakeInterval(graph_->GetArena(), current->GetType(), current)); } instructions_from_lifetime_position_.Add(current); current->SetLifetimePosition(lifetime_position); @@ -158,11 +158,11 @@ void SsaLivenessAnalysis::NumberInstructions() { } void SsaLivenessAnalysis::ComputeLiveness() { - for (HLinearOrderIterator it(*this); !it.Done(); it.Advance()) { + for (HLinearOrderIterator it(*graph_); !it.Done(); it.Advance()) { HBasicBlock* block = it.Current(); block_infos_.Put( block->GetBlockId(), - new (graph_.GetArena()) BlockInfo(graph_.GetArena(), *block, number_of_ssa_values_)); + new (graph_->GetArena()) BlockInfo(graph_->GetArena(), *block, number_of_ssa_values_)); } // Compute the live ranges, as well as the initial live_in, live_out, and kill sets. @@ -179,7 +179,7 @@ void SsaLivenessAnalysis::ComputeLiveness() { void SsaLivenessAnalysis::ComputeLiveRanges() { // Do a post order visit, adding inputs of instructions live in the block where // that instruction is defined, and killing instructions that are being visited. - for (HLinearPostOrderIterator it(*this); !it.Done(); it.Advance()) { + for (HLinearPostOrderIterator it(*graph_); !it.Done(); it.Advance()) { HBasicBlock* block = it.Current(); BitVector* kill = GetKillSet(*block); @@ -281,7 +281,7 @@ void SsaLivenessAnalysis::ComputeLiveInAndLiveOutSets() { do { changed = false; - for (HPostOrderIterator it(graph_); !it.Done(); it.Advance()) { + for (HPostOrderIterator it(*graph_); !it.Done(); it.Advance()) { const HBasicBlock& block = *it.Current(); // The live_in set depends on the kill set (which does not |