summaryrefslogtreecommitdiffstats
path: root/compiler
diff options
context:
space:
mode:
authorVladimir Marko <vmarko@google.com>2015-04-25 17:00:45 +0100
committerVladimir Marko <vmarko@google.com>2015-04-28 18:01:48 +0100
commitbe8f57d3a5ff121f1056791ed0910435c834b211 (patch)
tree2f3961518e95d2dfae188c04e34cde90cc5def79 /compiler
parent0dd76cd3f09f495a1b9a0e4f8712c09ff885c6fd (diff)
downloadart-be8f57d3a5ff121f1056791ed0910435c834b211.zip
art-be8f57d3a5ff121f1056791ed0910435c834b211.tar.gz
art-be8f57d3a5ff121f1056791ed0910435c834b211.tar.bz2
Quick: Avoid unnecessary GVN work in release builds.
In GVN's post-processing phase, compare LVNs only in debug builds as they should be equal anyway. Remove the Gate() from GVN cleanup pass and remove the DCHECK() from MIRGraph::GlobalValueNumberingCleanup() to make it a no-op if the GVN didn't run. Bug: 16398693 (cherry picked from commit f725550c8df90f8ec07395d9be5177a4be591c12) Change-Id: I518fba4a06c8d6d5ab16a6c122dc680b6d44814b
Diffstat (limited to 'compiler')
-rw-r--r--compiler/dex/bb_optimizations.cc11
-rw-r--r--compiler/dex/bb_optimizations.h3
-rw-r--r--compiler/dex/global_value_numbering.cc6
-rw-r--r--compiler/dex/mir_optimization.cc2
4 files changed, 6 insertions, 16 deletions
diff --git a/compiler/dex/bb_optimizations.cc b/compiler/dex/bb_optimizations.cc
index f351d99..11a7e44 100644
--- a/compiler/dex/bb_optimizations.cc
+++ b/compiler/dex/bb_optimizations.cc
@@ -17,7 +17,6 @@
#include "bb_optimizations.h"
#include "dataflow_iterator.h"
#include "dataflow_iterator-inl.h"
-#include "global_value_numbering.h"
namespace art {
@@ -80,14 +79,4 @@ bool MethodUseCount::Worker(PassDataHolder* data) const {
return false;
}
-bool GlobalValueNumberingCleanupPass::Gate(const PassDataHolder* data) const {
- DCHECK(data != nullptr);
- CompilationUnit* c_unit = down_cast<const PassMEDataHolder*>(data)->c_unit;
- DCHECK(c_unit != nullptr);
- // Do not do cleanup if GVN skipped this.
- // TODO: Proper dependencies between passes?
- return !GlobalValueNumbering::Skip(c_unit);
-}
-
-
} // namespace art
diff --git a/compiler/dex/bb_optimizations.h b/compiler/dex/bb_optimizations.h
index b948afd..eb87c29 100644
--- a/compiler/dex/bb_optimizations.h
+++ b/compiler/dex/bb_optimizations.h
@@ -284,9 +284,6 @@ class GlobalValueNumberingCleanupPass : public PassME {
: PassME("GVNCleanup", kNoNodes, "") {
}
- // Depends on GlobalValueNumbering, so implemented in cc file.
- bool Gate(const PassDataHolder* data) const OVERRIDE;
-
void Start(PassDataHolder* data) const OVERRIDE {
DCHECK(data != nullptr);
CompilationUnit* c_unit = down_cast<const PassMEDataHolder*>(data)->c_unit;
diff --git a/compiler/dex/global_value_numbering.cc b/compiler/dex/global_value_numbering.cc
index 30e3ce0..e2b9987 100644
--- a/compiler/dex/global_value_numbering.cc
+++ b/compiler/dex/global_value_numbering.cc
@@ -128,8 +128,9 @@ bool GlobalValueNumbering::FinishBasicBlock(BasicBlock* bb) {
++bbs_processed_;
merge_lvns_.clear();
- bool change = (lvns_[bb->id] == nullptr) || !lvns_[bb->id]->Equals(*work_lvn_);
+ bool change = false;
if (mode_ == kModeGvn) {
+ change = (lvns_[bb->id] == nullptr) || !lvns_[bb->id]->Equals(*work_lvn_);
// In GVN mode, keep the latest LVN even if Equals() indicates no change. This is
// to keep the correct values of fields that do not contribute to Equals() as long
// as they depend only on predecessor LVNs' fields that do contribute to Equals().
@@ -137,6 +138,9 @@ bool GlobalValueNumbering::FinishBasicBlock(BasicBlock* bb) {
std::unique_ptr<const LocalValueNumbering> old_lvn(lvns_[bb->id]);
lvns_[bb->id] = work_lvn_.release();
} else {
+ DCHECK_EQ(mode_, kModeGvnPostProcessing); // kModeLvn doesn't use FinishBasicBlock().
+ DCHECK(lvns_[bb->id] != nullptr);
+ DCHECK(lvns_[bb->id]->Equals(*work_lvn_));
work_lvn_.reset();
}
return change;
diff --git a/compiler/dex/mir_optimization.cc b/compiler/dex/mir_optimization.cc
index 3482602..f7107c1 100644
--- a/compiler/dex/mir_optimization.cc
+++ b/compiler/dex/mir_optimization.cc
@@ -1451,13 +1451,13 @@ void MIRGraph::EliminateDeadCodeEnd() {
}
void MIRGraph::GlobalValueNumberingCleanup() {
+ // If the GVN didn't run, these pointers should be null and everything is effectively no-op.
delete temp_.gvn.dce;
temp_.gvn.dce = nullptr;
delete temp_.gvn.gvn;
temp_.gvn.gvn = nullptr;
temp_.gvn.ifield_ids = nullptr;
temp_.gvn.sfield_ids = nullptr;
- DCHECK(temp_scoped_alloc_ != nullptr);
temp_scoped_alloc_.reset();
}