mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Evaluate keccak(a, const) if value at memory location a is known
Here the value of constant can be at most 32.
This commit is contained in:
@@ -32,6 +32,9 @@ namespace solidity::yul
|
||||
* Optimisation stage that replaces expressions of type ``sload(x)`` and ``mload(x)`` by the value
|
||||
* currently stored in storage resp. memory, if known.
|
||||
*
|
||||
* Also evaluates simple ``keccak256(a, c)`` when the value at memory location `a` is known and `c`
|
||||
* is a constant `<= 32`.
|
||||
*
|
||||
* Works best if the code is in SSA form.
|
||||
*
|
||||
* Prerequisite: Disambiguator, ForLoopInitRewriter.
|
||||
@@ -47,10 +50,12 @@ private:
|
||||
LoadResolver(
|
||||
Dialect const& _dialect,
|
||||
std::map<YulString, SideEffects> _functionSideEffects,
|
||||
bool _optimizeMLoad
|
||||
bool _optimizeMLoad,
|
||||
std::optional<size_t> _expectedExecutionsPerDeployment
|
||||
):
|
||||
DataFlowAnalyzer(_dialect, std::move(_functionSideEffects)),
|
||||
m_optimizeMLoad(_optimizeMLoad)
|
||||
m_optimizeMLoad(_optimizeMLoad),
|
||||
m_expectedExecutionsPerDeployment(std::move(_expectedExecutionsPerDeployment))
|
||||
{}
|
||||
|
||||
protected:
|
||||
@@ -63,7 +68,16 @@ protected:
|
||||
std::vector<Expression> const& _arguments
|
||||
);
|
||||
|
||||
/// Evaluates simple ``keccak256(a, c)`` when the value at memory location ``a`` is known and
|
||||
/// `c` is a constant `<= 32`.
|
||||
void tryEvaluateKeccak(
|
||||
Expression& _e,
|
||||
std::vector<Expression> const& _arguments
|
||||
);
|
||||
|
||||
bool m_optimizeMLoad = false;
|
||||
/// The --optimize-runs parameter. Value `nullopt` represents creation code.
|
||||
std::optional<size_t> m_expectedExecutionsPerDeployment;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user