Step 1 of 2: conditional passes.
Rationale:
The change adds a return value to Run() in preparation of
conditional pass execution. The value returned by Run() is
best effort, returning false means no optimizations were
applied or no useful information was obtained. I filled
in a few cases with more exact information, others
still just return true. In addition, it integrates inlining
as a regular pass, avoiding the ugly "break" into
optimizations1 and optimziations2.
Bug: b/78171933, b/74026074
Test: test-art-host,target
Change-Id: Ia39c5c83c01dcd79841e4b623917d61c754cf075
diff --git a/compiler/optimizing/gvn.cc b/compiler/optimizing/gvn.cc
index f05159b..4863718 100644
--- a/compiler/optimizing/gvn.cc
+++ b/compiler/optimizing/gvn.cc
@@ -352,7 +352,7 @@
visited_blocks_.ClearAllBits();
}
- void Run();
+ bool Run();
private:
// Per-block GVN. Will also update the ValueSet of the dominated and
@@ -397,7 +397,7 @@
DISALLOW_COPY_AND_ASSIGN(GlobalValueNumberer);
};
-void GlobalValueNumberer::Run() {
+bool GlobalValueNumberer::Run() {
DCHECK(side_effects_.HasRun());
sets_[graph_->GetEntryBlock()->GetBlockId()] = new (&allocator_) ValueSet(&allocator_);
@@ -406,6 +406,7 @@
for (HBasicBlock* block : graph_->GetReversePostOrder()) {
VisitBasicBlock(block);
}
+ return true;
}
void GlobalValueNumberer::VisitBasicBlock(HBasicBlock* block) {
@@ -557,9 +558,9 @@
return secondary_match;
}
-void GVNOptimization::Run() {
+bool GVNOptimization::Run() {
GlobalValueNumberer gvn(graph_, side_effects_);
- gvn.Run();
+ return gvn.Run();
}
} // namespace art