diff options
author | 2015-01-26 12:54:33 +0000 | |
---|---|---|
committer | 2015-01-26 14:44:57 +0000 | |
commit | 86dde1658a1951c251dd5c6ff21ecc5c281879a6 (patch) | |
tree | ac28ec3a686fb4e9809123d8bfcdd0096b2426fb /compiler/optimizing/gvn.cc | |
parent | 2dadc9df0ffb822870a150f81257792b83241c77 (diff) |
Introduce a SideEffectsAnalysis class.
LICM also needs the side effects information of loops, so move
the GVN::ComputeSideEffects method into its own analysis class.
Change-Id: I810c8230a0eb6b9b536e8f808e17a3a4ad72f7db
Diffstat (limited to 'compiler/optimizing/gvn.cc')
-rw-r--r-- | compiler/optimizing/gvn.cc | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/compiler/optimizing/gvn.cc b/compiler/optimizing/gvn.cc index 6e5f1bd203..781aad5c72 100644 --- a/compiler/optimizing/gvn.cc +++ b/compiler/optimizing/gvn.cc @@ -18,24 +18,12 @@ namespace art { -void GlobalValueNumberer::Run() { - ComputeSideEffects(); - - sets_.Put(graph_->GetEntryBlock()->GetBlockId(), new (allocator_) ValueSet(allocator_)); - - // Do reverse post order to ensure the non back-edge predecessors of a block are - // visited before the block itself. - for (HReversePostOrderIterator it(*graph_); !it.Done(); it.Advance()) { - VisitBasicBlock(it.Current()); - } -} - -void GlobalValueNumberer::UpdateLoopEffects(HLoopInformation* info, SideEffects effects) { +void SideEffectsAnalysis::UpdateLoopEffects(HLoopInformation* info, SideEffects effects) { int id = info->GetHeader()->GetBlockId(); loop_effects_.Put(id, loop_effects_.Get(id).Union(effects)); } -void GlobalValueNumberer::ComputeSideEffects() { +void SideEffectsAnalysis::Run() { if (kIsDebugBuild) { for (HReversePostOrderIterator it(*graph_); !it.Done(); it.Advance()) { HBasicBlock* block = it.Current(); @@ -80,17 +68,29 @@ void GlobalValueNumberer::ComputeSideEffects() { UpdateLoopEffects(block->GetLoopInformation(), effects); } } + has_run_ = true; } -SideEffects GlobalValueNumberer::GetLoopEffects(HBasicBlock* block) const { +SideEffects SideEffectsAnalysis::GetLoopEffects(HBasicBlock* block) const { DCHECK(block->IsLoopHeader()); return loop_effects_.Get(block->GetBlockId()); } -SideEffects GlobalValueNumberer::GetBlockEffects(HBasicBlock* block) const { +SideEffects SideEffectsAnalysis::GetBlockEffects(HBasicBlock* block) const { return block_effects_.Get(block->GetBlockId()); } +void GlobalValueNumberer::Run() { + DCHECK(side_effects_.HasRun()); + sets_.Put(graph_->GetEntryBlock()->GetBlockId(), new (allocator_) ValueSet(allocator_)); + + // Use the reverse post order to ensure the non back-edge predecessors of a block are + // visited before the block itself. + for (HReversePostOrderIterator it(*graph_); !it.Done(); it.Advance()) { + VisitBasicBlock(it.Current()); + } +} + void GlobalValueNumberer::VisitBasicBlock(HBasicBlock* block) { ValueSet* set = nullptr; const GrowableArray<HBasicBlock*>& predecessors = block->GetPredecessors(); @@ -110,7 +110,7 @@ void GlobalValueNumberer::VisitBasicBlock(HBasicBlock* block) { if (!set->IsEmpty()) { if (block->IsLoopHeader()) { DCHECK_EQ(block->GetDominator(), block->GetLoopInformation()->GetPreHeader()); - set->Kill(GetLoopEffects(block)); + set->Kill(side_effects_.GetLoopEffects(block)); } else if (predecessors.Size() > 1) { for (size_t i = 0, e = predecessors.Size(); i < e; ++i) { set->IntersectionWith(sets_.Get(predecessors.Get(i)->GetBlockId())); |