Use side effects of user-defined functions in other optimizer steps.

This commit is contained in:
chriseth
2021-11-02 11:59:01 +01:00
parent 5eb97fa6ee
commit d6c461ed61
8 changed files with 88 additions and 32 deletions
+9 -2
View File
@@ -31,12 +31,15 @@ namespace solidity::yul
{
struct Dialect;
struct OptimiserStepContext;
struct ControlFlowSideEffects;
/**
* Optimisation stage that removes unreachable code
*
* Unreachable code is any code within a block which is preceded by a
* leave, return, invalid, break, continue, selfdestruct or revert.
* leave, return, invalid, break, continue, selfdestruct or revert or
* a call to a user-defined function that never returns (either due to
* recursion or a call to return / revert / stop).
*
* Function definitions are retained as they might be called by earlier
* code and thus are considered reachable.
@@ -57,9 +60,13 @@ public:
void operator()(Block& _block) override;
private:
DeadCodeEliminator(Dialect const& _dialect): m_dialect(_dialect) {}
DeadCodeEliminator(
Dialect const& _dialect,
std::map<YulString, ControlFlowSideEffects> const& _sideEffects
): m_dialect(_dialect), m_functionSideEffects(_sideEffects) {}
Dialect const& m_dialect;
std::map<YulString, ControlFlowSideEffects> const& m_functionSideEffects;
};
}