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.h | |
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.h')
-rw-r--r-- | compiler/optimizing/ssa_liveness_analysis.h | 55 |
1 files changed, 6 insertions, 49 deletions
diff --git a/compiler/optimizing/ssa_liveness_analysis.h b/compiler/optimizing/ssa_liveness_analysis.h index b6e4028c3f..2b51f949d8 100644 --- a/compiler/optimizing/ssa_liveness_analysis.h +++ b/compiler/optimizing/ssa_liveness_analysis.h @@ -893,15 +893,14 @@ class LiveInterval : public ArenaObject<kArenaAllocMisc> { */ class SsaLivenessAnalysis : public ValueObject { public: - SsaLivenessAnalysis(const HGraph& graph, CodeGenerator* codegen) + SsaLivenessAnalysis(HGraph* graph, CodeGenerator* codegen) : graph_(graph), codegen_(codegen), - linear_order_(graph.GetArena(), graph.GetBlocks().Size()), - block_infos_(graph.GetArena(), graph.GetBlocks().Size()), - instructions_from_ssa_index_(graph.GetArena(), 0), - instructions_from_lifetime_position_(graph.GetArena(), 0), + block_infos_(graph->GetArena(), graph->GetBlocks().Size()), + instructions_from_ssa_index_(graph->GetArena(), 0), + instructions_from_lifetime_position_(graph->GetArena(), 0), number_of_ssa_values_(0) { - block_infos_.SetSize(graph.GetBlocks().Size()); + block_infos_.SetSize(graph->GetBlocks().Size()); } void Analyze(); @@ -918,10 +917,6 @@ class SsaLivenessAnalysis : public ValueObject { return &block_infos_.Get(block.GetBlockId())->kill_; } - const GrowableArray<HBasicBlock*>& GetLinearOrder() const { - return linear_order_; - } - HInstruction* GetInstructionFromSsaIndex(size_t index) const { return instructions_from_ssa_index_.Get(index); } @@ -989,9 +984,8 @@ class SsaLivenessAnalysis : public ValueObject { return instruction->GetType() == Primitive::kPrimNot; } - const HGraph& graph_; + HGraph* const graph_; CodeGenerator* const codegen_; - GrowableArray<HBasicBlock*> linear_order_; GrowableArray<BlockInfo*> block_infos_; // Temporary array used when computing live_in, live_out, and kill sets. @@ -1004,43 +998,6 @@ class SsaLivenessAnalysis : public ValueObject { DISALLOW_COPY_AND_ASSIGN(SsaLivenessAnalysis); }; -class HLinearPostOrderIterator : public ValueObject { - public: - explicit HLinearPostOrderIterator(const SsaLivenessAnalysis& liveness) - : order_(liveness.GetLinearOrder()), index_(liveness.GetLinearOrder().Size()) {} - - bool Done() const { return index_ == 0; } - - HBasicBlock* Current() const { return order_.Get(index_ -1); } - - void Advance() { - --index_; - DCHECK_GE(index_, 0U); - } - - private: - const GrowableArray<HBasicBlock*>& order_; - size_t index_; - - DISALLOW_COPY_AND_ASSIGN(HLinearPostOrderIterator); -}; - -class HLinearOrderIterator : public ValueObject { - public: - explicit HLinearOrderIterator(const SsaLivenessAnalysis& liveness) - : order_(liveness.GetLinearOrder()), index_(0) {} - - bool Done() const { return index_ == order_.Size(); } - HBasicBlock* Current() const { return order_.Get(index_); } - void Advance() { ++index_; } - - private: - const GrowableArray<HBasicBlock*>& order_; - size_t index_; - - DISALLOW_COPY_AND_ASSIGN(HLinearOrderIterator); -}; - } // namespace art #endif // ART_COMPILER_OPTIMIZING_SSA_LIVENESS_ANALYSIS_H_ |