mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Fix expression simplifying by moving from SSAValueTracker to DataFlowAnalyzer as a base.
This commit is contained in:
@@ -36,7 +36,7 @@ using namespace dev::solidity;
|
||||
void ExpressionSimplifier::visit(Expression& _expression)
|
||||
{
|
||||
ASTModifier::visit(_expression);
|
||||
while (auto match = SimplificationRules::findFirstMatch(_expression, m_dialect, m_ssaValues))
|
||||
while (auto match = SimplificationRules::findFirstMatch(_expression, m_dialect, m_value))
|
||||
{
|
||||
// Do not apply the rule if it removes non-constant parts of the expression.
|
||||
// TODO: The check could actually be less strict than "movable".
|
||||
@@ -53,7 +53,5 @@ void ExpressionSimplifier::visit(Expression& _expression)
|
||||
|
||||
void ExpressionSimplifier::run(Dialect const& _dialect, Block& _ast)
|
||||
{
|
||||
SSAValueTracker ssaValues;
|
||||
ssaValues(_ast);
|
||||
ExpressionSimplifier{_dialect, ssaValues.values()}(_ast);
|
||||
ExpressionSimplifier{_dialect}(_ast);
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
|
||||
#include <libyul/AsmDataForward.h>
|
||||
|
||||
#include <libyul/optimiser/ASTWalker.h>
|
||||
#include <libyul/optimiser/DataFlowAnalyzer.h>
|
||||
|
||||
namespace yul
|
||||
{
|
||||
@@ -33,9 +33,12 @@ struct Dialect;
|
||||
* The component will work best if the code is in SSA form, but
|
||||
* this is not required for correctness.
|
||||
*
|
||||
* It tracks the current values of variables using the DataFlowAnalyzer
|
||||
* and takes them into account for replacements.
|
||||
*
|
||||
* Prerequisite: Disambiguator.
|
||||
*/
|
||||
class ExpressionSimplifier: public ASTModifier
|
||||
class ExpressionSimplifier: public DataFlowAnalyzer
|
||||
{
|
||||
public:
|
||||
using ASTModifier::operator();
|
||||
@@ -43,12 +46,7 @@ public:
|
||||
|
||||
static void run(Dialect const& _dialect, Block& _ast);
|
||||
private:
|
||||
explicit ExpressionSimplifier(Dialect const& _dialect, std::map<YulString, Expression const*> _ssaValues):
|
||||
m_dialect(_dialect), m_ssaValues(std::move(_ssaValues))
|
||||
{}
|
||||
|
||||
Dialect const& m_dialect;
|
||||
std::map<YulString, Expression const*> m_ssaValues;
|
||||
explicit ExpressionSimplifier(Dialect const& _dialect): DataFlowAnalyzer(_dialect) {}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user