Merge pull request #6520 from ethereum/addAssertForLoopDeadCode

Add assertion that DeadCodeEliminator needs ForLoopInitRewriter.
This commit is contained in:
chriseth 2019-04-16 15:52:18 +02:00 committed by GitHub
commit 94053c9a52
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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
// ----
// {
// for {
// let a := 10
// for {
// }
// iszero(iszero(a))
// {