Add assertion that DeadCodeEliminator needs ForLoopInitRewriter.

This commit is contained in:
chriseth 2019-04-15 15:15:48 +02:00
parent bf5792f7ca
commit fb06451f45
4 changed files with 9 additions and 1 deletions

View File

@ -67,6 +67,12 @@ auto findFirstTerminatingStatement(Block& _block)
}
}
void DeadCodeEliminator::operator()(ForLoop& _for)
{
yulAssert(_for.pre.statements.empty(), "DeadCodeEliminator needs ForLoopInitRewriter as a prerequisite.");
ASTModifier::operator()(_for);
}
void DeadCodeEliminator::operator()(Block& _block)
{
auto& statements = _block.statements;

View File

@ -47,6 +47,7 @@ class DeadCodeEliminator: public ASTModifier
{
public:
using ASTModifier::operator();
void operator()(ForLoop& _for) override;
void operator()(Block& _block) override;
};

View File

@ -192,6 +192,7 @@ bool YulOptimizerTest::run(ostream& _stream, string const& _linePrefix, bool con
disambiguate();
NameDispenser nameDispenser{*m_dialect, *m_ast};
ExpressionSplitter{*m_dialect, nameDispenser}(*m_ast);
ForLoopInitRewriter{}(*m_ast);
CommonSubexpressionEliminator{*m_dialect}(*m_ast);
ExpressionSimplifier::run(*m_dialect, *m_ast);
UnusedPruner::runUntilStabilised(*m_dialect, *m_ast);

View File

@ -6,8 +6,8 @@
// step: fullSimplify
// ----
// {
// let a := 10
// for {
// let a := 10
// }
// iszero(iszero(a))
// {