Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Static Public Member Functions | List of all members
dart::DelayAllocations Class Reference

#include <redundancy_elimination.h>

Inheritance diagram for dart::DelayAllocations:
dart::AllStatic

Static Public Member Functions

static void Optimize (FlowGraph *graph)
 

Detailed Description

Definition at line 154 of file redundancy_elimination.h.

Member Function Documentation

◆ Optimize()

void dart::DelayAllocations::Optimize ( FlowGraph graph)
static

Definition at line 1635 of file redundancy_elimination.cc.

1635 {
1636 // Go through all Allocation instructions and move them down to their
1637 // dominant use when doing so is sound.
1638 DirectChainedHashMap<IdentitySetKeyValueTrait<Instruction*>> moved;
1639 for (BlockIterator block_it = graph->reverse_postorder_iterator();
1640 !block_it.Done(); block_it.Advance()) {
1641 BlockEntryInstr* block = block_it.Current();
1642
1643 for (ForwardInstructionIterator instr_it(block); !instr_it.Done();
1644 instr_it.Advance()) {
1645 Definition* def = instr_it.Current()->AsDefinition();
1646 if (def != nullptr && def->IsAllocation() && def->env() == nullptr &&
1647 !moved.HasKey(def)) {
1648 Instruction* use = DominantUse(def);
1649 if (use != nullptr && !use->IsPhi() && IsOneTimeUse(use, def)) {
1650 instr_it.RemoveCurrentFromGraph();
1651 def->InsertBefore(use);
1652 moved.Insert(def);
1653 }
1654 }
1655 }
1656 }
1657}

The documentation for this class was generated from the following files: