| Index: runtime/vm/flow_graph_optimizer.cc
|
| diff --git a/runtime/vm/flow_graph_optimizer.cc b/runtime/vm/flow_graph_optimizer.cc
|
| index fc311613061d29ff9f3628b1074c474d16a4aa7d..2dbb285541fbe50ed8a6c262d52086f20a54dad8 100644
|
| --- a/runtime/vm/flow_graph_optimizer.cc
|
| +++ b/runtime/vm/flow_graph_optimizer.cc
|
| @@ -2383,6 +2383,23 @@ void ConstantPropagator::Transform() {
|
| b.Advance()) {
|
| BlockEntryInstr* block = b.Current();
|
| if (!reachable_->Contains(block->preorder_number())) {
|
| + // Remove phi inputs corresponding to unreachable predecessor blocks.
|
| + // Predecessors will be recomputed (in block id order) after removing
|
| + // unreachable code so we merely have to keep the phi inputs in order.
|
| + GotoInstr* jump = block->last_instruction()->AsGoto();
|
| + if (jump != NULL) {
|
| + JoinEntryInstr* join = jump->successor();
|
| + ZoneGrowableArray<PhiInstr*>* phis = join->phis();
|
| + if (phis != NULL) {
|
| + intptr_t pred_idx = join->IndexOfPredecessor(block);
|
| + ASSERT(pred_idx >= 0);
|
| + for (intptr_t phi_idx = 0; phi_idx < phis->length(); ++phi_idx) {
|
| + PhiInstr* phi = (*phis)[phi_idx];
|
| + if (phi == NULL) continue;
|
| + phi->RemoveInputAt(pred_idx);
|
| + }
|
| + }
|
| + }
|
| continue;
|
| }
|
| for (ForwardInstructionIterator i(block); !i.Done(); i.Advance()) {
|
| @@ -2412,13 +2429,14 @@ void ConstantPropagator::Transform() {
|
| ASSERT(branch->comparison()->IsStrictCompare());
|
| ASSERT(if_false->parallel_move() == NULL);
|
| ASSERT(if_false->loop_info() == NULL);
|
| - join = new JoinEntryInstr(if_false->try_index());
|
| + join =
|
| + new JoinEntryInstr(if_false->block_id(), if_false->try_index());
|
| next = if_false->next();
|
| } else if (!reachable_->Contains(if_false->preorder_number())) {
|
| ASSERT(branch->comparison()->IsStrictCompare());
|
| ASSERT(if_true->parallel_move() == NULL);
|
| ASSERT(if_true->loop_info() == NULL);
|
| - join = new JoinEntryInstr(if_true->try_index());
|
| + join = new JoinEntryInstr(if_true->block_id(), if_true->try_index());
|
| next = if_true->next();
|
| }
|
|
|
| @@ -2445,19 +2463,6 @@ void ConstantPropagator::Transform() {
|
| graph_->DiscoverBlocks();
|
| GrowableArray<BitVector*> dominance_frontier;
|
| graph_->ComputeDominators(&dominance_frontier);
|
| -
|
| - // Garbage collect phi inputs corresponding to unreachable predecessors.
|
| - // This is required because we assume that predecessor and phi indexes
|
| - // align. Note that this does not necessarily eliminate all useless phis
|
| - // (e.g., it does not eliminate phis that were originally inserted solely
|
| - // due to an assignment on the now-unreachable path).
|
| - for (BlockIterator it = graph_->reverse_postorder_iterator();
|
| - !it.Done();
|
| - it.Advance()) {
|
| - JoinEntryInstr* join = it.Current()->AsJoinEntry();
|
| - if (join != NULL) join->EliminateUnreachablePhiInputs();
|
| - }
|
| -
|
| graph_->ComputeUseLists();
|
| }
|
|
|
|
|