diff --git a/libsolidity/interface/AssemblyStack.cpp b/libsolidity/interface/AssemblyStack.cpp index 6d30f5f73..a09de3c38 100644 --- a/libsolidity/interface/AssemblyStack.cpp +++ b/libsolidity/interface/AssemblyStack.cpp @@ -134,7 +134,7 @@ void AssemblyStack::optimize(yul::Object& _object) for (auto& subNode: _object.subObjects) if (auto subObject = dynamic_cast(subNode.get())) optimize(*subObject); - yul::OptimiserSuite::run(*languageToDialect(m_language), *_object.code, *_object.analysisInfo); + yul::OptimiserSuite::run(languageToDialect(m_language), *_object.code, *_object.analysisInfo); } MachineAssemblyObject AssemblyStack::assemble(Machine _machine, bool _optimize) const diff --git a/libyul/optimiser/Suite.cpp b/libyul/optimiser/Suite.cpp index aa1d4a139..3fb5a212c 100644 --- a/libyul/optimiser/Suite.cpp +++ b/libyul/optimiser/Suite.cpp @@ -50,7 +50,7 @@ using namespace dev; using namespace yul; void OptimiserSuite::run( - Dialect const& _dialect, + shared_ptr const& _dialect, Block& _ast, AsmAnalysisInfo const& _analysisInfo, set const& _externallyUsedIdentifiers @@ -58,52 +58,52 @@ void OptimiserSuite::run( { set reservedIdentifiers = _externallyUsedIdentifiers; - Block ast = boost::get(Disambiguator(_dialect, _analysisInfo, reservedIdentifiers)(_ast)); + Block ast = boost::get(Disambiguator(*_dialect, _analysisInfo, reservedIdentifiers)(_ast)); (VarDeclInitializer{})(ast); (FunctionHoister{})(ast); (BlockFlattener{})(ast); (FunctionGrouper{})(ast); EquivalentFunctionCombiner::run(ast); - UnusedPruner::runUntilStabilised(_dialect, ast, reservedIdentifiers); + UnusedPruner::runUntilStabilised(*_dialect, ast, reservedIdentifiers); (ForLoopInitRewriter{})(ast); (BlockFlattener{})(ast); - StructuralSimplifier{_dialect}(ast); + StructuralSimplifier{*_dialect}(ast); - NameDispenser dispenser{_dialect, ast}; + NameDispenser dispenser{*_dialect, ast}; for (size_t i = 0; i < 4; i++) { - ExpressionSplitter{_dialect, dispenser}(ast); + ExpressionSplitter{*_dialect, dispenser}(ast); SSATransform::run(ast, dispenser); - RedundantAssignEliminator::run(_dialect, ast); - RedundantAssignEliminator::run(_dialect, ast); + RedundantAssignEliminator::run(*_dialect, ast); + RedundantAssignEliminator::run(*_dialect, ast); - ExpressionSimplifier::run(_dialect, ast); - CommonSubexpressionEliminator{_dialect}(ast); - StructuralSimplifier{_dialect}(ast); + ExpressionSimplifier::run(*_dialect, ast); + CommonSubexpressionEliminator{*_dialect}(ast); + StructuralSimplifier{*_dialect}(ast); (BlockFlattener{})(ast); SSATransform::run(ast, dispenser); - RedundantAssignEliminator::run(_dialect, ast); - RedundantAssignEliminator::run(_dialect, ast); - UnusedPruner::runUntilStabilised(_dialect, ast, reservedIdentifiers); - CommonSubexpressionEliminator{_dialect}(ast); - UnusedPruner::runUntilStabilised(_dialect, ast, reservedIdentifiers); + RedundantAssignEliminator::run(*_dialect, ast); + RedundantAssignEliminator::run(*_dialect, ast); + UnusedPruner::runUntilStabilised(*_dialect, ast, reservedIdentifiers); + CommonSubexpressionEliminator{*_dialect}(ast); + UnusedPruner::runUntilStabilised(*_dialect, ast, reservedIdentifiers); SSAReverser::run(ast); - CommonSubexpressionEliminator{_dialect}(ast); - UnusedPruner::runUntilStabilised(_dialect, ast, reservedIdentifiers); + CommonSubexpressionEliminator{*_dialect}(ast); + UnusedPruner::runUntilStabilised(*_dialect, ast, reservedIdentifiers); ExpressionJoiner::run(ast); ExpressionJoiner::run(ast); - ExpressionInliner(_dialect, ast).run(); - UnusedPruner::runUntilStabilised(_dialect, ast, reservedIdentifiers); + ExpressionInliner(*_dialect, ast).run(); + UnusedPruner::runUntilStabilised(*_dialect, ast, reservedIdentifiers); - ExpressionSplitter{_dialect, dispenser}(ast); + ExpressionSplitter{*_dialect, dispenser}(ast); SSATransform::run(ast, dispenser); - RedundantAssignEliminator::run(_dialect, ast); - RedundantAssignEliminator::run(_dialect, ast); - CommonSubexpressionEliminator{_dialect}(ast); + RedundantAssignEliminator::run(*_dialect, ast); + RedundantAssignEliminator::run(*_dialect, ast); + CommonSubexpressionEliminator{*_dialect}(ast); (FunctionGrouper{})(ast); EquivalentFunctionCombiner::run(ast); @@ -111,33 +111,33 @@ void OptimiserSuite::run( (BlockFlattener{})(ast); SSATransform::run(ast, dispenser); - RedundantAssignEliminator::run(_dialect, ast); - RedundantAssignEliminator::run(_dialect, ast); - ExpressionSimplifier::run(_dialect, ast); - StructuralSimplifier{_dialect}(ast); + RedundantAssignEliminator::run(*_dialect, ast); + RedundantAssignEliminator::run(*_dialect, ast); + ExpressionSimplifier::run(*_dialect, ast); + StructuralSimplifier{*_dialect}(ast); (BlockFlattener{})(ast); - CommonSubexpressionEliminator{_dialect}(ast); + CommonSubexpressionEliminator{*_dialect}(ast); SSATransform::run(ast, dispenser); - RedundantAssignEliminator::run(_dialect, ast); - RedundantAssignEliminator::run(_dialect, ast); - UnusedPruner::runUntilStabilised(_dialect, ast, reservedIdentifiers); - CommonSubexpressionEliminator{_dialect}(ast); + RedundantAssignEliminator::run(*_dialect, ast); + RedundantAssignEliminator::run(*_dialect, ast); + UnusedPruner::runUntilStabilised(*_dialect, ast, reservedIdentifiers); + CommonSubexpressionEliminator{*_dialect}(ast); } ExpressionJoiner::run(ast); - Rematerialiser::run(_dialect, ast); - UnusedPruner::runUntilStabilised(_dialect, ast, reservedIdentifiers); + Rematerialiser::run(*_dialect, ast); + UnusedPruner::runUntilStabilised(*_dialect, ast, reservedIdentifiers); ExpressionJoiner::run(ast); - UnusedPruner::runUntilStabilised(_dialect, ast, reservedIdentifiers); + UnusedPruner::runUntilStabilised(*_dialect, ast, reservedIdentifiers); ExpressionJoiner::run(ast); - UnusedPruner::runUntilStabilised(_dialect, ast, reservedIdentifiers); + UnusedPruner::runUntilStabilised(*_dialect, ast, reservedIdentifiers); SSAReverser::run(ast); - CommonSubexpressionEliminator{_dialect}(ast); - UnusedPruner::runUntilStabilised(_dialect, ast, reservedIdentifiers); + CommonSubexpressionEliminator{*_dialect}(ast); + UnusedPruner::runUntilStabilised(*_dialect, ast, reservedIdentifiers); ExpressionJoiner::run(ast); - Rematerialiser::run(_dialect, ast); - UnusedPruner::runUntilStabilised(_dialect, ast, reservedIdentifiers); + Rematerialiser::run(*_dialect, ast); + UnusedPruner::runUntilStabilised(*_dialect, ast, reservedIdentifiers); _ast = std::move(ast); } diff --git a/libyul/optimiser/Suite.h b/libyul/optimiser/Suite.h index 376e9889b..8aeef7608 100644 --- a/libyul/optimiser/Suite.h +++ b/libyul/optimiser/Suite.h @@ -38,7 +38,7 @@ class OptimiserSuite { public: static void run( - Dialect const& _dialect, + std::shared_ptr const& _dialect, Block& _ast, AsmAnalysisInfo const& _analysisInfo, std::set const& _externallyUsedIdentifiers = {} diff --git a/test/libyul/YulOptimizerTest.cpp b/test/libyul/YulOptimizerTest.cpp index 306721a02..7b0cb1004 100644 --- a/test/libyul/YulOptimizerTest.cpp +++ b/test/libyul/YulOptimizerTest.cpp @@ -242,7 +242,7 @@ bool YulOptimizerTest::run(ostream& _stream, string const& _linePrefix, bool con UnusedPruner::runUntilStabilised(*m_dialect, *m_ast); } else if (m_optimizerStep == "fullSuite") - OptimiserSuite::run(*m_dialect, *m_ast, *m_analysisInfo); + OptimiserSuite::run(m_dialect, *m_ast, *m_analysisInfo); else { FormattedScope(_stream, _formatted, {formatting::BOLD, formatting::RED}) << _linePrefix << "Invalid optimizer step: " << m_optimizerStep << endl;