Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(707)

Unified Diff: runtime/vm/flow_graph_optimizer.cc

Issue 790143002: Fix dead phis elimination. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/compiler.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/flow_graph_optimizer.cc
===================================================================
--- runtime/vm/flow_graph_optimizer.cc (revision 42165)
+++ runtime/vm/flow_graph_optimizer.cc (working copy)
@@ -7303,6 +7303,19 @@
}
+// Returns true iff this definition is used in a non-phi instruction.
+static bool HasRealUse(Definition* def) {
+ // Environment uses are real (non-phi) uses.
+ if (def->env_use_list() != NULL) return true;
+ for (Value::Iterator it(def->input_use_list());
+ !it.Done();
+ it.Advance()) {
+ if (!it.Current()->instruction()->IsPhi()) return true;
+ }
+ return false;
+}
+
+
void DeadCodeElimination::EliminateDeadPhis(FlowGraph* flow_graph) {
GrowableArray<PhiInstr*> live_phis;
for (BlockIterator b = flow_graph->postorder_iterator();
@@ -7314,7 +7327,7 @@
PhiInstr* phi = it.Current();
// Phis that have uses and phis inside try blocks are
// marked as live.
- if (phi->HasUses() || join->InsideTryBlock()) {
+ if (HasRealUse(phi) || join->InsideTryBlock()) {
live_phis.Add(phi);
phi->mark_alive();
} else {
« no previous file with comments | « runtime/vm/compiler.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698