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

Side by Side Diff: runtime/vm/flow_graph_optimizer.cc

Issue 12316065: Set instruction/use_index when adding an input to an IL instruction. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Incorporated review comments. Created 7 years, 9 months 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/flow_graph_builder.cc ('k') | runtime/vm/flow_graph_type_propagator.cc » ('j') | 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/flow_graph_builder.h" 9 #include "vm/flow_graph_builder.h"
10 #include "vm/flow_graph_compiler.h" 10 #include "vm/flow_graph_compiler.h"
(...skipping 3271 matching lines...) Expand 10 before | Expand all | Expand 10 after
3282 ASSERT((*pred_out_values)[expr_id] != NULL); 3282 ASSERT((*pred_out_values)[expr_id] != NULL);
3283 3283
3284 // Sets of outgoing values are not linked into use lists so 3284 // Sets of outgoing values are not linked into use lists so
3285 // they might contain values that were replaced and removed 3285 // they might contain values that were replaced and removed
3286 // from the graph by this iteration. 3286 // from the graph by this iteration.
3287 // To prevent using them we additionally mark definitions themselves 3287 // To prevent using them we additionally mark definitions themselves
3288 // as replaced and store a pointer to the replacement. 3288 // as replaced and store a pointer to the replacement.
3289 Definition* replacement = (*pred_out_values)[expr_id]->Replacement(); 3289 Definition* replacement = (*pred_out_values)[expr_id]->Replacement();
3290 Value* input = new Value(replacement); 3290 Value* input = new Value(replacement);
3291 phi->SetInputAt(i, input); 3291 phi->SetInputAt(i, input);
3292
3293 // TODO(vegorov): add a helper function to handle input insertion.
3294 input->set_instruction(phi);
3295 input->set_use_index(i);
3296 replacement->AddInputUse(input); 3292 replacement->AddInputUse(input);
3297 } 3293 }
3298 3294
3299 phi->set_ssa_temp_index(graph_->alloc_ssa_temp_index()); 3295 phi->set_ssa_temp_index(graph_->alloc_ssa_temp_index());
3300 phis_.Add(phi); // Postpone phi insertion until after load forwarding. 3296 phis_.Add(phi); // Postpone phi insertion until after load forwarding.
3301 3297
3302 return phi; 3298 return phi;
3303 } 3299 }
3304 3300
3305 // Iterate over basic blocks and replace exposed loads with incoming 3301 // Iterate over basic blocks and replace exposed loads with incoming
(...skipping 972 matching lines...) Expand 10 before | Expand all | Expand 10 after
4278 if (phis != NULL) { 4274 if (phis != NULL) {
4279 intptr_t pred_count = join->PredecessorCount(); 4275 intptr_t pred_count = join->PredecessorCount();
4280 intptr_t live_count = 0; 4276 intptr_t live_count = 0;
4281 for (intptr_t pred_idx = 0; pred_idx < pred_count; ++pred_idx) { 4277 for (intptr_t pred_idx = 0; pred_idx < pred_count; ++pred_idx) {
4282 if (reachable_->Contains( 4278 if (reachable_->Contains(
4283 join->PredecessorAt(pred_idx)->preorder_number())) { 4279 join->PredecessorAt(pred_idx)->preorder_number())) {
4284 if (live_count < pred_idx) { 4280 if (live_count < pred_idx) {
4285 for (intptr_t phi_idx = 0; phi_idx < phis->length(); ++phi_idx) { 4281 for (intptr_t phi_idx = 0; phi_idx < phis->length(); ++phi_idx) {
4286 PhiInstr* phi = (*phis)[phi_idx]; 4282 PhiInstr* phi = (*phis)[phi_idx];
4287 if (phi == NULL) continue; 4283 if (phi == NULL) continue;
4288 Value* input = phi->inputs_[pred_idx]; 4284 phi->SetInputAt(live_count, phi->InputAt(pred_idx));
4289 input->set_use_index(live_count);
4290 phi->inputs_[live_count] = input;
4291 } 4285 }
4292 } 4286 }
4293 ++live_count; 4287 ++live_count;
4294 } else { 4288 } else {
4295 for (intptr_t phi_idx = 0; phi_idx < phis->length(); ++phi_idx) { 4289 for (intptr_t phi_idx = 0; phi_idx < phis->length(); ++phi_idx) {
4296 PhiInstr* phi = (*phis)[phi_idx]; 4290 PhiInstr* phi = (*phis)[phi_idx];
4297 if (phi == NULL) continue; 4291 if (phi == NULL) continue;
4298 phi->inputs_[pred_idx]->RemoveFromUseList(); 4292 phi->InputAt(pred_idx)->RemoveFromUseList();
4299 } 4293 }
4300 } 4294 }
4301 } 4295 }
4302 if (live_count < pred_count) { 4296 if (live_count < pred_count) {
4303 for (intptr_t phi_idx = 0; phi_idx < phis->length(); ++phi_idx) { 4297 for (intptr_t phi_idx = 0; phi_idx < phis->length(); ++phi_idx) {
4304 PhiInstr* phi = (*phis)[phi_idx]; 4298 PhiInstr* phi = (*phis)[phi_idx];
4305 if (phi == NULL) continue; 4299 if (phi == NULL) continue;
4306 if (FLAG_remove_redundant_phis && (live_count == 1)) { 4300 if (FLAG_remove_redundant_phis && (live_count == 1)) {
4307 Value* input = phi->InputAt(0); 4301 Value* input = phi->InputAt(0);
4308 phi->ReplaceUsesWith(input->definition()); 4302 phi->ReplaceUsesWith(input->definition());
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
4383 4377
4384 if (FLAG_trace_constant_propagation) { 4378 if (FLAG_trace_constant_propagation) {
4385 OS::Print("\n==== After constant propagation ====\n"); 4379 OS::Print("\n==== After constant propagation ====\n");
4386 FlowGraphPrinter printer(*graph_); 4380 FlowGraphPrinter printer(*graph_);
4387 printer.PrintBlocks(); 4381 printer.PrintBlocks();
4388 } 4382 }
4389 } 4383 }
4390 4384
4391 4385
4392 } // namespace dart 4386 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/flow_graph_builder.cc ('k') | runtime/vm/flow_graph_type_propagator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698