diff options
author | 2016-10-05 09:55:42 +0100 | |
---|---|---|
committer | 2016-10-05 09:55:42 +0100 | |
commit | ebe167422f6197b9df0698bbeb944a0e4eea5f2d (patch) | |
tree | 60bb0084030cadfed694261c36c5722f4f945869 /compiler/optimizing/loop_optimization.cc | |
parent | 2a5c5160771ad528bc9b3ac36ac5785a184c956d (diff) |
Properly scope HLoopOptimization's allocator.
HOptimization classes do not get their destructor called,
as they are arena objects. So the scope for the optimization
allocator needs to be the Run method.
Also anticipate bisection search breakage by adding
HLoopOptimization to the list of recognized optimizations.
Change-Id: I7770989c39d5700a3b6b0a20af5d4b874dfde111
Diffstat (limited to 'compiler/optimizing/loop_optimization.cc')
-rw-r--r-- | compiler/optimizing/loop_optimization.cc | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/compiler/optimizing/loop_optimization.cc b/compiler/optimizing/loop_optimization.cc index 7dfa4f160b..383a0278c6 100644 --- a/compiler/optimizing/loop_optimization.cc +++ b/compiler/optimizing/loop_optimization.cc @@ -128,7 +128,7 @@ HLoopOptimization::HLoopOptimization(HGraph* graph, HInductionVarAnalysis* induction_analysis) : HOptimization(graph, kLoopOptimizationPassName), induction_range_(induction_analysis), - loop_allocator_(graph_->GetArena()->GetArenaPool()), // phase-local allocator on global pool + loop_allocator_(nullptr), top_loop_(nullptr), last_loop_(nullptr) { } @@ -140,6 +140,9 @@ void HLoopOptimization::Run() { return; } + ArenaAllocator allocator(graph_->GetArena()->GetArenaPool()); + loop_allocator_ = &allocator; + // Build the linear order. This step enables building a loop hierarchy that // properly reflects the outer-inner and previous-next relation. graph_->Linearize(); @@ -150,16 +153,16 @@ void HLoopOptimization::Run() { AddLoop(block->GetLoopInformation()); } } - if (top_loop_ == nullptr) { - return; // no loops + if (top_loop_ != nullptr) { + // Traverse the loop hierarchy inner-to-outer and optimize. + TraverseLoopsInnerToOuter(top_loop_); } - // Traverse the loop hierarchy inner-to-outer and optimize. - TraverseLoopsInnerToOuter(top_loop_); + loop_allocator_ = nullptr; } void HLoopOptimization::AddLoop(HLoopInformation* loop_info) { DCHECK(loop_info != nullptr); - LoopNode* node = new (&loop_allocator_) LoopNode(loop_info); // phase-local allocator + LoopNode* node = new (loop_allocator_) LoopNode(loop_info); // phase-local allocator if (last_loop_ == nullptr) { // First loop. DCHECK(top_loop_ == nullptr); |