mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Allow ExpressionJoiner to be run until it stabilizes.
This commit is contained in:
parent
1eb8d8f10b
commit
b0fa2fb296
@ -40,6 +40,17 @@ void ExpressionJoiner::run(OptimiserStepContext&, Block& _ast)
|
|||||||
ExpressionJoiner{_ast}(_ast);
|
ExpressionJoiner{_ast}(_ast);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ExpressionJoiner::runUntilStabilized(OptimiserStepContext&, Block& _ast)
|
||||||
|
{
|
||||||
|
while (true)
|
||||||
|
{
|
||||||
|
ExpressionJoiner expressionJoiner{_ast};
|
||||||
|
expressionJoiner(_ast);
|
||||||
|
if (!expressionJoiner.m_expressionWasJoined)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void ExpressionJoiner::operator()(FunctionCall& _funCall)
|
void ExpressionJoiner::operator()(FunctionCall& _funCall)
|
||||||
{
|
{
|
||||||
@ -74,6 +85,7 @@ void ExpressionJoiner::visit(Expression& _e)
|
|||||||
*latestStatement() = Block();
|
*latestStatement() = Block();
|
||||||
|
|
||||||
decrementLatestStatementPointer();
|
decrementLatestStatementPointer();
|
||||||
|
m_expressionWasJoined = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@ -74,6 +74,7 @@ class ExpressionJoiner: public ASTModifier
|
|||||||
public:
|
public:
|
||||||
static constexpr char const* name{"ExpressionJoiner"};
|
static constexpr char const* name{"ExpressionJoiner"};
|
||||||
static void run(OptimiserStepContext&, Block& _ast);
|
static void run(OptimiserStepContext&, Block& _ast);
|
||||||
|
static void runUntilStabilized(OptimiserStepContext&, Block& _ast);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
explicit ExpressionJoiner(Block& _ast);
|
explicit ExpressionJoiner(Block& _ast);
|
||||||
@ -92,9 +93,10 @@ private:
|
|||||||
bool isLatestStatementVarDeclJoinable(Identifier const& _identifier);
|
bool isLatestStatementVarDeclJoinable(Identifier const& _identifier);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Block* m_currentBlock = nullptr; ///< Pointer to current block holding the statement being visited.
|
Block* m_currentBlock = nullptr; ///< Pointer to current block holding the statement being visited.
|
||||||
size_t m_latestStatementInBlock = 0; ///< Offset to m_currentBlock's statements of the last visited statement.
|
size_t m_latestStatementInBlock = 0; ///< Offset to m_currentBlock's statements of the last visited statement.
|
||||||
std::map<YulString, size_t> m_references; ///< Holds reference counts to all variable declarations in current block.
|
std::map<YulString, size_t> m_references; ///< Holds reference counts to all variable declarations in current block.
|
||||||
|
bool m_expressionWasJoined = false; ///< True, if any expression was joined during the visit.
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user