17 class IRFunctionOptimizer;
26 std::map<FuncIdentifier, std::set<FuncIdentifier>>
callGraph;
27 std::map<FuncIdentifier, std::set<FuncIdentifier>>
callerGraph;
81 std::set<yoi::indexT>::const_iterator
it;
83 Iterator(
const std::set<yoi::indexT> &set);
85 Iterator(std::set<yoi::indexT>::const_iterator
it);
98 std::shared_ptr<IRValueType>
type;
138 void push(
const std::shared_ptr<IRValueType> &type,
147 void push(
const std::shared_ptr<IRValueType> &type,
164 yoi::indexT reduce(
const SimulationStack::Item::ContributedInstructionSet &contributedInstructions,
201 SimulationStack::Item
lessThan(
const SimulationStack::Item &item,
const SimulationStack::Item &right);
203 SimulationStack::Item
lessThanOrEqual(
const SimulationStack::Item &item,
const SimulationStack::Item &right);
205 SimulationStack::Item
greaterThan(
const SimulationStack::Item &item,
const SimulationStack::Item &right);
207 SimulationStack::Item
greaterThanOrEqual(
const SimulationStack::Item &item,
const SimulationStack::Item &right);
209 SimulationStack::Item
equal(
const SimulationStack::Item &item,
const SimulationStack::Item &right);
211 SimulationStack::Item
notEqual(
const SimulationStack::Item &item,
const SimulationStack::Item &right);
230 const std::shared_ptr<IRModule> &
irModule,
231 std::map<CallGraph::FuncIdentifier, FunctionAnalysisInfo> &globalResults);
260 std::pair<std::map<indexT, std::vector<indexT>>, std::map<indexT, std::vector<indexT>>>
performCFGAnalysis();
SimulationStack::Item lessThanOrEqual(const SimulationStack::Item &item, const SimulationStack::Item &right)
std::map< CallGraph::FuncIdentifier, FunctionAnalysisInfo > & globalAnalysisResults
AnalysisState mergeStatesForInterfaceAllocationReduction(const AnalysisState &s1, const AnalysisState &s2)
std::map< yoi::indexT, VariablesExtraInfo > variablesExtraInfo
CallGraph::FuncIdentifier currentFuncId
yoi::indexT reduce(const SimulationStack::Item::ContributedInstructionSet &contributedInstructions, yoi::indexT currentIndex)
bool performInterfaceAllocationReduction()
IRFunctionOptimizer & reduceEmptyCodeBlock()
void handleInstruction(const IR &ins, yoi::indexT insIndex, yoi::indexT currentCodeBlockIndex)
SimulationStack::Item equal(const SimulationStack::Item &item, const SimulationStack::Item &right)
SimulationStack::Item div(const IRFunctionOptimizer::SimulationStack::Item &a, const IRFunctionOptimizer::SimulationStack::Item &b)
void transformBlock(indexT blockIndex, const AnalysisState &inState)
std::shared_ptr< IRFunctionDefinition > targetFunction
SimulationStack::Item add(const IRFunctionOptimizer::SimulationStack::Item &a, const IRFunctionOptimizer::SimulationStack::Item &b)
SimulationStack::Item mul(const IRFunctionOptimizer::SimulationStack::Item &a, const IRFunctionOptimizer::SimulationStack::Item &b)
SimulationStack::Item greaterThanOrEqual(const SimulationStack::Item &item, const SimulationStack::Item &right)
SimulationStack::Item sub(const IRFunctionOptimizer::SimulationStack::Item &a, const IRFunctionOptimizer::SimulationStack::Item &b)
AnalysisState analyzeBlockForRaw(indexT blockIndex, const AnalysisState &inState)
SimulationStack::Item bitwiseAnd(const IRFunctionOptimizer::SimulationStack::Item &a, const IRFunctionOptimizer::SimulationStack::Item &b)
IRFunctionOptimizer & controlFlowOptimization()
struct yoi::IRFunctionOptimizer::SimulationStack simulationStack
bool performNullableCheck()
SimulationStack::Item negate(const IRFunctionOptimizer::SimulationStack::Item &a)
SimulationStack::Item bitwiseShiftRight(const IRFunctionOptimizer::SimulationStack::Item &a, const IRFunctionOptimizer::SimulationStack::Item &b)
IRFunctionOptimizer & doOptimizationForCurrentFunction()
SimulationStack::Item bitwiseNot(const IRFunctionOptimizer::SimulationStack::Item &a)
yoi::indexT currentCodeBlockIndex
std::pair< std::map< indexT, std::vector< indexT > >, std::map< indexT, std::vector< indexT > > > performCFGAnalysis()
AnalysisState mergeStatesForRaw(const AnalysisState &s1, const AnalysisState &s2)
IRFunctionOptimizer & reduceRedundantTempVar()
IRFunctionOptimizer & reduceRedundantNop()
SimulationStack::Item mod(const IRFunctionOptimizer::SimulationStack::Item &a, const IRFunctionOptimizer::SimulationStack::Item &b)
yoi::indexT generatePushOp(const SimulationStack::Item &item, yoi::indexT index)
SimulationStack::Item bitwiseShiftLeft(const IRFunctionOptimizer::SimulationStack::Item &a, const IRFunctionOptimizer::SimulationStack::Item &b)
AnalysisState analyzeBlockForNullable(indexT blockIndex, const AnalysisState &inState)
AnalysisState analyzeBlock(indexT blockIndex, const AnalysisState &inState)
IRFunctionOptimizer & reduceRedundantJump()
SimulationStack::Item lessThan(const SimulationStack::Item &item, const SimulationStack::Item &right)
IRFunctionOptimizer & reduceRedundantCodeAfterRet()
AnalysisState analyzeBlockForInterfaceAllocationReduction(indexT blockIndex, const AnalysisState &inState)
IRFunctionOptimizer & reduceRedundantConstantExpr()
IRFunctionOptimizer & setTargetFunction(const std::shared_ptr< IRFunctionDefinition > &targetFunction, CallGraph::FuncIdentifier funcId)
SimulationStack::Item bitwiseOr(const IRFunctionOptimizer::SimulationStack::Item &a, const IRFunctionOptimizer::SimulationStack::Item &b)
AnalysisState mergeStatesForNullable(const AnalysisState &s1, const AnalysisState &s2)
std::shared_ptr< IRModule > irModule
bool performParamBorrowCheck()
std::shared_ptr< compilerContext > compilerCtx
SimulationStack::Item notEqual(const SimulationStack::Item &item, const SimulationStack::Item &right)
SimulationStack::Item bitwiseXor(const IRFunctionOptimizer::SimulationStack::Item &a, const IRFunctionOptimizer::SimulationStack::Item &b)
SimulationStack::Item greaterThan(const SimulationStack::Item &item, const SimulationStack::Item &right)
bool performInterfaceWrapperPass()
bool performStructNullablePass()
bool performBaseOptimization()
yoi::indexT entryModuleIndex
std::shared_ptr< compilerContext > compilerCtx
std::map< CallGraph::FuncIdentifier, FunctionAnalysisInfo > functionAnalysisResults
AnalysisState mergeStates(const AnalysisState &s1, const AnalysisState &s2)
IRFunctionOptimizer::SimulationStack stack
std::map< indexT, IRFunctionOptimizer::VariablesExtraInfo > variableStates
bool operator!=(const AnalysisState &other) const
std::map< FuncIdentifier, std::set< FuncIdentifier > > callGraph
std::pair< indexT, indexT > FuncIdentifier
void addCall(FuncIdentifier caller, FuncIdentifier callee)
std::set< FuncIdentifier > functions
yoi::indexT entryModuleIndex
std::set< FuncIdentifier > entryPoints
std::map< FuncIdentifier, std::set< FuncIdentifier > > callerGraph
std::set< FuncIdentifier > unreachableFunctions
bool isYieldValueNullable
yoi::vec< ParameterState > paramStates
bool isReturnValueNullable
bool operator!=(const FunctionAnalysisInfo &other) const
yoi::indexT operator*() const
bool operator!=(const Iterator &other) const
std::set< yoi::indexT >::const_iterator it
ContributedInstructionSet & insert(yoi::indexT index)
ContributedInstructionSet operator+(const ContributedInstructionSet &other) const
ContributedInstructionSet()=default
yoi::indexT codeBlockIndex
std::set< yoi::indexT > instructions
ContributedInstructionSet contributedInstructions
std::shared_ptr< IRValueType > type
union yoi::IRFunctionOptimizer::SimulationStack::Item::PossibleValue possibleValue
Item & peek(yoi::indexT index)
std::vector< Item > items
void push(const std::shared_ptr< IRValueType > &type, const Item::ContributedInstructionSet &contributedInstructions)
SimulationStack()=default
yoi::indexT stringConstIndex