4480 {
4481 GrowableArray<Instruction*>
worklist;
4482 BitVector live(flow_graph->zone(), flow_graph->current_ssa_temp_index());
4483
4484
4485 for (BlockIterator block_it = flow_graph->reverse_postorder_iterator();
4486 !block_it.Done(); block_it.Advance()) {
4487 BlockEntryInstr* block = block_it.Current();
4488 for (ForwardInstructionIterator it(block); !it.Done(); it.Advance()) {
4489 Instruction* current = it.Current();
4490 ASSERT(!current->IsMoveArgument());
4491
4492
4493 if (!current->CanEliminate(block)) {
4495 if (Definition* def = current->AsDefinition()) {
4496 if (def->HasSSATemp()) {
4497 live.Add(def->ssa_temp_index());
4498 }
4499 }
4500 }
4501 }
4502 }
4503
4504
4506 Instruction* current =
worklist.RemoveLast();
4507 for (intptr_t
i = 0, n = current->InputCount();
i < n; ++
i) {
4508 Definition* input = current->InputAt(
i)->definition();
4509 ASSERT(input->HasSSATemp());
4510 if (!live.Contains(input->ssa_temp_index())) {
4512 live.Add(input->ssa_temp_index());
4513 }
4514 }
4515 for (intptr_t
i = 0, n = current->ArgumentCount();
i < n; ++
i) {
4516 Definition* input = current->ArgumentAt(
i);
4517 ASSERT(input->HasSSATemp());
4518 if (!live.Contains(input->ssa_temp_index())) {
4520 live.Add(input->ssa_temp_index());
4521 }
4522 }
4523 if (current->env() != nullptr) {
4524 for (Environment::DeepIterator it(current->env()); !it.Done();
4525 it.Advance()) {
4526 Definition* input = it.CurrentValue()->definition();
4527 ASSERT(!input->IsMoveArgument());
4528 if (input->HasSSATemp() && !live.Contains(input->ssa_temp_index())) {
4530 live.Add(input->ssa_temp_index());
4531 }
4532 }
4533 }
4534 }
4535
4536
4537 for (BlockIterator block_it = flow_graph->reverse_postorder_iterator();
4538 !block_it.Done(); block_it.Advance()) {
4539 BlockEntryInstr* block = block_it.Current();
4540 if (JoinEntryInstr*
join = block->AsJoinEntry()) {
4541 for (PhiIterator it(
join); !it.Done(); it.Advance()) {
4542 PhiInstr* current = it.Current();
4543 if (!live.Contains(current->ssa_temp_index())) {
4544 it.RemoveCurrentFromGraph();
4545 }
4546 }
4547 }
4548 for (ForwardInstructionIterator it(block); !it.Done(); it.Advance()) {
4549 Instruction* current = it.Current();
4550 if (!current->CanEliminate(block)) {
4551 continue;
4552 }
4553 ASSERT(!current->IsMoveArgument());
4554 ASSERT((current->ArgumentCount() == 0) || !current->HasMoveArguments());
4555 if (Definition* def = current->AsDefinition()) {
4556 if (def->HasSSATemp() && live.Contains(def->ssa_temp_index())) {
4557 continue;
4558 }
4559 }
4560 it.RemoveCurrentFromGraph();
4561 }
4562 }
4563}
static SkString join(const CommandLineFlags::StringArray &)