Merge pull request #5366 from ethereum/addVarDecl

[Yul] Add VarDeclPropagator to full suite and interactive optimizer.
This commit is contained in:
chriseth 2018-11-08 12:21:45 +01:00 committed by GitHub
commit bf5b36a1ed
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 1 deletions

View File

@ -33,6 +33,7 @@
#include <libyul/optimiser/CommonSubexpressionEliminator.h> #include <libyul/optimiser/CommonSubexpressionEliminator.h>
#include <libyul/optimiser/SSATransform.h> #include <libyul/optimiser/SSATransform.h>
#include <libyul/optimiser/RedundantAssignEliminator.h> #include <libyul/optimiser/RedundantAssignEliminator.h>
#include <libyul/optimiser/VarDeclPropagator.h>
#include <libsolidity/inlineasm/AsmAnalysisInfo.h> #include <libsolidity/inlineasm/AsmAnalysisInfo.h>
#include <libsolidity/inlineasm/AsmData.h> #include <libsolidity/inlineasm/AsmData.h>
@ -65,6 +66,7 @@ void OptimiserSuite::run(
ExpressionSplitter{dispenser}(ast); ExpressionSplitter{dispenser}(ast);
SSATransform::run(ast, dispenser); SSATransform::run(ast, dispenser);
RedundantAssignEliminator::run(ast); RedundantAssignEliminator::run(ast);
VarDeclPropagator{}(ast);
RedundantAssignEliminator::run(ast); RedundantAssignEliminator::run(ast);
CommonSubexpressionEliminator{}(ast); CommonSubexpressionEliminator{}(ast);
@ -90,21 +92,26 @@ void OptimiserSuite::run(
RedundantAssignEliminator::run(ast); RedundantAssignEliminator::run(ast);
CommonSubexpressionEliminator{}(ast); CommonSubexpressionEliminator{}(ast);
FullInliner{ast, dispenser}.run(); FullInliner{ast, dispenser}.run();
VarDeclPropagator{}(ast);
SSATransform::run(ast, dispenser); SSATransform::run(ast, dispenser);
RedundantAssignEliminator::run(ast); RedundantAssignEliminator::run(ast);
VarDeclPropagator{}(ast);
RedundantAssignEliminator::run(ast); RedundantAssignEliminator::run(ast);
ExpressionSimplifier::run(ast); ExpressionSimplifier::run(ast);
CommonSubexpressionEliminator{}(ast); CommonSubexpressionEliminator{}(ast);
SSATransform::run(ast, dispenser); SSATransform::run(ast, dispenser);
RedundantAssignEliminator::run(ast); RedundantAssignEliminator::run(ast);
VarDeclPropagator{}(ast);
RedundantAssignEliminator::run(ast); RedundantAssignEliminator::run(ast);
UnusedPruner::runUntilStabilised(ast, reservedIdentifiers); UnusedPruner::runUntilStabilised(ast, reservedIdentifiers);
} }
ExpressionJoiner::run(ast); ExpressionJoiner::run(ast);
VarDeclPropagator{}(ast);
UnusedPruner::runUntilStabilised(ast); UnusedPruner::runUntilStabilised(ast);
ExpressionJoiner::run(ast); ExpressionJoiner::run(ast);
UnusedPruner::runUntilStabilised(ast); UnusedPruner::runUntilStabilised(ast);
ExpressionJoiner::run(ast); ExpressionJoiner::run(ast);
VarDeclPropagator{}(ast);
UnusedPruner::runUntilStabilised(ast); UnusedPruner::runUntilStabilised(ast);
ExpressionJoiner::run(ast); ExpressionJoiner::run(ast);
UnusedPruner::runUntilStabilised(ast); UnusedPruner::runUntilStabilised(ast);

View File

@ -45,6 +45,7 @@
#include <libyul/optimiser/ExpressionJoiner.h> #include <libyul/optimiser/ExpressionJoiner.h>
#include <libyul/optimiser/RedundantAssignEliminator.h> #include <libyul/optimiser/RedundantAssignEliminator.h>
#include <libyul/optimiser/SSATransform.h> #include <libyul/optimiser/SSATransform.h>
#include <libyul/optimiser/VarDeclPropagator.h>
#include <libdevcore/JSON.h> #include <libdevcore/JSON.h>
@ -120,7 +121,7 @@ public:
m_nameDispenser = make_shared<NameDispenser>(*m_ast); m_nameDispenser = make_shared<NameDispenser>(*m_ast);
disambiguated = true; disambiguated = true;
} }
cout << "(q)quit/(f)flatten/(c)se/(x)plit/(j)oin/(g)rouper/(h)oister/" << endl; cout << "(q)quit/(f)flatten/(c)se/propagate var(d)ecls/(x)plit/(j)oin/(g)rouper/(h)oister/" << endl;
cout << " (e)xpr inline/(i)nline/(s)implify/(u)nusedprune/ss(a) transform/" << endl; cout << " (e)xpr inline/(i)nline/(s)implify/(u)nusedprune/ss(a) transform/" << endl;
cout << " (r)edundant assign elim./re(m)aterializer? "; cout << " (r)edundant assign elim./re(m)aterializer? ";
cout.flush(); cout.flush();
@ -136,6 +137,9 @@ public:
case 'c': case 'c':
(CommonSubexpressionEliminator{})(*m_ast); (CommonSubexpressionEliminator{})(*m_ast);
break; break;
case 'd':
(VarDeclPropagator{})(*m_ast);
break;
case 'x': case 'x':
ExpressionSplitter{*m_nameDispenser}(*m_ast); ExpressionSplitter{*m_nameDispenser}(*m_ast);
break; break;