5#ifndef RUNTIME_VM_COMPILER_BACKEND_REDUNDANCY_ELIMINATION_H_
6#define RUNTIME_VM_COMPILER_BACKEND_REDUNDANCY_ELIMINATION_H_
8#if defined(DART_PRECOMPILED_RUNTIME)
9#error "AOT runtime should not use compiler sources (including header files)"
17class CSEInstructionSet;
22 : flow_graph_(flow_graph), candidates_(5), materializations_(5) {}
43 ExitsCollector() : exits_(10), worklist_(3) {}
45 const GrowableArray<Instruction*>& exits()
const {
return exits_; }
47 void CollectTransitively(Definition* alloc);
53 void Collect(Definition* alloc);
55 GrowableArray<Instruction*> exits_;
56 GrowableArray<Definition*> worklist_;
59 void CollectCandidates();
61 void NormalizeMaterializations();
63 void RemoveUnusedMaterializations();
65 void DiscoverFailedCandidates();
67 void InsertMaterializations(Definition* alloc);
69 void CreateMaterializationAt(Instruction*
exit,
71 const ZoneGrowableArray<const Slot*>& fields);
73 void EliminateAllocation(Definition* alloc);
75 enum SafeUseCheck { kOptimisticCheck, kStrictCheck };
77 bool IsAllocationSinkingCandidate(Definition* alloc, SafeUseCheck check_type);
79 bool IsSafeUse(
Value* use, SafeUseCheck check_type);
81 Zone* zone()
const {
return flow_graph_->
zone(); }
83 FlowGraph* flow_graph_;
85 GrowableArray<Definition*> candidates_;
86 GrowableArray<MaterializeObjectInstr*> materializations_;
88 ExitsCollector exits_collector_;
100 static bool OptimizeRecursive(
FlowGraph* graph,
140 FlowGraph* flow_graph()
const {
return flow_graph_; }
146 void TrySpecializeSmiPhi(
PhiInstr* phi,
MaterializeObjectInstr * MaterializationFor(Definition *alloc, Instruction *exit)
const GrowableArray< Definition * > & candidates() const
AllocationSinking(FlowGraph *flow_graph)
void DetachMaterializations()
static void EliminateStackOverflow(FlowGraph *graph)
static void EliminateDeadPhis(FlowGraph *graph)
static void RemoveDeadAndRedundantPhisFromTheGraph(FlowGraph *graph)
static void EliminateDeadCode(FlowGraph *graph)
static void Optimize(FlowGraph *graph)
static void Optimize(FlowGraph *graph)
static bool Optimize(FlowGraph *graph, bool run_load_optimization=true)
void OptimisticallySpecializeSmiPhis()
LICM(FlowGraph *flow_graph)
void OptimizeCatchEntryStates(FlowGraph *flow_graph, bool is_aot)
SI auto map(std::index_sequence< I... >, Fn &&fn, const Args &... args) -> skvx::Vec< sizeof...(I), decltype(fn(args[0]...))>
static const char header[]