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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/vm/compiler.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/flow_graph_optimizer.h" 5 #include "vm/flow_graph_optimizer.h"
6 6
7 #include "vm/bit_vector.h" 7 #include "vm/bit_vector.h"
8 #include "vm/cha.h" 8 #include "vm/cha.h"
9 #include "vm/cpu.h" 9 #include "vm/cpu.h"
10 #include "vm/dart_entry.h" 10 #include "vm/dart_entry.h"
(...skipping 7285 matching lines...) Expand 10 before | Expand all | Expand 10 after
7296 }; 7296 };
7297 7297
7298 7298
7299 void DeadStoreElimination::Optimize(FlowGraph* graph) { 7299 void DeadStoreElimination::Optimize(FlowGraph* graph) {
7300 if (FLAG_dead_store_elimination) { 7300 if (FLAG_dead_store_elimination) {
7301 StoreOptimizer::OptimizeGraph(graph); 7301 StoreOptimizer::OptimizeGraph(graph);
7302 } 7302 }
7303 } 7303 }
7304 7304
7305 7305
7306 // Returns true iff this definition is used in a non-phi instruction.
7307 static bool HasRealUse(Definition* def) {
7308 // Environment uses are real (non-phi) uses.
7309 if (def->env_use_list() != NULL) return true;
7310 for (Value::Iterator it(def->input_use_list());
7311 !it.Done();
7312 it.Advance()) {
7313 if (!it.Current()->instruction()->IsPhi()) return true;
7314 }
7315 return false;
7316 }
7317
7318
7306 void DeadCodeElimination::EliminateDeadPhis(FlowGraph* flow_graph) { 7319 void DeadCodeElimination::EliminateDeadPhis(FlowGraph* flow_graph) {
7307 GrowableArray<PhiInstr*> live_phis; 7320 GrowableArray<PhiInstr*> live_phis;
7308 for (BlockIterator b = flow_graph->postorder_iterator(); 7321 for (BlockIterator b = flow_graph->postorder_iterator();
7309 !b.Done(); 7322 !b.Done();
7310 b.Advance()) { 7323 b.Advance()) {
7311 JoinEntryInstr* join = b.Current()->AsJoinEntry(); 7324 JoinEntryInstr* join = b.Current()->AsJoinEntry();
7312 if (join != NULL) { 7325 if (join != NULL) {
7313 for (PhiIterator it(join); !it.Done(); it.Advance()) { 7326 for (PhiIterator it(join); !it.Done(); it.Advance()) {
7314 PhiInstr* phi = it.Current(); 7327 PhiInstr* phi = it.Current();
7315 // Phis that have uses and phis inside try blocks are 7328 // Phis that have uses and phis inside try blocks are
7316 // marked as live. 7329 // marked as live.
7317 if (phi->HasUses() || join->InsideTryBlock()) { 7330 if (HasRealUse(phi) || join->InsideTryBlock()) {
7318 live_phis.Add(phi); 7331 live_phis.Add(phi);
7319 phi->mark_alive(); 7332 phi->mark_alive();
7320 } else { 7333 } else {
7321 phi->mark_dead(); 7334 phi->mark_dead();
7322 } 7335 }
7323 } 7336 }
7324 } 7337 }
7325 } 7338 }
7326 7339
7327 while (!live_phis.is_empty()) { 7340 while (!live_phis.is_empty()) {
(...skipping 2736 matching lines...) Expand 10 before | Expand all | Expand 10 after
10064 10077
10065 // Insert materializations at environment uses. 10078 // Insert materializations at environment uses.
10066 for (intptr_t i = 0; i < exits_collector_.exits().length(); i++) { 10079 for (intptr_t i = 0; i < exits_collector_.exits().length(); i++) {
10067 CreateMaterializationAt( 10080 CreateMaterializationAt(
10068 exits_collector_.exits()[i], alloc, *slots); 10081 exits_collector_.exits()[i], alloc, *slots);
10069 } 10082 }
10070 } 10083 }
10071 10084
10072 10085
10073 } // namespace dart 10086 } // namespace dart
OLDNEW
« 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