From 6f4086d17969d10aed14a56f6484489f101113fb Mon Sep 17 00:00:00 2001 From: clonker <1685266+clonker@users.noreply.github.com> Date: Wed, 12 Mar 2025 09:03:08 +0100 Subject: [PATCH 01/17] Yul: Integrate numeric LabelID as YulName --- libyul/ASTForward.h | 3 +-- libyul/ASTLabelRegistry.h | 4 +++- libyul/YulName.h | 4 ++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/libyul/ASTForward.h b/libyul/ASTForward.h index 868fc84b2827..6009fc1956da 100644 --- a/libyul/ASTForward.h +++ b/libyul/ASTForward.h @@ -28,8 +28,7 @@ namespace solidity::yul { -class YulString; -using YulName = YulString; +using YulName = std::size_t; enum class LiteralKind; class LiteralValue; diff --git a/libyul/ASTLabelRegistry.h b/libyul/ASTLabelRegistry.h index cb7c405af9fa..72fa6f58ce04 100644 --- a/libyul/ASTLabelRegistry.h +++ b/libyul/ASTLabelRegistry.h @@ -28,6 +28,8 @@ namespace solidity::yul { +using YulName = std::size_t; + /// Instances of the `ASTLabelRegistry` are immutable containers describing a labelling of nodes inside the AST. /// Each element of the AST that possesses a label has a `ASTLabelRegistry::LabelID`, with which the label can /// be queried in O(1). @@ -43,7 +45,7 @@ class ASTLabelRegistry { public: /// unsafe to use from a different registry instance, it is up to the user to safeguard against this - using LabelID = size_t; + using LabelID = YulName; ASTLabelRegistry(); ASTLabelRegistry(std::vector _labels, std::vector _idToLabelMapping); diff --git a/libyul/YulName.h b/libyul/YulName.h index 34fd6a5a26b0..afd63c12f664 100644 --- a/libyul/YulName.h +++ b/libyul/YulName.h @@ -18,9 +18,9 @@ #pragma once -#include +#include namespace solidity::yul { -using YulName = YulString; +using YulName = ASTLabelRegistry::LabelID; } From 2e027ad5faf3b71f81394e8221a86bc9e569193f Mon Sep 17 00:00:00 2001 From: clonker <1685266+clonker@users.noreply.github.com> Date: Fri, 7 Feb 2025 12:00:36 +0100 Subject: [PATCH 02/17] Yul: LabelIDDispenser consumes ids from blocks --- libyul/optimiser/LabelIDDispenser.cpp | 9 ++++++--- libyul/optimiser/LabelIDDispenser.h | 3 ++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/libyul/optimiser/LabelIDDispenser.cpp b/libyul/optimiser/LabelIDDispenser.cpp index 6d4e476cb67f..ff3bb019bacd 100644 --- a/libyul/optimiser/LabelIDDispenser.cpp +++ b/libyul/optimiser/LabelIDDispenser.cpp @@ -18,6 +18,7 @@ #include +#include #include #include @@ -81,10 +82,12 @@ bool LabelIDDispenser::ghost(LabelID const _id) const return m_labels.ghost(_id); } -ASTLabelRegistry LabelIDDispenser::generateNewLabels(Dialect const& _dialect) const +ASTLabelRegistry LabelIDDispenser::generateNewLabels(Block const& _astRoot, Dialect const& _dialect) const { - auto const usedIDs = - ranges::views::iota(static_cast(1), m_idToLabelMapping.size() + m_labels.maxID() + 1) | + std::set usedIDs = NameCollector(_astRoot).names(); + // add ghosts to usedIDs as they're not referenced in the regular ast + usedIDs += ranges::views::iota(static_cast(1), m_idToLabelMapping.size() + m_labels.maxID() + 1) | + ranges::views::filter([this](auto const& labelID) { return ghost(labelID); }) | ranges::to; return generateNewLabels(usedIDs, _dialect); } diff --git a/libyul/optimiser/LabelIDDispenser.h b/libyul/optimiser/LabelIDDispenser.h index 0168fadcfe28..61b4938a7575 100644 --- a/libyul/optimiser/LabelIDDispenser.h +++ b/libyul/optimiser/LabelIDDispenser.h @@ -26,6 +26,7 @@ namespace solidity::yul { +struct Block; class Dialect; /// Can spawn new `LabelID`s which depend on `LabelID`s from a parent label registry. Once generation is completed, @@ -56,7 +57,7 @@ class LabelIDDispenser /// Labels are guaranteed to be valid and not reserved if and only if they were valid and not reserved in the /// original registry. No new invalid and/or reserved labels are introduced. ASTLabelRegistry generateNewLabels(std::set const& _usedIDs, Dialect const& _dialect) const; - ASTLabelRegistry generateNewLabels(Dialect const& _dialect) const; + ASTLabelRegistry generateNewLabels(Block const& _astRoot, Dialect const& _dialect) const; private: /// For newly added label IDs, this yields the parent ID which is contained in the provided registry. /// For label IDs which already are not new, this function is the identity. From 729d2e2e38186a970829a734c1787f43b95b692b Mon Sep 17 00:00:00 2001 From: clonker <1685266+clonker@users.noreply.github.com> Date: Wed, 5 Feb 2025 12:12:50 +0100 Subject: [PATCH 03/17] Yul: AST contains ASTLabelRegistry --- libsolidity/codegen/ContractCompiler.cpp | 2 +- libyul/AST.cpp | 9 +++++++ libyul/AST.h | 17 +++++++++++- libyul/AsmJsonImporter.cpp | 2 +- libyul/AsmParser.cpp | 2 +- libyul/ObjectOptimizer.cpp | 8 +++++- libyul/optimiser/StackCompressor.cpp | 2 +- libyul/optimiser/Suite.cpp | 34 +++++++++++------------- test/libyul/KnowledgeBaseTest.cpp | 2 +- test/libyul/YulOptimizerTestCommon.cpp | 6 ++--- test/tools/yulopti.cpp | 2 +- tools/yulPhaser/Program.cpp | 8 +++--- 12 files changed, 61 insertions(+), 33 deletions(-) diff --git a/libsolidity/codegen/ContractCompiler.cpp b/libsolidity/codegen/ContractCompiler.cpp index 3a4dca0439ca..6ad824a47098 100644 --- a/libsolidity/codegen/ContractCompiler.cpp +++ b/libsolidity/codegen/ContractCompiler.cpp @@ -944,7 +944,7 @@ bool ContractCompiler::visit(InlineAssembly const& _inlineAssembly) solAssert(dialect, ""); // Create a modifiable copy of the code and analysis - object.setCode(std::make_shared(_inlineAssembly.dialect(), yul::ASTCopier().translate(code->root()))); + object.setCode(std::make_shared(_inlineAssembly.dialect(), yul::ASTLabelRegistry{}, yul::ASTCopier().translate(code->root()))); object.analysisInfo = std::make_shared(yul::AsmAnalyzer::analyzeStrictAssertCorrect(object)); m_context.optimizeYul(object, m_optimiserSettings); diff --git a/libyul/AST.cpp b/libyul/AST.cpp index 8c9f376415f9..a6054f7430e7 100644 --- a/libyul/AST.cpp +++ b/libyul/AST.cpp @@ -17,6 +17,9 @@ along with solidity. If not, see . // SPDX-License-Identifier: GPL-3.0 #include + +#include + #include namespace solidity::yul @@ -77,4 +80,10 @@ bool LiteralValue::operator<(solidity::yul::LiteralValue const& _rhs) const return value() < _rhs.value(); } +AST::AST(Dialect const& _dialect, LabelIDDispenser const& _dispenser, Block _root): + m_dialect(_dialect), + m_labels(_dispenser.generateNewLabels(_root, _dialect)), + m_root(std::move(_root)) +{} + } diff --git a/libyul/AST.h b/libyul/AST.h index d5988ee05386..2288713c205f 100644 --- a/libyul/AST.h +++ b/libyul/AST.h @@ -24,6 +24,7 @@ #pragma once #include +#include #include #include @@ -38,6 +39,7 @@ namespace solidity::yul { class Dialect; +class LabelIDDispenser; struct NameWithDebugData { langutil::DebugData::ConstPtr debugData; YulName name; }; using NameWithDebugDataList = std::vector; @@ -109,12 +111,25 @@ struct Leave { langutil::DebugData::ConstPtr debugData; }; class AST { public: - AST(Dialect const& _dialect, Block _root): m_dialect(_dialect), m_root(std::move(_root)) {} + AST(Dialect const& _dialect, ASTLabelRegistry _labels, Block _root): + m_dialect(_dialect), + m_labels(std::move(_labels)), + m_root(std::move(_root)) + {} + /// Creates a new AST instance by generating labels based on the state of the dispenser plus the entered block. + /// One could also call `_dispenser.generateNewLabels` beforehand, but then special care has to be taken + /// to not inline it into one constructor call. The order of evaluation is not defined. + AST(Dialect const& _dialect, LabelIDDispenser const& _dispenser, Block _root); Dialect const& dialect() const { return m_dialect; } Block const& root() const { return m_root; } + ASTLabelRegistry const& labels() const { return m_labels; } + + std::string_view labelOf(ASTLabelRegistry::LabelID const _id) const { return m_labels[_id]; } + private: Dialect const& m_dialect; + ASTLabelRegistry m_labels; Block m_root; }; diff --git a/libyul/AsmJsonImporter.cpp b/libyul/AsmJsonImporter.cpp index a937be62fb7a..a9b7c280f45e 100644 --- a/libyul/AsmJsonImporter.cpp +++ b/libyul/AsmJsonImporter.cpp @@ -53,7 +53,7 @@ SourceLocation const AsmJsonImporter::createSourceLocation(Json const& _node) AST AsmJsonImporter::createAST(solidity::Json const& _node) { - return {m_dialect, createBlock(_node)}; + return {m_dialect, ASTNodeRegistry{}, createBlock(_node)}; } template diff --git a/libyul/AsmParser.cpp b/libyul/AsmParser.cpp index a6949d7f8bdb..5882b8f2a717 100644 --- a/libyul/AsmParser.cpp +++ b/libyul/AsmParser.cpp @@ -125,7 +125,7 @@ std::unique_ptr Parser::parseInline(std::shared_ptr const& _scanne m_scanner = _scanner; if (m_useSourceLocationFrom == UseSourceLocationFrom::Comments) fetchDebugDataFromComment(); - return std::make_unique(m_dialect, parseBlock()); + return std::make_unique(m_dialect, ASTNodeRegistry{}, parseBlock()); } catch (FatalError const&) { diff --git a/libyul/ObjectOptimizer.cpp b/libyul/ObjectOptimizer.cpp index a09e88791577..58de85fd190b 100644 --- a/libyul/ObjectOptimizer.cpp +++ b/libyul/ObjectOptimizer.cpp @@ -118,7 +118,13 @@ void ObjectOptimizer::overwriteWithOptimizedObject(util::h256 _cacheKey, Object& yulAssert(cachedObject.optimizedAST); yulAssert(cachedObject.dialect); - _object.setCode(std::make_shared(*cachedObject.dialect, ASTCopier{}.translate(*cachedObject.optimizedAST))); + _object.setCode( + std::make_shared( + *cachedObject.dialect, + ASTLabelRegistry{}, + ASTCopier{}.translate(*cachedObject.optimizedAST) + ) + ); yulAssert(_object.code()); yulAssert(_object.dialect()); diff --git a/libyul/optimiser/StackCompressor.cpp b/libyul/optimiser/StackCompressor.cpp index b0be60d63442..595e4b3ee800 100644 --- a/libyul/optimiser/StackCompressor.cpp +++ b/libyul/optimiser/StackCompressor.cpp @@ -280,7 +280,7 @@ std::tuple StackCompressor::run( for (size_t iterations = 0; iterations < _maxIterations; iterations++) { Object object(_object); - object.setCode(std::make_shared(*_object.dialect(), std::get(ASTCopier{}(astRoot)))); + object.setCode(std::make_shared(*_object.dialect(), ASTLabelRegistry{}, std::get(ASTCopier{}(astRoot)))); std::map stackSurplus = CompilabilityChecker(object, _optimizeStackAllocation).stackDeficit; if (stackSurplus.empty()) return std::make_tuple(true, std::move(astRoot)); diff --git a/libyul/optimiser/Suite.cpp b/libyul/optimiser/Suite.cpp index 17698d74e2a0..b53647aeb3cc 100644 --- a/libyul/optimiser/Suite.cpp +++ b/libyul/optimiser/Suite.cpp @@ -139,7 +139,7 @@ void OptimiserSuite::run( if (!usesOptimizedCodeGenerator) { PROFILER_PROBE("StackCompressor", probe); - _object.setCode(std::make_shared(dialect, std::move(astRoot))); + _object.setCode(std::make_shared(dialect, ASTLabelRegistry{}, std::move(astRoot))); astRoot = std::get<1>(StackCompressor::run( _object, _optimizeStackAllocation, @@ -165,28 +165,26 @@ void OptimiserSuite::run( { if (!evmDialect->eofVersion().has_value()) { - { - PROFILER_PROBE("StackCompressor", probe); - _object.setCode(std::make_shared(dialect, std::move(astRoot))); - astRoot = std::get<1>(StackCompressor::run( - _object, - _optimizeStackAllocation, - stackCompressorMaxIterations - )); - } - if (evmDialect->providesObjectAccess()) - { - PROFILER_PROBE("StackLimitEvader", probe); - _object.setCode(std::make_shared(dialect, std::move(astRoot))); - astRoot = StackLimitEvader::run(suite.m_context, _object); - } + PROFILER_PROBE("StackCompressor", probe); + _object.setCode(std::make_shared(dialect, ASTLabelRegistry{}, std::move(astRoot))); + astRoot = std::get<1>(StackCompressor::run( + _object, + _optimizeStackAllocation, + stackCompressorMaxIterations + )); + } + if (evmDialect->providesObjectAccess()) + { + PROFILER_PROBE("StackLimitEvader", probe); + _object.setCode(std::make_shared(dialect, ASTLabelRegistry{}, std::move(astRoot))); + astRoot = StackLimitEvader::run(suite.m_context, _object); } } else if (evmDialect->providesObjectAccess() && _optimizeStackAllocation) { PROFILER_PROBE("StackLimitEvader", probe); yulAssert(!evmDialect->eofVersion().has_value(), ""); - _object.setCode(std::make_shared(dialect, std::move(astRoot))); + _object.setCode(std::make_shared(dialect, ASTLabelRegistry{}, std::move(astRoot))); astRoot = StackLimitEvader::run(suite.m_context, _object); } } @@ -201,7 +199,7 @@ void OptimiserSuite::run( VarNameCleaner::run(suite.m_context, astRoot); } - _object.setCode(std::make_shared(dialect, std::move(astRoot))); + _object.setCode(std::make_shared(dialect, ASTLabelRegistry{}, std::move(astRoot))); _object.analysisInfo = std::make_shared(AsmAnalyzer::analyzeStrictAssertCorrect(_object)); } diff --git a/test/libyul/KnowledgeBaseTest.cpp b/test/libyul/KnowledgeBaseTest.cpp index 6e75442f0621..84e5a988a5d2 100644 --- a/test/libyul/KnowledgeBaseTest.cpp +++ b/test/libyul/KnowledgeBaseTest.cpp @@ -60,7 +60,7 @@ class KnowledgeBaseTest for (auto const& [name, expression]: m_ssaValues.values()) m_values[name].value = expression; - m_object->setCode(std::make_shared(*m_object->dialect(), std::move(astRoot))); + m_object->setCode(std::make_shared(*m_object->dialect(), ASTLabelRegistry{}, std::move(astRoot))); return KnowledgeBase( [this](YulName _var) { return util::valueOrNullptr(m_values, _var); }, *m_object->dialect() diff --git a/test/libyul/YulOptimizerTestCommon.cpp b/test/libyul/YulOptimizerTestCommon.cpp index 19b2176c10f5..478cbb8864f0 100644 --- a/test/libyul/YulOptimizerTestCommon.cpp +++ b/test/libyul/YulOptimizerTestCommon.cpp @@ -413,7 +413,7 @@ YulOptimizerTestCommon::YulOptimizerTestCommon(std::shared_ptr _ob size_t maxIterations = 16; { Object object(*m_optimizedObject); - object.setCode(std::make_shared(*m_object->dialect(), std::get(ASTCopier{}(block)))); + object.setCode(std::make_shared(*m_object->dialect(), ASTLabelRegistry{}, std::get(ASTCopier{}(block)))); block = std::get<1>(StackCompressor::run(object, true, maxIterations)); } BlockFlattener::run(*m_context, block); @@ -435,7 +435,7 @@ YulOptimizerTestCommon::YulOptimizerTestCommon(std::shared_ptr _ob auto block = disambiguate(); updateContext(block); Object object(*m_optimizedObject); - object.setCode(std::make_shared(*m_object->dialect(), std::get(ASTCopier{}(block)))); + object.setCode(std::make_shared(*m_object->dialect(), ASTLabelRegistry{}, std::get(ASTCopier{}(block)))); auto const unreachables = CompilabilityChecker{ object, true @@ -499,7 +499,7 @@ bool YulOptimizerTestCommon::runStep() if (m_namedSteps.count(m_optimizerStep)) { auto block = m_namedSteps[m_optimizerStep](); - m_optimizedObject->setCode(std::make_shared(*m_object->dialect(), std::move(block))); + m_optimizedObject->setCode(std::make_shared(*m_object->dialect(), ASTLabelRegistry{}, std::move(block))); } else return false; diff --git a/test/tools/yulopti.cpp b/test/tools/yulopti.cpp index b164bfb4f3d1..1a3b3cd5acbf 100644 --- a/test/tools/yulopti.cpp +++ b/test/tools/yulopti.cpp @@ -218,7 +218,7 @@ class YulOpti case ';': { Object obj; - obj.setCode(std::make_shared(m_dialect, std::get(ASTCopier{}(*m_astRoot)))); + obj.setCode(std::make_shared(m_dialect, ASTLabelRegistry{}, std::get(ASTCopier{}(*m_astRoot)))); *m_astRoot = std::get<1>(StackCompressor::run(obj, true, 16)); break; } diff --git a/tools/yulPhaser/Program.cpp b/tools/yulPhaser/Program.cpp index 6d182782701e..36675116167b 100644 --- a/tools/yulPhaser/Program.cpp +++ b/tools/yulPhaser/Program.cpp @@ -59,7 +59,7 @@ std::ostream& operator<<(std::ostream& _stream, Program const& _program); } Program::Program(Program const& program): - m_ast(std::make_unique(program.m_dialect, std::get(ASTCopier{}(program.m_ast->root())))), + m_ast(std::make_unique(program.m_dialect, ASTLabelRegistry{}, std::get(ASTCopier{}(program.m_ast->root())))), m_dialect{program.m_dialect}, m_nameDispenser(program.m_nameDispenser) { @@ -150,7 +150,7 @@ std::variant, ErrorList> Program::parseObject(Dialect const // The public API of the class does not provide access to the smart pointer so it won't be hard // to switch to shared_ptr if the copying turns out to be an issue (though it would be better // to refactor ObjectParser and Object to use unique_ptr instead). - auto astCopy = std::make_unique(_dialect, std::get(ASTCopier{}(selectedObject->code()->root()))); + auto astCopy = std::make_unique(_dialect, ASTLabelRegistry{}, std::get(ASTCopier{}(selectedObject->code()->root()))); return std::variant, ErrorList>(std::move(astCopy)); } @@ -179,7 +179,7 @@ std::unique_ptr Program::disambiguateAST( std::set const externallyUsedIdentifiers = {}; Disambiguator disambiguator(_dialect, _analysisInfo, externallyUsedIdentifiers); - return std::make_unique(_dialect, std::get(disambiguator(_ast.root()))); + return std::make_unique(_dialect, ASTLabelRegistry{}, std::get(disambiguator(_ast.root()))); } std::unique_ptr Program::applyOptimisationSteps( @@ -203,7 +203,7 @@ std::unique_ptr Program::applyOptimisationSteps( for (std::string const& step: _optimisationSteps) OptimiserSuite::allSteps().at(step)->run(context, astRoot); - return std::make_unique(_dialect, std::move(astRoot)); + return std::make_unique(_dialect, ASTLabelRegistry{}, std::move(astRoot)); } size_t Program::computeCodeSize(Block const& _ast, CodeWeights const& _weights) From b051a1e3b7763b3ece842fcee9301911462937d7 Mon Sep 17 00:00:00 2001 From: clonker <1685266+clonker@users.noreply.github.com> Date: Wed, 5 Feb 2025 12:25:25 +0100 Subject: [PATCH 04/17] Yul: ASM to JSON conversion and import uses numerical label IDs --- libsolidity/ast/ASTJsonExporter.cpp | 8 ++++---- libyul/AsmJsonConverter.cpp | 12 ++++++------ libyul/AsmJsonConverter.h | 9 +++++++-- libyul/AsmJsonImporter.cpp | 11 +++++++---- libyul/AsmJsonImporter.h | 9 +++++++-- 5 files changed, 31 insertions(+), 18 deletions(-) diff --git a/libsolidity/ast/ASTJsonExporter.cpp b/libsolidity/ast/ASTJsonExporter.cpp index 4eaa558713a7..76f985486d1e 100644 --- a/libsolidity/ast/ASTJsonExporter.cpp +++ b/libsolidity/ast/ASTJsonExporter.cpp @@ -670,10 +670,10 @@ bool ASTJsonExporter::visit(InlineAssembly const& _node) for (auto const& it: _node.annotation().externalReferences) if (it.first) - externalReferences.emplace_back(std::make_pair( - it.first->name.str(), + externalReferences.emplace_back( + _node.operations().labelOf(it.first->name), inlineAssemblyIdentifierToJson(it) - )); + ); Json externalReferencesJson = Json::array(); @@ -684,7 +684,7 @@ bool ASTJsonExporter::visit(InlineAssembly const& _node) auto const& evmDialect = dynamic_cast(_node.dialect()); std::vector> attributes = { - std::make_pair("AST", Json(yul::AsmJsonConverter(evmDialect, sourceIndexFromLocation(_node.location()))(_node.operations().root()))), + std::make_pair("AST", Json(yul::AsmJsonConverter(evmDialect, _node.operations().labels(), sourceIndexFromLocation(_node.location()))(_node.operations().root()))), std::make_pair("externalReferences", std::move(externalReferencesJson)), std::make_pair("evmVersion", evmDialect.evmVersion().name()) }; diff --git a/libyul/AsmJsonConverter.cpp b/libyul/AsmJsonConverter.cpp index fd36dd26022c..32c18d19645d 100644 --- a/libyul/AsmJsonConverter.cpp +++ b/libyul/AsmJsonConverter.cpp @@ -41,9 +41,9 @@ Json AsmJsonConverter::operator()(Block const& _node) const Json AsmJsonConverter::operator()(NameWithDebugData const& _node) const { - yulAssert(!_node.name.empty(), "Invalid variable name."); + yulAssert(!m_labels.empty(_node.name), "Invalid variable name."); Json ret = createAstNode(originLocationOf(_node), nativeLocationOf(_node), "YulTypedName"); - ret["name"] = _node.name.str(); + ret["name"] = m_labels[_node.name]; // even though types are removed from Yul, we keep this field in the Json interface to not introduce // a breaking change // can be removed with the next breaking version @@ -79,9 +79,9 @@ Json AsmJsonConverter::operator()(Literal const& _node) const Json AsmJsonConverter::operator()(Identifier const& _node) const { - yulAssert(!_node.name.empty(), "Invalid identifier"); + yulAssert(!m_labels.empty(_node.name), "Invalid identifier"); Json ret = createAstNode(originLocationOf(_node), nativeLocationOf(_node), "YulIdentifier"); - ret["name"] = _node.name.str(); + ret["name"] = m_labels[_node.name]; return ret; } @@ -129,9 +129,9 @@ Json AsmJsonConverter::operator()(VariableDeclaration const& _node) const Json AsmJsonConverter::operator()(FunctionDefinition const& _node) const { - yulAssert(!_node.name.empty(), "Invalid function name."); + yulAssert(!m_labels.empty(_node.name), "Invalid function name."); Json ret = createAstNode(originLocationOf(_node), nativeLocationOf(_node), "YulFunctionDefinition"); - ret["name"] = _node.name.str(); + ret["name"] = m_labels[_node.name]; for (auto const& var: _node.parameters) ret["parameters"].emplace_back((*this)(var)); for (auto const& var: _node.returnVariables) diff --git a/libyul/AsmJsonConverter.h b/libyul/AsmJsonConverter.h index 6705197f943f..c0d9c2392c60 100644 --- a/libyul/AsmJsonConverter.h +++ b/libyul/AsmJsonConverter.h @@ -24,9 +24,12 @@ #pragma once #include + #include #include + #include + #include #include @@ -34,6 +37,7 @@ namespace solidity::yul { class Dialect; +class ASTLabelRegistry; /** * Converter of the yul AST into JSON format @@ -43,8 +47,8 @@ class AsmJsonConverter: public boost::static_visitor public: /// Create a converter to JSON for any block of inline assembly /// @a _sourceIndex to be used to abbreviate source name in the source locations - AsmJsonConverter(Dialect const& _dialect, std::optional _sourceIndex): - m_dialect(_dialect), m_sourceIndex(_sourceIndex) {} + AsmJsonConverter(Dialect const& _dialect, ASTLabelRegistry const& _labels, std::optional _sourceIndex): + m_dialect(_dialect), m_labels(_labels), m_sourceIndex(_sourceIndex) {} Json operator()(Block const& _node) const; Json operator()(NameWithDebugData const& _node) const; @@ -71,6 +75,7 @@ class AsmJsonConverter: public boost::static_visitor Json vectorOfVariantsToJson(std::vector const& vec) const; Dialect const& m_dialect; + ASTLabelRegistry const& m_labels; std::optional const m_sourceIndex; }; diff --git a/libyul/AsmJsonImporter.cpp b/libyul/AsmJsonImporter.cpp index a9b7c280f45e..74ca3d5dc37c 100644 --- a/libyul/AsmJsonImporter.cpp +++ b/libyul/AsmJsonImporter.cpp @@ -35,6 +35,8 @@ #include #include +#include + #include using namespace solidity::langutil; @@ -53,7 +55,8 @@ SourceLocation const AsmJsonImporter::createSourceLocation(Json const& _node) AST AsmJsonImporter::createAST(solidity::Json const& _node) { - return {m_dialect, ASTNodeRegistry{}, createBlock(_node)}; + auto block = createBlock(_node); + return {m_dialect, m_labelRegistryBuilder.build(), std::move(block)}; } template @@ -79,7 +82,7 @@ Json AsmJsonImporter::member(Json const& _node, std::string const& _name) NameWithDebugData AsmJsonImporter::createNameWithDebugData(Json const& _node) { auto nameWithDebugData = createAsmNode(_node); - nameWithDebugData.name = YulName{member(_node, "name").get()}; + nameWithDebugData.name = m_labelRegistryBuilder.define(member(_node, "name").get()); return nameWithDebugData; } @@ -234,7 +237,7 @@ Leave AsmJsonImporter::createLeave(Json const& _node) Identifier AsmJsonImporter::createIdentifier(Json const& _node) { auto identifier = createAsmNode(_node); - identifier.name = YulName(member(_node, "name").get()); + identifier.name = m_labelRegistryBuilder.define(member(_node, "name").get()); return identifier; } @@ -293,7 +296,7 @@ VariableDeclaration AsmJsonImporter::createVariableDeclaration(Json const& _node FunctionDefinition AsmJsonImporter::createFunctionDefinition(Json const& _node) { auto funcDef = createAsmNode(_node); - funcDef.name = YulName{member(_node, "name").get()}; + funcDef.name = m_labelRegistryBuilder.define(member(_node, "name").get()); if (_node.contains("parameters")) for (auto const& var: member(_node, "parameters")) diff --git a/libyul/AsmJsonImporter.h b/libyul/AsmJsonImporter.h index 830e44b3acb1..0c18dff8182b 100644 --- a/libyul/AsmJsonImporter.h +++ b/libyul/AsmJsonImporter.h @@ -23,11 +23,15 @@ #pragma once +#include +#include + #include + #include -#include -#include +#include +#include namespace solidity::yul { @@ -78,6 +82,7 @@ class AsmJsonImporter Dialect const& m_dialect; std::vector> const& m_sourceNames; + ASTLabelRegistryBuilder m_labelRegistryBuilder; }; } From 201cc2f3d21f5e5ca51196a50bd1ea9f72872031 Mon Sep 17 00:00:00 2001 From: clonker <1685266+clonker@users.noreply.github.com> Date: Wed, 5 Feb 2025 12:34:25 +0100 Subject: [PATCH 05/17] AsmParser: Use ASTLabelRegistryBuilder for numerical label IDs --- libyul/AsmParser.cpp | 125 ++++++++++++++++++++++++++----------------- libyul/AsmParser.h | 28 ++++++---- 2 files changed, 92 insertions(+), 61 deletions(-) diff --git a/libyul/AsmParser.cpp b/libyul/AsmParser.cpp index 5882b8f2a717..deba14d08ace 100644 --- a/libyul/AsmParser.cpp +++ b/libyul/AsmParser.cpp @@ -125,7 +125,9 @@ std::unique_ptr Parser::parseInline(std::shared_ptr const& _scanne m_scanner = _scanner; if (m_useSourceLocationFrom == UseSourceLocationFrom::Comments) fetchDebugDataFromComment(); - return std::make_unique(m_dialect, ASTNodeRegistry{}, parseBlock()); + ASTLabelRegistryBuilder labelRegistryBuilder; + auto block = parseBlock(labelRegistryBuilder); + return std::make_unique(m_dialect, labelRegistryBuilder.build(), std::move(block)); } catch (FatalError const&) { @@ -329,35 +331,35 @@ std::optional>> Parser::parseASTI return std::nullopt; } -Block Parser::parseBlock() +Block Parser::parseBlock(ASTLabelRegistryBuilder& _labelRegistryBuilder) { RecursionGuard recursionGuard(*this); Block block = createWithDebugData(); expectToken(Token::LBrace); while (currentToken() != Token::RBrace) - block.statements.emplace_back(parseStatement()); + block.statements.emplace_back(parseStatement(_labelRegistryBuilder)); updateLocationEndFrom(block.debugData, currentLocation()); advance(); return block; } -Statement Parser::parseStatement() +Statement Parser::parseStatement(ASTLabelRegistryBuilder& _labelRegistryBuilder) { RecursionGuard recursionGuard(*this); switch (currentToken()) { case Token::Let: - return parseVariableDeclaration(); + return parseVariableDeclaration(_labelRegistryBuilder); case Token::Function: - return parseFunctionDefinition(); + return parseFunctionDefinition(_labelRegistryBuilder); case Token::LBrace: - return parseBlock(); + return parseBlock(_labelRegistryBuilder); case Token::If: { If _if = createWithDebugData(); advance(); - _if.condition = std::make_unique(parseExpression()); - _if.body = parseBlock(); + _if.condition = std::make_unique(parseExpression(_labelRegistryBuilder)); + _if.body = parseBlock(_labelRegistryBuilder); updateLocationEndFrom(_if.debugData, nativeLocationOf(_if.body)); return Statement{std::move(_if)}; } @@ -365,11 +367,11 @@ Statement Parser::parseStatement() { Switch _switch = createWithDebugData(); advance(); - _switch.expression = std::make_unique(parseExpression()); + _switch.expression = std::make_unique(parseExpression(_labelRegistryBuilder)); while (currentToken() == Token::Case) - _switch.cases.emplace_back(parseCase()); + _switch.cases.emplace_back(parseCase(_labelRegistryBuilder)); if (currentToken() == Token::Default) - _switch.cases.emplace_back(parseCase()); + _switch.cases.emplace_back(parseCase(_labelRegistryBuilder)); if (currentToken() == Token::Default) fatalParserError(6931_error, "Only one default case allowed."); else if (currentToken() == Token::Case) @@ -380,7 +382,7 @@ Statement Parser::parseStatement() return Statement{std::move(_switch)}; } case Token::For: - return parseForLoop(); + return parseForLoop(_labelRegistryBuilder); case Token::Break: { Statement stmt{createWithDebugData()}; @@ -410,13 +412,13 @@ Statement Parser::parseStatement() // Options left: // Expression/FunctionCall // Assignment - std::variant elementary(parseLiteralOrIdentifier()); + std::variant elementary(parseLiteralOrIdentifier(_labelRegistryBuilder)); switch (currentToken()) { case Token::LParen: { - Expression expr = parseCall(std::move(elementary)); + Expression expr = parseCall(_labelRegistryBuilder, std::move(elementary)); return ExpressionStatement{debugDataOf(expr), std::move(expr)}; } case Token::Comma: @@ -460,7 +462,7 @@ Statement Parser::parseStatement() else { expectToken(Token::Comma); - elementary = parseLiteralOrIdentifier(); + elementary = parseLiteralOrIdentifier(_labelRegistryBuilder); } } }, elementary); @@ -469,7 +471,7 @@ Statement Parser::parseStatement() expectToken(Token::AssemblyAssign); - assignment.value = std::make_unique(parseExpression()); + assignment.value = std::make_unique(parseExpression(_labelRegistryBuilder)); updateLocationEndFrom(assignment.debugData, nativeLocationOf(*assignment.value)); return Statement{std::move(assignment)}; @@ -483,7 +485,7 @@ Statement Parser::parseStatement() return {}; } -Case Parser::parseCase() +Case Parser::parseCase(ASTLabelRegistryBuilder& _labelRegistryBuilder) { RecursionGuard recursionGuard(*this); Case _case = createWithDebugData(); @@ -492,19 +494,19 @@ Case Parser::parseCase() else if (currentToken() == Token::Case) { advance(); - std::variant literal = parseLiteralOrIdentifier(); + std::variant literal = parseLiteralOrIdentifier(_labelRegistryBuilder); if (!std::holds_alternative(literal)) fatalParserError(4805_error, "Literal expected."); _case.value = std::make_unique(std::get(std::move(literal))); } else yulAssert(false, "Case or default case expected."); - _case.body = parseBlock(); + _case.body = parseBlock(_labelRegistryBuilder); updateLocationEndFrom(_case.debugData, nativeLocationOf(_case.body)); return _case; } -ForLoop Parser::parseForLoop() +ForLoop Parser::parseForLoop(ASTLabelRegistryBuilder& _labelRegistryBuilder) { RecursionGuard recursionGuard(*this); @@ -513,13 +515,13 @@ ForLoop Parser::parseForLoop() ForLoop forLoop = createWithDebugData(); expectToken(Token::For); m_currentForLoopComponent = ForLoopComponent::ForLoopPre; - forLoop.pre = parseBlock(); + forLoop.pre = parseBlock(_labelRegistryBuilder); m_currentForLoopComponent = ForLoopComponent::None; - forLoop.condition = std::make_unique(parseExpression()); + forLoop.condition = std::make_unique(parseExpression(_labelRegistryBuilder)); m_currentForLoopComponent = ForLoopComponent::ForLoopPost; - forLoop.post = parseBlock(); + forLoop.post = parseBlock(_labelRegistryBuilder); m_currentForLoopComponent = ForLoopComponent::ForLoopBody; - forLoop.body = parseBlock(); + forLoop.body = parseBlock(_labelRegistryBuilder); updateLocationEndFrom(forLoop.debugData, nativeLocationOf(forLoop.body)); m_currentForLoopComponent = outerForLoopComponent; @@ -527,22 +529,25 @@ ForLoop Parser::parseForLoop() return forLoop; } -Expression Parser::parseExpression(bool _unlimitedLiteralArgument) +Expression Parser::parseExpression(ASTLabelRegistryBuilder& _labelRegistryBuilder, bool const _unlimitedLiteralArgument) { RecursionGuard recursionGuard(*this); - std::variant operation = parseLiteralOrIdentifier(_unlimitedLiteralArgument); + std::variant operation = parseLiteralOrIdentifier( + _labelRegistryBuilder, + _unlimitedLiteralArgument + ); return visit(GenericVisitor{ [&](Identifier& _identifier) -> Expression { if (currentToken() == Token::LParen) - return parseCall(std::move(operation)); + return parseCall(_labelRegistryBuilder, std::move(operation)); return std::move(_identifier); }, [&](BuiltinName& _builtin) -> Expression { if (currentToken() == Token::LParen) - return parseCall(std::move(operation)); + return parseCall(_labelRegistryBuilder, std::move(operation)); fatalParserError( 7104_error, nativeLocationOf(_builtin), @@ -557,7 +562,10 @@ Expression Parser::parseExpression(bool _unlimitedLiteralArgument) }, operation); } -std::variant Parser::parseLiteralOrIdentifier(bool _unlimitedLiteralArgument) +std::variant Parser::parseLiteralOrIdentifier( + ASTLabelRegistryBuilder& _labelRegistryBuilder, + bool const _unlimitedLiteralArgument +) { RecursionGuard recursionGuard(*this); switch (currentToken()) @@ -568,7 +576,10 @@ std::variant Parser::parseLiteralOrIdentifier( if (std::optional const builtinHandle = m_dialect.findBuiltin(currentLiteral())) literalOrIdentifier = BuiltinName{createDebugData(), *builtinHandle}; else - literalOrIdentifier = Identifier{createDebugData(), YulName{currentLiteral()}}; + { + auto const labelID = _labelRegistryBuilder.define(currentLiteral()); + literalOrIdentifier = Identifier{createDebugData(), YulName{labelID}}; + } advance(); return literalOrIdentifier; } @@ -610,7 +621,7 @@ std::variant Parser::parseLiteralOrIdentifier( expectToken(Token::Colon); updateLocationEndFrom(literal.debugData, currentLocation()); auto const typedLiteralLocation = SourceLocation::smallestCovering(literalLocation, currentLocation()); - std::ignore = expectAsmIdentifier(); + std::ignore = expectAsmIdentifier(_labelRegistryBuilder); raiseUnsupportedTypesError(typedLiteralLocation); } @@ -625,14 +636,14 @@ std::variant Parser::parseLiteralOrIdentifier( return {}; } -VariableDeclaration Parser::parseVariableDeclaration() +VariableDeclaration Parser::parseVariableDeclaration(ASTLabelRegistryBuilder& _labelRegistryBuilder) { RecursionGuard recursionGuard(*this); VariableDeclaration varDecl = createWithDebugData(); expectToken(Token::Let); while (true) { - varDecl.variables.emplace_back(parseNameWithDebugData()); + varDecl.variables.emplace_back(parseNameWithDebugData(_labelRegistryBuilder)); if (currentToken() == Token::Comma) expectToken(Token::Comma); else @@ -641,7 +652,7 @@ VariableDeclaration Parser::parseVariableDeclaration() if (currentToken() == Token::AssemblyAssign) { expectToken(Token::AssemblyAssign); - varDecl.value = std::make_unique(parseExpression()); + varDecl.value = std::make_unique(parseExpression(_labelRegistryBuilder)); updateLocationEndFrom(varDecl.debugData, nativeLocationOf(*varDecl.value)); } else @@ -650,7 +661,7 @@ VariableDeclaration Parser::parseVariableDeclaration() return varDecl; } -FunctionDefinition Parser::parseFunctionDefinition() +FunctionDefinition Parser::parseFunctionDefinition(ASTLabelRegistryBuilder& _labelRegistryBuilder) { RecursionGuard recursionGuard(*this); @@ -666,11 +677,11 @@ FunctionDefinition Parser::parseFunctionDefinition() FunctionDefinition funDef = createWithDebugData(); expectToken(Token::Function); - funDef.name = expectAsmIdentifier(); + funDef.name = expectAsmIdentifier(_labelRegistryBuilder); expectToken(Token::LParen); while (currentToken() != Token::RParen) { - funDef.parameters.emplace_back(parseNameWithDebugData()); + funDef.parameters.emplace_back(parseNameWithDebugData(_labelRegistryBuilder)); if (currentToken() == Token::RParen) break; expectToken(Token::Comma); @@ -681,7 +692,7 @@ FunctionDefinition Parser::parseFunctionDefinition() expectToken(Token::RightArrow); while (true) { - funDef.returnVariables.emplace_back(parseNameWithDebugData()); + funDef.returnVariables.emplace_back(parseNameWithDebugData(_labelRegistryBuilder)); if (currentToken() == Token::LBrace) break; expectToken(Token::Comma); @@ -689,7 +700,7 @@ FunctionDefinition Parser::parseFunctionDefinition() } bool preInsideFunction = m_insideFunction; m_insideFunction = true; - funDef.body = parseBlock(); + funDef.body = parseBlock(_labelRegistryBuilder); m_insideFunction = preInsideFunction; updateLocationEndFrom(funDef.debugData, nativeLocationOf(funDef.body)); @@ -697,7 +708,10 @@ FunctionDefinition Parser::parseFunctionDefinition() return funDef; } -FunctionCall Parser::parseCall(std::variant&& _initialOp) +FunctionCall Parser::parseCall( + ASTLabelRegistryBuilder& _labelRegistryBuilder, + std::variant&& _initialOp +) { RecursionGuard recursionGuard(*this); @@ -726,11 +740,21 @@ FunctionCall Parser::parseCall(std::variant&& expectToken(Token::LParen); if (currentToken() != Token::RParen) { - functionCall.arguments.emplace_back(parseExpression(isUnlimitedLiteralArgument(argumentIndex++))); + functionCall.arguments.emplace_back( + parseExpression( + _labelRegistryBuilder, + isUnlimitedLiteralArgument(argumentIndex++) + ) + ); while (currentToken() != Token::RParen) { expectToken(Token::Comma); - functionCall.arguments.emplace_back(parseExpression(isUnlimitedLiteralArgument(argumentIndex++))); + functionCall.arguments.emplace_back( + parseExpression( + _labelRegistryBuilder, + isUnlimitedLiteralArgument(argumentIndex++) + ) + ); } } updateLocationEndFrom(functionCall.debugData, currentLocation()); @@ -738,35 +762,36 @@ FunctionCall Parser::parseCall(std::variant&& return functionCall; } -NameWithDebugData Parser::parseNameWithDebugData() +NameWithDebugData Parser::parseNameWithDebugData(ASTLabelRegistryBuilder& _labelRegistryBuilder) { RecursionGuard recursionGuard(*this); NameWithDebugData typedName = createWithDebugData(); auto const nameLocation = currentLocation(); - typedName.name = expectAsmIdentifier(); + typedName.name = expectAsmIdentifier(_labelRegistryBuilder); if (currentToken() == Token::Colon) { expectToken(Token::Colon); updateLocationEndFrom(typedName.debugData, currentLocation()); auto const typedNameLocation = SourceLocation::smallestCovering(nameLocation, currentLocation()); - std::ignore = expectAsmIdentifier(); + std::ignore = expectAsmIdentifier(_labelRegistryBuilder); raiseUnsupportedTypesError(typedNameLocation); } return typedName; } -YulName Parser::expectAsmIdentifier() +YulName Parser::expectAsmIdentifier(ASTLabelRegistryBuilder& _labelRegistryBuilder) { - YulName name{currentLiteral()}; - if (currentToken() == Token::Identifier && m_dialect.findBuiltin(name.str())) + std::string_view const identifier = currentLiteral(); + if (currentToken() == Token::Identifier && m_dialect.findBuiltin(identifier)) // Non-fatal. We'll continue and wrongly parse it as an identifier. May lead to some spurious // errors after this point, but likely also much more useful ones. m_errorReporter.parserError( 5568_error, currentLocation(), - "Cannot use builtin function name \"" + name.str() + "\" as identifier name." + fmt::format("Cannot use builtin function name \"{}\" as identifier name.", identifier) ); + YulName const name = _labelRegistryBuilder.define(identifier); // NOTE: We keep the expectation here to ensure the correct source location for the error above. expectToken(Token::Identifier); return name; diff --git a/libyul/AsmParser.h b/libyul/AsmParser.h index 75c1cba873f9..ad057d8f7c05 100644 --- a/libyul/AsmParser.h +++ b/libyul/AsmParser.h @@ -133,20 +133,26 @@ class Parser: public langutil::ParserBase return r; } - Block parseBlock(); - Statement parseStatement(); - Case parseCase(); - ForLoop parseForLoop(); + Block parseBlock(ASTLabelRegistryBuilder& _labelRegistryBuilder); + Statement parseStatement(ASTLabelRegistryBuilder& _labelRegistryBuilder); + Case parseCase(ASTLabelRegistryBuilder& _labelRegistryBuilder); + ForLoop parseForLoop(ASTLabelRegistryBuilder& _labelRegistryBuilder); /// Parses a functional expression that has to push exactly one stack element - Expression parseExpression(bool _unlimitedLiteralArgument = false); + Expression parseExpression(ASTLabelRegistryBuilder& _labelRegistryBuilder, bool _unlimitedLiteralArgument = false); /// Parses an elementary operation, i.e. a literal, identifier, instruction or /// builtin function call (only the name). - std::variant parseLiteralOrIdentifier(bool _unlimitedLiteralArgument = false); - VariableDeclaration parseVariableDeclaration(); - FunctionDefinition parseFunctionDefinition(); - FunctionCall parseCall(std::variant&& _index); - NameWithDebugData parseNameWithDebugData(); - YulName expectAsmIdentifier(); + std::variant parseLiteralOrIdentifier( + ASTLabelRegistryBuilder& _labelRegistryBuilder, + bool _unlimitedLiteralArgument = false + ); + VariableDeclaration parseVariableDeclaration(ASTLabelRegistryBuilder& _labelRegistryBuilder); + FunctionDefinition parseFunctionDefinition(ASTLabelRegistryBuilder& _labelRegistryBuilder); + FunctionCall parseCall( + ASTLabelRegistryBuilder& _labelRegistryBuilder, + std::variant&& _index + ); + NameWithDebugData parseNameWithDebugData(ASTLabelRegistryBuilder& _labelRegistryBuilder); + YulName expectAsmIdentifier(ASTLabelRegistryBuilder& _labelRegistryBuilder); void raiseUnsupportedTypesError(langutil::SourceLocation const& _location) const; /// Reports an error if we are currently not inside the body part of a for loop. From d7d6d204f8c3f9bfd053487b0d0c81fbc7b6ceba Mon Sep 17 00:00:00 2001 From: clonker <1685266+clonker@users.noreply.github.com> Date: Thu, 13 Mar 2025 14:13:32 +0100 Subject: [PATCH 06/17] Yul: Integrate numerical label IDs --- libsolidity/interface/CompilerStack.cpp | 2 +- libyul/AsmAnalysis.cpp | 40 ++++++------ libyul/AsmAnalysis.h | 4 ++ libyul/AsmPrinter.cpp | 14 ++-- libyul/AsmPrinter.h | 3 + libyul/CompilabilityChecker.cpp | 4 +- libyul/Exceptions.h | 4 +- libyul/Object.cpp | 2 +- libyul/ObjectOptimizer.cpp | 10 +-- libyul/ObjectOptimizer.h | 3 +- libyul/ScopeFiller.cpp | 8 +-- libyul/ScopeFiller.h | 5 +- libyul/Utilities.cpp | 6 +- libyul/Utilities.h | 3 +- libyul/YulControlFlowGraphExporter.cpp | 9 ++- libyul/YulControlFlowGraphExporter.h | 3 +- libyul/YulStack.cpp | 3 +- libyul/backends/evm/AsmCodeGen.cpp | 4 +- libyul/backends/evm/AsmCodeGen.h | 2 +- libyul/backends/evm/ControlFlow.cpp | 4 +- libyul/backends/evm/ControlFlow.h | 7 +- libyul/backends/evm/ControlFlowGraph.h | 17 +++++ .../backends/evm/ControlFlowGraphBuilder.cpp | 13 ++-- libyul/backends/evm/ControlFlowGraphBuilder.h | 4 +- libyul/backends/evm/EVMCodeTransform.cpp | 31 +++++---- libyul/backends/evm/EVMCodeTransform.h | 7 +- libyul/backends/evm/EVMDialect.cpp | 24 +++---- libyul/backends/evm/EVMDialect.h | 1 + libyul/backends/evm/EVMObjectCompiler.cpp | 3 +- .../evm/OptimizedEVMCodeTransform.cpp | 21 +++--- .../backends/evm/OptimizedEVMCodeTransform.h | 1 + libyul/backends/evm/SSAControlFlowGraph.cpp | 30 +++++---- libyul/backends/evm/SSAControlFlowGraph.h | 4 ++ libyul/backends/evm/StackHelpers.h | 12 ++-- libyul/backends/evm/StackLayoutGenerator.cpp | 2 +- libyul/optimiser/BlockHasher.cpp | 4 +- libyul/optimiser/CallGraphGenerator.h | 2 +- libyul/optimiser/CircularReferencesPruner.cpp | 2 +- libyul/optimiser/DataFlowAnalyzer.h | 1 + libyul/optimiser/Disambiguator.cpp | 2 +- libyul/optimiser/Disambiguator.h | 11 ++-- libyul/optimiser/ExpressionInliner.cpp | 14 ++-- libyul/optimiser/ExpressionSplitter.cpp | 6 +- libyul/optimiser/ExpressionSplitter.h | 6 +- libyul/optimiser/FullInliner.cpp | 10 +-- libyul/optimiser/FullInliner.h | 15 ++--- libyul/optimiser/FunctionSpecializer.cpp | 8 +-- libyul/optimiser/FunctionSpecializer.h | 5 +- libyul/optimiser/KnowledgeBase.cpp | 2 +- libyul/optimiser/KnowledgeBase.h | 4 +- libyul/optimiser/NameDisplacer.cpp | 2 +- libyul/optimiser/NameDisplacer.h | 11 ++-- libyul/optimiser/OptimiserStep.h | 6 +- libyul/optimiser/SSATransform.cpp | 20 +++--- libyul/optimiser/StackCompressor.cpp | 9 ++- libyul/optimiser/StackLimitEvader.cpp | 6 +- libyul/optimiser/StackToMemoryMover.cpp | 8 +-- libyul/optimiser/StackToMemoryMover.h | 2 +- libyul/optimiser/Suite.cpp | 65 ++++++++++--------- libyul/optimiser/Suite.h | 3 +- libyul/optimiser/SyntacticalEquality.h | 1 + libyul/optimiser/UnusedFunctionsCommon.cpp | 5 +- libyul/optimiser/UnusedFunctionsCommon.h | 3 +- 63 files changed, 308 insertions(+), 235 deletions(-) diff --git a/libsolidity/interface/CompilerStack.cpp b/libsolidity/interface/CompilerStack.cpp index 1b0a299f7291..98aaf43b0681 100644 --- a/libsolidity/interface/CompilerStack.cpp +++ b/libsolidity/interface/CompilerStack.cpp @@ -911,7 +911,7 @@ Json CompilerStack::generatedSources(std::string const& _contractName, bool _run yul::EVMDialect const& dialect = yul::EVMDialect::strictAssemblyForEVM(m_evmVersion, m_eofVersion); std::shared_ptr parserResult = yul::Parser{errorReporter, dialect}.parse(charStream); solAssert(parserResult); - sources[0]["ast"] = yul::AsmJsonConverter{dialect, sourceIndex}(parserResult->root()); + sources[0]["ast"] = yul::AsmJsonConverter{dialect, parserResult->labels(), sourceIndex}(parserResult->root()); sources[0]["name"] = sourceName; sources[0]["id"] = sourceIndex; sources[0]["language"] = "Yul"; diff --git a/libyul/AsmAnalysis.cpp b/libyul/AsmAnalysis.cpp index b36eb48b415e..586d17555f79 100644 --- a/libyul/AsmAnalysis.cpp +++ b/libyul/AsmAnalysis.cpp @@ -70,7 +70,7 @@ bool AsmAnalyzer::analyze(Block const& _block) { // FIXME: Pass location of the object name. Now it's a location of first code section in yul validateObjectStructure(nativeLocationOf(_block)); - if (!(ScopeFiller(m_info, m_errorReporter))(_block)) + if (!(ScopeFiller(m_info, m_errorReporter, m_labels))(_block)) return false; (*this)(_block); @@ -103,12 +103,13 @@ AsmAnalysisInfo AsmAnalyzer::analyzeStrictAssertCorrect( Object::Structure _objectStructure ) { - return analyzeStrictAssertCorrect(_dialect, _ast.root(), std::move(_objectStructure)); + return analyzeStrictAssertCorrect(_dialect, _ast.root(), _ast.labels(), std::move(_objectStructure)); } AsmAnalysisInfo AsmAnalyzer::analyzeStrictAssertCorrect( Dialect const& _dialect, Block const& _astRoot, + ASTLabelRegistry const& _labels, Object::Structure _objectStructure ) { @@ -119,6 +120,7 @@ AsmAnalysisInfo AsmAnalyzer::analyzeStrictAssertCorrect( analysisInfo, errors, _dialect, + _labels, {}, std::move(_objectStructure) ).analyze(_astRoot); @@ -146,7 +148,7 @@ AsmAnalysisInfo AsmAnalyzer::analyzeStrictAssertCorrect( yulAssert(errors.hasErrors(), "Yul analysis failed but did not report any errors."); yulAssert(false, fmt::format( "{}\n\nExpected valid Yul, but errors were reported during analysis:\n{}", - AsmPrinter{_dialect}(_astRoot), + AsmPrinter{_dialect, _labels}(_astRoot), formatErrors(errorList) )); } @@ -179,7 +181,7 @@ size_t AsmAnalyzer::operator()(Literal const& _literal) size_t AsmAnalyzer::operator()(Identifier const& _identifier) { - yulAssert(!_identifier.name.empty()); + yulAssert(!m_labels.empty(_identifier.name)); auto watcher = m_errorReporter.errorWatcher(); if (m_currentScope->lookup(_identifier.name, GenericVisitor{ @@ -189,7 +191,7 @@ size_t AsmAnalyzer::operator()(Identifier const& _identifier) m_errorReporter.declarationError( 4990_error, nativeLocationOf(_identifier), - fmt::format("Variable {} used before it was declared.", _identifier.name.str()) + fmt::format("Variable {} used before it was declared.", m_labels[_identifier.name]) ); }, [&](Scope::Function const&) @@ -197,7 +199,7 @@ size_t AsmAnalyzer::operator()(Identifier const& _identifier) m_errorReporter.typeError( 6041_error, nativeLocationOf(_identifier), - fmt::format("Function {} used without being called.", _identifier.name.str()) + fmt::format("Function {} used without being called.", m_labels[_identifier.name]) ); } })) @@ -223,7 +225,7 @@ size_t AsmAnalyzer::operator()(Identifier const& _identifier) m_errorReporter.declarationError( 8198_error, nativeLocationOf(_identifier), - fmt::format("Identifier \"{}\" not found.", _identifier.name.str()) + fmt::format("Identifier \"{}\" not found.", m_labels[_identifier.name]) ); } @@ -262,7 +264,7 @@ void AsmAnalyzer::operator()(Assignment const& _assignment) nativeLocationOf(_assignment), fmt::format( "Variable {} occurs multiple times on the left-hand side of the assignment.", - _variableName.name.str() + m_labels[_variableName.name] ) ); @@ -274,7 +276,7 @@ void AsmAnalyzer::operator()(Assignment const& _assignment) nativeLocationOf(_assignment), fmt::format( "Variable count for assignment to \"{}\" does not match number of values ({} vs. {})", - joinHumanReadable(applyMap(_assignment.variableNames, [](auto const& _identifier){ return _identifier.name.str(); })), + joinHumanReadable(applyMap(_assignment.variableNames, [&](auto const& _identifier){ return m_labels[_identifier.name]; })), numVariables, numRhsValues ) @@ -309,7 +311,7 @@ void AsmAnalyzer::operator()(VariableDeclaration const& _varDecl) nativeLocationOf(_varDecl), fmt::format( "Variable count mismatch for declaration of \"{}\": {} variables and {} values.", - joinHumanReadable(applyMap(_varDecl.variables, [](auto const& _identifier){ return _identifier.name.str(); })), + joinHumanReadable(applyMap(_varDecl.variables, [&](auto const& _identifier){ return m_labels[_identifier.name]; })), numVariables, numValues ) @@ -324,7 +326,7 @@ void AsmAnalyzer::operator()(VariableDeclaration const& _varDecl) void AsmAnalyzer::operator()(FunctionDefinition const& _funDef) { - yulAssert(!_funDef.name.empty()); + yulAssert(!m_labels.empty(_funDef.name)); expectValidIdentifier(_funDef.name, nativeLocationOf(_funDef)); Block const* virtualBlock = m_info.virtualBlocks.at(&_funDef).get(); yulAssert(virtualBlock, ""); @@ -437,7 +439,7 @@ size_t AsmAnalyzer::operator()(FunctionCall const& _funCall) m_errorReporter.declarationError( 4619_error, nativeLocationOf(_identifier), - fmt::format("Function \"{}\" not found.", _identifier.name.str()) + fmt::format("Function \"{}\" not found.", m_labels[_identifier.name]) ); yulAssert(!watcher.ok(), "Expected a reported error."); } @@ -452,7 +454,7 @@ size_t AsmAnalyzer::operator()(FunctionCall const& _funCall) nativeLocationOf(_funCall.functionName), fmt::format( "Function \"{}\" expects {} arguments but got {}.", - resolveFunctionName(_funCall.functionName, m_dialect), + resolveFunctionName(_funCall.functionName, m_labels, m_dialect), *numParameters, _funCall.arguments.size() ) @@ -481,7 +483,7 @@ size_t AsmAnalyzer::operator()(FunctionCall const& _funCall) ); else if (*literalArgumentKind == LiteralKind::String) { - std::string_view functionName = resolveFunctionName(_funCall.functionName, m_dialect); + std::string_view functionName = resolveFunctionName(_funCall.functionName, m_labels, m_dialect); if (functionName == "datasize" || functionName == "dataoffset") { auto const& argumentAsLiteral = std::get(arg); @@ -540,7 +542,7 @@ size_t AsmAnalyzer::operator()(FunctionCall const& _funCall) } else if (*literalArgumentKind == LiteralKind::Number) { - std::string_view functionName = resolveFunctionName(_funCall.functionName, m_dialect); + std::string_view const functionName = resolveFunctionName(_funCall.functionName, m_labels, m_dialect); if (functionName == "auxdataloadn") { auto const& argumentAsLiteral = std::get(arg); @@ -669,7 +671,7 @@ void AsmAnalyzer::expectUnlimitedStringLiteral(Literal const& _literal) void AsmAnalyzer::checkAssignment(Identifier const& _variable) { - yulAssert(!_variable.name.empty()); + yulAssert(!m_labels.empty(_variable.name)); auto watcher = m_errorReporter.errorWatcher(); bool hasVariable = false; bool found = false; @@ -690,7 +692,7 @@ void AsmAnalyzer::checkAssignment(Identifier const& _variable) m_errorReporter.declarationError( 1133_error, nativeLocationOf(_variable), - fmt::format("Variable {} used before it was declared.", _variable.name.str()) + fmt::format("Variable {} used before it was declared.", m_labels[_variable.name]) ); else hasVariable = true; @@ -723,7 +725,7 @@ Scope& AsmAnalyzer::scope(Block const* _block) void AsmAnalyzer::expectValidIdentifier(YulName _identifier, SourceLocation const& _location) { - std::string_view const label = _identifier.str(); + std::string_view const label = m_labels[_identifier]; // NOTE: the leading dot case is handled by the parser not allowing it. if (label.ends_with('.')) m_errorReporter.syntaxError( @@ -920,7 +922,7 @@ bool AsmAnalyzer::validateInstructions(evmasm::Instruction _instr, SourceLocatio bool AsmAnalyzer::validateInstructions(FunctionCall const& _functionCall) { return validateInstructions( - resolveFunctionName(_functionCall.functionName, m_dialect), + resolveFunctionName(_functionCall.functionName, m_labels, m_dialect), nativeLocationOf(_functionCall.functionName) ); } diff --git a/libyul/AsmAnalysis.h b/libyul/AsmAnalysis.h index 51b8cde2ba1f..47419f96da7c 100644 --- a/libyul/AsmAnalysis.h +++ b/libyul/AsmAnalysis.h @@ -61,6 +61,7 @@ class AsmAnalyzer AsmAnalysisInfo& _analysisInfo, langutil::ErrorReporter& _errorReporter, Dialect const& _dialect, + ASTLabelRegistry const& _labels, ExternalIdentifierAccess::Resolver _resolver = ExternalIdentifierAccess::Resolver(), Object::Structure _objectStructure = {} ): @@ -68,6 +69,7 @@ class AsmAnalyzer m_info(_analysisInfo), m_errorReporter(_errorReporter), m_dialect(_dialect), + m_labels(_labels), m_objectStructure(std::move(_objectStructure)) { if (EVMDialect const* evmDialect = dynamic_cast(&m_dialect)) @@ -85,6 +87,7 @@ class AsmAnalyzer static AsmAnalysisInfo analyzeStrictAssertCorrect( Dialect const& _dialect, Block const& _astRoot, + ASTLabelRegistry const& _labels, Object::Structure _objectStructure ); static AsmAnalysisInfo analyzeStrictAssertCorrect( @@ -138,6 +141,7 @@ class AsmAnalyzer langutil::EVMVersion m_evmVersion; std::optional m_eofVersion; Dialect const& m_dialect; + ASTLabelRegistry const& m_labels; /// Names of data objects to be referenced by builtin functions with literal arguments. Object::Structure m_objectStructure; ForLoop const* m_currentForLoop = nullptr; diff --git a/libyul/AsmPrinter.cpp b/libyul/AsmPrinter.cpp index a3f7b4ca2b23..414a6a0c9d64 100644 --- a/libyul/AsmPrinter.cpp +++ b/libyul/AsmPrinter.cpp @@ -49,7 +49,7 @@ std::string AsmPrinter::format( DebugInfoSelection const& _debugInfoSelection, CharStreamProvider const* _soliditySourceProvider) { - return AsmPrinter{_ast.dialect(), _sourceIndexToName, _debugInfoSelection, _soliditySourceProvider}(_ast.root()); + return AsmPrinter{_ast.dialect(), _ast.labels(), _sourceIndexToName, _debugInfoSelection, _soliditySourceProvider}(_ast.root()); } @@ -74,8 +74,8 @@ std::string AsmPrinter::operator()(Literal const& _literal) std::string AsmPrinter::operator()(Identifier const& _identifier) { - yulAssert(!_identifier.name.empty(), "Invalid identifier."); - return formatDebugData(_identifier) + _identifier.name.str(); + yulAssert(!m_labels.empty(_identifier.name), "Invalid identifier."); + return fmt::format("{}{}", formatDebugData(_identifier), m_labels[_identifier.name]); } std::string AsmPrinter::operator()(BuiltinName const& _builtin) @@ -123,10 +123,10 @@ std::string AsmPrinter::operator()(VariableDeclaration const& _variableDeclarati std::string AsmPrinter::operator()(FunctionDefinition const& _functionDefinition) { - yulAssert(!_functionDefinition.name.empty(), "Invalid function name."); + yulAssert(!m_labels.empty(_functionDefinition.name), "Invalid function name."); std::string out = formatDebugData(_functionDefinition); - out += "function " + _functionDefinition.name.str() + "("; + out += fmt::format("function {}(", m_labels[_functionDefinition.name]); out += boost::algorithm::join( _functionDefinition.parameters | ranges::views::transform( [this](NameWithDebugData argument) { return formatNameWithDebugData(argument); } @@ -253,8 +253,8 @@ std::string AsmPrinter::operator()(Block const& _block) std::string AsmPrinter::formatNameWithDebugData(NameWithDebugData _variable) { - yulAssert(!_variable.name.empty(), "Invalid variable name."); - return formatDebugData(_variable) + _variable.name.str(); + yulAssert(!m_labels.empty(_variable.name), "Invalid variable name."); + return fmt::format("{}{}", formatDebugData(_variable), m_labels[_variable.name]); } std::string AsmPrinter::formatSourceLocation( diff --git a/libyul/AsmPrinter.h b/libyul/AsmPrinter.h index 60a7f9a0f289..1303def7b27c 100644 --- a/libyul/AsmPrinter.h +++ b/libyul/AsmPrinter.h @@ -55,11 +55,13 @@ class AsmPrinter explicit AsmPrinter( Dialect const& _dialect, + ASTLabelRegistry const& _labels, std::optional>> const& _sourceIndexToName = {}, langutil::DebugInfoSelection const& _debugInfoSelection = langutil::DebugInfoSelection::Default(), langutil::CharStreamProvider const* _soliditySourceProvider = nullptr ): m_dialect(_dialect), + m_labels(_labels), m_debugInfoSelection(_debugInfoSelection), m_soliditySourceProvider(_soliditySourceProvider) { @@ -102,6 +104,7 @@ class AsmPrinter } Dialect const& m_dialect; + ASTLabelRegistry const& m_labels; std::map m_nameToSourceIndex; langutil::SourceLocation m_lastLocation = {}; langutil::DebugInfoSelection m_debugInfoSelection = {}; diff --git a/libyul/CompilabilityChecker.cpp b/libyul/CompilabilityChecker.cpp index 2df14f211939..485205bb8083 100644 --- a/libyul/CompilabilityChecker.cpp +++ b/libyul/CompilabilityChecker.cpp @@ -42,7 +42,7 @@ CompilabilityChecker::CompilabilityChecker( yul::AsmAnalysisInfo analysisInfo = yul::AsmAnalyzer::analyzeStrictAssertCorrect( noOutputDialect, - _object.code()->root(), + *_object.code(), _object.summarizeStructure() ); @@ -56,7 +56,7 @@ CompilabilityChecker::CompilabilityChecker( CodeTransform transform( assembly, analysisInfo, - _object.code()->root(), + *_object.code(), noOutputDialect, builtinContext, _optimizeStackAllocation diff --git a/libyul/Exceptions.h b/libyul/Exceptions.h index 4f08e192f788..9d0a13007ce3 100644 --- a/libyul/Exceptions.h +++ b/libyul/Exceptions.h @@ -50,8 +50,8 @@ struct StackTooDeepError: virtual YulException { *this << util::errinfo_comment(_message); } - YulName functionName; - YulName variable; + YulName functionName{}; + YulName variable{}; int depth; }; diff --git a/libyul/Object.cpp b/libyul/Object.cpp index 54ec6a3cfd7a..7f0aa11d6dc0 100644 --- a/libyul/Object.cpp +++ b/libyul/Object.cpp @@ -99,7 +99,7 @@ Json Object::toJson() const Json codeJson; codeJson["nodeType"] = "YulCode"; - codeJson["block"] = AsmJsonConverter(*dialect(), 0 /* sourceIndex */)(code()->root()); + codeJson["block"] = AsmJsonConverter(*dialect(), code()->labels(), 0 /* sourceIndex */)(code()->root()); Json subObjectsJson = Json::array(); for (std::shared_ptr const& subObject: subObjects) diff --git a/libyul/ObjectOptimizer.cpp b/libyul/ObjectOptimizer.cpp index 58de85fd190b..22575b9a9df7 100644 --- a/libyul/ObjectOptimizer.cpp +++ b/libyul/ObjectOptimizer.cpp @@ -82,7 +82,7 @@ void ObjectOptimizer::optimize(Object& _object, Settings const& _settings, bool if (EVMDialect const* evmDialect = dynamic_cast(&dialect)) meter = std::make_unique(*evmDialect, _isCreation, _settings.expectedExecutionsPerDeployment); - std::optional cacheKey = calculateCacheKey(_object.code()->root(), *_object.debugData, _settings, _isCreation); + std::optional cacheKey = calculateCacheKey(*_object.code(), *_object.debugData, _settings, _isCreation); if (cacheKey.has_value() && m_cachedObjects.count(*cacheKey) != 0) { overwriteWithOptimizedObject(*cacheKey, _object); @@ -107,6 +107,7 @@ void ObjectOptimizer::storeOptimizedObject(util::h256 _cacheKey, Object const& _ { m_cachedObjects[_cacheKey] = CachedObject{ std::make_shared(ASTCopier{}.translate(_optimizedObject.code()->root())), + std::make_unique(_optimizedObject.code()->labels()), &_dialect, }; } @@ -121,7 +122,7 @@ void ObjectOptimizer::overwriteWithOptimizedObject(util::h256 _cacheKey, Object& _object.setCode( std::make_shared( *cachedObject.dialect, - ASTLabelRegistry{}, + ASTLabelRegistry(*cachedObject.labels), ASTCopier{}.translate(*cachedObject.optimizedAST) ) ); @@ -140,7 +141,7 @@ void ObjectOptimizer::overwriteWithOptimizedObject(util::h256 _cacheKey, Object& } std::optional ObjectOptimizer::calculateCacheKey( - Block const& _ast, + AST const& _ast, ObjectDebugData const& _debugData, Settings const& _settings, bool _isCreation @@ -148,6 +149,7 @@ std::optional ObjectOptimizer::calculateCacheKey( { AsmPrinter asmPrinter( languageToDialect(_settings.language, _settings.evmVersion, _settings.eofVersion), + _ast.labels(), _debugData.sourceNames, DebugInfoSelection::All() ); @@ -157,7 +159,7 @@ std::optional ObjectOptimizer::calculateCacheKey( // in that regard are considered equal here. This is fine because the optimizer does not keep // them up to date across AST transformations anyway so in any use where they need to be reliable, // we just regenerate them by reparsing the object. - rawKey += keccak256(asmPrinter(_ast)).asBytes(); + rawKey += keccak256(asmPrinter(_ast.root())).asBytes(); rawKey += keccak256(_debugData.formatUseSrcComment()).asBytes(); rawKey += h256(u256(_settings.language)).asBytes(); static_assert(static_cast(static_cast(2)) == 1); diff --git a/libyul/ObjectOptimizer.h b/libyul/ObjectOptimizer.h index b2019d36b206..c1884d9820ee 100644 --- a/libyul/ObjectOptimizer.h +++ b/libyul/ObjectOptimizer.h @@ -77,6 +77,7 @@ class ObjectOptimizer struct CachedObject { std::shared_ptr optimizedAST; + std::unique_ptr labels; Dialect const* dialect; }; @@ -86,7 +87,7 @@ class ObjectOptimizer void overwriteWithOptimizedObject(util::h256 _cacheKey, Object& _object) const; static std::optional calculateCacheKey( - Block const& _ast, + AST const& _ast, ObjectDebugData const& _debugData, Settings const& _settings, bool _isCreation diff --git a/libyul/ScopeFiller.cpp b/libyul/ScopeFiller.cpp index 7d65a2e95519..a1328a003b2c 100644 --- a/libyul/ScopeFiller.cpp +++ b/libyul/ScopeFiller.cpp @@ -38,8 +38,8 @@ using namespace solidity::yul; using namespace solidity::util; using namespace solidity::langutil; -ScopeFiller::ScopeFiller(AsmAnalysisInfo& _info, ErrorReporter& _errorReporter): - m_info(_info), m_errorReporter(_errorReporter) +ScopeFiller::ScopeFiller(AsmAnalysisInfo& _info, ErrorReporter& _errorReporter, ASTLabelRegistry const& _labels): + m_labels(_labels), m_info(_info), m_errorReporter(_errorReporter) { m_currentScope = &scope(nullptr); } @@ -141,7 +141,7 @@ bool ScopeFiller::registerVariable(NameWithDebugData const& _name, SourceLocatio m_errorReporter.declarationError( 1395_error, _location, - "Variable name " + _name.name.str() + " already taken in this scope." + fmt::format("Variable name {} already taken in this scope.", m_labels[_name.name]) ); return false; } @@ -156,7 +156,7 @@ bool ScopeFiller::registerFunction(FunctionDefinition const& _funDef) m_errorReporter.declarationError( 6052_error, nativeLocationOf(_funDef), - "Function name " + _funDef.name.str() + " already taken in this scope." + fmt::format("Function name {} already taken in this scope.", m_labels[_funDef.name]) ); return false; } diff --git a/libyul/ScopeFiller.h b/libyul/ScopeFiller.h index 7a4834a483a5..013e75677d43 100644 --- a/libyul/ScopeFiller.h +++ b/libyul/ScopeFiller.h @@ -39,6 +39,8 @@ struct NameWithDebugData; struct Scope; struct AsmAnalysisInfo; +class ASTLabelRegistry; + /** * Fills scopes with identifiers and checks for name clashes. * Does not resolve references. @@ -46,7 +48,7 @@ struct AsmAnalysisInfo; class ScopeFiller { public: - ScopeFiller(AsmAnalysisInfo& _info, langutil::ErrorReporter& _errorReporter); + ScopeFiller(AsmAnalysisInfo& _info, langutil::ErrorReporter& _errorReporter, ASTLabelRegistry const& _labels); bool operator()(Literal const&) { return true; } bool operator()(Identifier const&) { return true; } @@ -74,6 +76,7 @@ class ScopeFiller Scope& scope(Block const* _block); Scope* m_currentScope = nullptr; + ASTLabelRegistry const& m_labels; AsmAnalysisInfo& m_info; langutil::ErrorReporter& m_errorReporter; }; diff --git a/libyul/Utilities.cpp b/libyul/Utilities.cpp index e7caf1b2dff4..144f439bdb5b 100644 --- a/libyul/Utilities.cpp +++ b/libyul/Utilities.cpp @@ -242,11 +242,11 @@ bool SwitchCaseCompareByLiteralValue::operator()(Case const* _lhs, Case const* _ return Less{}(_lhs->value.get(), _rhs->value.get()); } -std::string_view yul::resolveFunctionName(FunctionName const& _functionName, Dialect const& _dialect) +std::string_view yul::resolveFunctionName(FunctionName const& _functionName, ASTLabelRegistry const& _labels, Dialect const& _dialect) { GenericVisitor visitor{ - [&](Identifier const& _identifier) -> std::string const& { return _identifier.name.str(); }, - [&](BuiltinName const& _builtin) -> std::string const& { return _dialect.builtin(_builtin.handle).name; } + [&](Identifier const& _identifier) -> std::string_view { return _labels[_identifier.name]; }, + [&](BuiltinName const& _builtin) -> std::string_view { return _dialect.builtin(_builtin.handle).name; } }; return std::visit(visitor, _functionName); } diff --git a/libyul/Utilities.h b/libyul/Utilities.h index 64b5f456ac1f..cec0a37f1938 100644 --- a/libyul/Utilities.h +++ b/libyul/Utilities.h @@ -30,6 +30,7 @@ namespace solidity::yul { +class ASTLabelRegistry; class Dialect; class EVMDialect; struct BuiltinFunction; @@ -88,7 +89,7 @@ struct SwitchCaseCompareByLiteralValue bool operator()(Case const* _lhsCase, Case const* _rhsCase) const; }; -std::string_view resolveFunctionName(FunctionName const& _functionName, Dialect const& _dialect); +std::string_view resolveFunctionName(FunctionName const& _functionName, ASTLabelRegistry const& _labels, Dialect const& _dialect); BuiltinFunction const* resolveBuiltinFunction(FunctionName const& _functionName, Dialect const& _dialect); BuiltinFunctionForEVM const* resolveBuiltinFunctionForEVM(FunctionName const& _functionName, EVMDialect const& _dialect); diff --git a/libyul/YulControlFlowGraphExporter.cpp b/libyul/YulControlFlowGraphExporter.cpp index 65c0805f984a..b5bee8b813a1 100644 --- a/libyul/YulControlFlowGraphExporter.cpp +++ b/libyul/YulControlFlowGraphExporter.cpp @@ -31,7 +31,10 @@ using namespace solidity::langutil; using namespace solidity::util; using namespace solidity::yul; -YulControlFlowGraphExporter::YulControlFlowGraphExporter(ControlFlow const& _controlFlow, ControlFlowLiveness const* _liveness): m_controlFlow(_controlFlow), m_liveness(_liveness) +YulControlFlowGraphExporter::YulControlFlowGraphExporter(ASTLabelRegistry const& _labels, ControlFlow const& _controlFlow, ControlFlowLiveness const* _liveness): + m_labels(_labels), + m_controlFlow(_controlFlow), + m_liveness(_liveness) { } @@ -67,7 +70,7 @@ Json YulControlFlowGraphExporter::run() Json functionsJson = Json::object(); size_t index = 0; for (auto const& [function, functionGraph]: m_controlFlow.functionGraphMapping) - functionsJson[function->name.str()] = exportFunction(*functionGraph, m_liveness ? m_liveness->functionLiveness[index++].get() : nullptr); + functionsJson[m_labels[function->name]] = exportFunction(*functionGraph, m_liveness ? m_liveness->functionLiveness[index++].get() : nullptr); yulObjectJson["functions"] = functionsJson; return yulObjectJson; @@ -180,7 +183,7 @@ Json YulControlFlowGraphExporter::toJson(Json& _ret, SSACFG const& _cfg, SSACFG: std::visit(util::GenericVisitor{ [&](SSACFG::Call const& _call) { _ret["type"] = "FunctionCall"; - opJson["op"] = _call.function.get().name.str(); + opJson["op"] = m_labels[_call.function.get().name]; }, [&](SSACFG::BuiltinCall const& _call) { _ret["type"] = "BuiltinCall"; diff --git a/libyul/YulControlFlowGraphExporter.h b/libyul/YulControlFlowGraphExporter.h index 91f9d040e404..55b6ce076e92 100644 --- a/libyul/YulControlFlowGraphExporter.h +++ b/libyul/YulControlFlowGraphExporter.h @@ -28,13 +28,14 @@ using namespace yul; class YulControlFlowGraphExporter { public: - YulControlFlowGraphExporter(ControlFlow const& _controlFlow, ControlFlowLiveness const* _liveness=nullptr); + YulControlFlowGraphExporter(ASTLabelRegistry const& _labels, ControlFlow const& _controlFlow, ControlFlowLiveness const* _liveness=nullptr); Json run(); Json exportBlock(SSACFG const& _cfg, SSACFG::BlockId _blockId, SSACFGLiveness const* _liveness); Json exportFunction(SSACFG const& _cfg, SSACFGLiveness const* _liveness); std::string varToString(SSACFG const& _cfg, SSACFG::ValueId _var); private: + ASTLabelRegistry const& m_labels; ControlFlow const& m_controlFlow; ControlFlowLiveness const* m_liveness; Json toJson(SSACFG const& _cfg, SSACFG::BlockId _blockId, SSACFGLiveness const* _liveness); diff --git a/libyul/YulStack.cpp b/libyul/YulStack.cpp index 5adb8d6d5c9a..eecf0a35807b 100644 --- a/libyul/YulStack.cpp +++ b/libyul/YulStack.cpp @@ -167,6 +167,7 @@ bool YulStack::analyzeParsed(Object& _object) *_object.analysisInfo, m_errorReporter, languageToDialect(m_language, m_evmVersion, m_eofVersion), + _object.code()->labels(), {}, _object.summarizeStructure() ); @@ -401,7 +402,7 @@ Json YulStack::cfgJson() const _object.code()->root() ); std::unique_ptr liveness = std::make_unique(*controlFlow); - YulControlFlowGraphExporter exporter(*controlFlow, liveness.get()); + YulControlFlowGraphExporter exporter(_object.code()->labels(), *controlFlow, liveness.get()); return exporter.run(); }; diff --git a/libyul/backends/evm/AsmCodeGen.cpp b/libyul/backends/evm/AsmCodeGen.cpp index 91d06e2f0850..a0e8d902219d 100644 --- a/libyul/backends/evm/AsmCodeGen.cpp +++ b/libyul/backends/evm/AsmCodeGen.cpp @@ -34,7 +34,7 @@ using namespace solidity::util; using namespace solidity::langutil; void CodeGenerator::assemble( - Block const& _parsedData, + AST const& _parsedData, AsmAnalysisInfo& _analysisInfo, evmasm::Assembly& _assembly, langutil::EVMVersion _evmVersion, @@ -58,7 +58,7 @@ void CodeGenerator::assemble( CodeTransform::UseNamedLabels::YesAndForceUnique : CodeTransform::UseNamedLabels::Never ); - transform(_parsedData); + transform(_parsedData.root()); if (!transform.stackErrors().empty()) assertThrow( false, diff --git a/libyul/backends/evm/AsmCodeGen.h b/libyul/backends/evm/AsmCodeGen.h index d7a6b5c928f5..03c00ac79d5a 100644 --- a/libyul/backends/evm/AsmCodeGen.h +++ b/libyul/backends/evm/AsmCodeGen.h @@ -40,7 +40,7 @@ class CodeGenerator public: /// Performs code generation and appends generated to _assembly. static void assemble( - Block const& _parsedData, + AST const& _parsedData, AsmAnalysisInfo& _analysisInfo, evmasm::Assembly& _assembly, langutil::EVMVersion _evmVersion, diff --git a/libyul/backends/evm/ControlFlow.cpp b/libyul/backends/evm/ControlFlow.cpp index 863fa30f6c7d..8e11acd0572c 100644 --- a/libyul/backends/evm/ControlFlow.cpp +++ b/libyul/backends/evm/ControlFlow.cpp @@ -27,7 +27,7 @@ ControlFlowLiveness::ControlFlowLiveness(ControlFlow const& _controlFlow): functionLiveness(_controlFlow.functionGraphs | ranges::views::transform([](auto const& _cfg) { return std::make_unique(*_cfg); }) | ranges::to) { } -std::string ControlFlowLiveness::toDot() const +std::string ControlFlowLiveness::toDot(ASTLabelRegistry const& _labels) const { - return controlFlow.get().toDot(this); + return controlFlow.get().toDot(_labels, this); } diff --git a/libyul/backends/evm/ControlFlow.h b/libyul/backends/evm/ControlFlow.h index 394ce00c58c4..93cd167a408b 100644 --- a/libyul/backends/evm/ControlFlow.h +++ b/libyul/backends/evm/ControlFlow.h @@ -35,7 +35,7 @@ struct ControlFlowLiveness{ std::unique_ptr mainLiveness; std::vector> functionLiveness; - std::string toDot() const; + std::string toDot(ASTLabelRegistry const& _labels) const; }; struct ControlFlow @@ -52,16 +52,17 @@ struct ControlFlow return nullptr; } - std::string toDot(ControlFlowLiveness const* _liveness=nullptr) const + std::string toDot(ASTLabelRegistry const& _labels, ControlFlowLiveness const* _liveness=nullptr) const { if (_liveness) yulAssert(&_liveness->controlFlow.get() == this); std::ostringstream output; output << "digraph SSACFG {\nnodesep=0.7;\ngraph[fontname=\"DejaVu Sans\"]\nnode[shape=box,fontname=\"DejaVu Sans\"];\n\n"; - output << mainGraph->toDot(false, std::nullopt, _liveness ? _liveness->mainLiveness.get() : nullptr); + output << mainGraph->toDot(_labels, false, std::nullopt, _liveness ? _liveness->mainLiveness.get() : nullptr); for (size_t index=0; index < functionGraphs.size(); ++index) output << functionGraphs[index]->toDot( + _labels, false, index+1, _liveness ? _liveness->functionLiveness[index].get() : nullptr diff --git a/libyul/backends/evm/ControlFlowGraph.h b/libyul/backends/evm/ControlFlowGraph.h index 980787c52297..1cff3c98299c 100644 --- a/libyul/backends/evm/ControlFlowGraph.h +++ b/libyul/backends/evm/ControlFlowGraph.h @@ -29,6 +29,8 @@ #include +#include + #include #include #include @@ -237,11 +239,26 @@ struct CFG /// Ghost calls are used for the equality comparisons of the switch condition ghost variable with /// the switch case literals when transforming the control flow of a switch to a sequence of conditional jumps. std::list ghostCalls; + /// AST labels + std::unique_ptr labels; + std::string_view labelOf(ASTLabelRegistry::LabelID const _id) const + { + yulAssert(labels, "AST labels must be part of the CFG to use the labelOf functionality."); + if (!labels->ghost(_id)) + return (*labels)[_id]; + + // to satisfy the `labelOf(id) -> string_view` interface, the backing strings are cached here + auto const [it, _] = ghostLabelsCache.try_emplace(_id, fmt::format("GHOST[{}]", _id)); + return it->second; + } BasicBlock& makeBlock(langutil::DebugData::ConstPtr _debugData) { return blocks.emplace_back(BasicBlock{std::move(_debugData), {}, {}}); } + +private: + mutable std::map ghostLabelsCache; }; } diff --git a/libyul/backends/evm/ControlFlowGraphBuilder.cpp b/libyul/backends/evm/ControlFlowGraphBuilder.cpp index d9456e4c32d0..9c0845cd5b4e 100644 --- a/libyul/backends/evm/ControlFlowGraphBuilder.cpp +++ b/libyul/backends/evm/ControlFlowGraphBuilder.cpp @@ -25,6 +25,7 @@ #include #include #include +#include #include #include @@ -228,6 +229,7 @@ void markNeedsCleanStack(CFG& _cfg) std::unique_ptr ControlFlowGraphBuilder::build( AsmAnalysisInfo const& _analysisInfo, + LabelIDDispenser& _nameDispenser, Dialect const& _dialect, Block const& _block ) @@ -240,7 +242,7 @@ std::unique_ptr ControlFlowGraphBuilder::build( result->entry = &result->makeBlock(debugDataOf(_block)); ControlFlowSideEffectsCollector sideEffects(_dialect, _block); - ControlFlowGraphBuilder builder(*result, _analysisInfo, sideEffects.functionSideEffects(), _dialect); + ControlFlowGraphBuilder builder(*result, _analysisInfo, sideEffects.functionSideEffects(), _nameDispenser, _dialect); builder.m_currentBlock = result->entry; builder(_block); @@ -249,6 +251,8 @@ std::unique_ptr ControlFlowGraphBuilder::build( markStartsOfSubGraphs(*result); markNeedsCleanStack(*result); + result->labels = std::make_unique(builder.m_nameDispenser.generateNewLabels(_block, _dialect)); + // TODO: It might be worthwhile to run some further simplifications on the graph itself here. // E.g. if there is a jump to a node that has the jumping node as its only entry, the nodes can be fused, etc. @@ -259,11 +263,13 @@ ControlFlowGraphBuilder::ControlFlowGraphBuilder( CFG& _graph, AsmAnalysisInfo const& _analysisInfo, std::map const& _functionSideEffects, + LabelIDDispenser& _nameDispenser, Dialect const& _dialect ): m_graph(_graph), m_info(_analysisInfo), m_functionSideEffects(_functionSideEffects), + m_nameDispenser(_nameDispenser), m_dialect(_dialect) { if (EVMDialect const* evmDialect = dynamic_cast(&m_dialect)) @@ -362,8 +368,7 @@ void ControlFlowGraphBuilder::operator()(Switch const& _switch) yulAssert(m_currentBlock, ""); langutil::DebugData::ConstPtr preSwitchDebugData = debugDataOf(_switch); - auto ghostVariableId = m_graph.ghostVariables.size(); - YulName ghostVariableName("GHOST[" + std::to_string(ghostVariableId) + "]"); + YulName const ghostVariableName = m_nameDispenser.newGhost(); auto& ghostVar = m_graph.ghostVariables.emplace_back(Scope::Variable{ghostVariableName}); // Artificially generate: @@ -496,7 +501,7 @@ void ControlFlowGraphBuilder::operator()(FunctionDefinition const& _function) CFG::FunctionInfo& functionInfo = m_graph.functionInfo.at(&function); - ControlFlowGraphBuilder builder{m_graph, m_info, m_functionSideEffects, m_dialect}; + ControlFlowGraphBuilder builder{m_graph, m_info, m_functionSideEffects, m_nameDispenser, m_dialect}; builder.m_currentFunction = &functionInfo; builder.m_currentBlock = functionInfo.entry; builder(_function.body); diff --git a/libyul/backends/evm/ControlFlowGraphBuilder.h b/libyul/backends/evm/ControlFlowGraphBuilder.h index 4a2aae98c26f..a405d614d70b 100644 --- a/libyul/backends/evm/ControlFlowGraphBuilder.h +++ b/libyul/backends/evm/ControlFlowGraphBuilder.h @@ -31,7 +31,7 @@ class ControlFlowGraphBuilder public: ControlFlowGraphBuilder(ControlFlowGraphBuilder const&) = delete; ControlFlowGraphBuilder& operator=(ControlFlowGraphBuilder const&) = delete; - static std::unique_ptr build(AsmAnalysisInfo const& _analysisInfo, Dialect const& _dialect, Block const& _block); + static std::unique_ptr build(AsmAnalysisInfo const& _analysisInfo, LabelIDDispenser& _nameDispenser, Dialect const& _dialect, Block const& _block); StackSlot operator()(Expression const& _expression); StackSlot operator()(Literal const& _literal); @@ -57,6 +57,7 @@ class ControlFlowGraphBuilder CFG& _graph, AsmAnalysisInfo const& _analysisInfo, std::map const& _functionSideEffects, + LabelIDDispenser& _nameDispenser, Dialect const& _dialect ); void registerFunction(FunctionDefinition const& _function); @@ -80,6 +81,7 @@ class ControlFlowGraphBuilder CFG& m_graph; AsmAnalysisInfo const& m_info; std::map const& m_functionSideEffects; + LabelIDDispenser& m_nameDispenser; Dialect const& m_dialect; CFG::BasicBlock* m_currentBlock = nullptr; Scope* m_scope = nullptr; diff --git a/libyul/backends/evm/EVMCodeTransform.cpp b/libyul/backends/evm/EVMCodeTransform.cpp index f77e4e047d7a..d7b99088db33 100644 --- a/libyul/backends/evm/EVMCodeTransform.cpp +++ b/libyul/backends/evm/EVMCodeTransform.cpp @@ -32,6 +32,8 @@ #include +#include + #include #include @@ -50,6 +52,7 @@ CodeTransform::CodeTransform( AbstractAssembly& _assembly, AsmAnalysisInfo& _analysisInfo, Block const& _block, + ASTLabelRegistry const& _labels, bool _allowStackOpt, EVMDialect const& _dialect, BuiltinContext& _builtinContext, @@ -61,6 +64,7 @@ CodeTransform::CodeTransform( ): m_assembly(_assembly), m_info(_analysisInfo), + m_labels(_labels), m_dialect(_dialect), m_builtinContext(_builtinContext), m_allowStackOpt(_allowStackOpt), @@ -385,6 +389,7 @@ void CodeTransform::operator()(FunctionDefinition const& _function) m_assembly, m_info, _function.body, + m_labels, m_allowStackOpt, m_dialect, m_builtinContext, @@ -420,7 +425,7 @@ void CodeTransform::operator()(FunctionDefinition const& _function) m_assembly.markAsInvalid(); for (StackTooDeepError& stackError: subTransform.m_stackErrors) { - if (stackError.functionName.empty()) + if (ASTLabelRegistry::empty(stackError.functionName)) stackError.functionName = _function.name; m_stackErrors.emplace_back(std::move(stackError)); } @@ -460,11 +465,11 @@ void CodeTransform::operator()(FunctionDefinition const& _function) _function.name, YulName{}, static_cast(stackLayout.size()) - 17, - "The function " + - _function.name.str() + - " has " + - std::to_string(stackLayout.size() - 17) + - " parameters or return variables too many to fit the stack size." + fmt::format( + "The function {} has {} parameters or return variables too many to fit the stack size.", + m_labels[_function.name], + stackLayout.size() - 17 + ) ); stackError(std::move(error), m_assembly.stackHeight() - static_cast(_function.parameters.size())); } @@ -603,7 +608,7 @@ void CodeTransform::createFunctionEntryID(FunctionDefinition const& _function) !nameAlreadySeen ) ? m_assembly.namedLabel( - _function.name.str(), + std::string{m_labels[_function.name]}, _function.parameters.size(), _function.returnVariables.size(), astID @@ -783,12 +788,12 @@ size_t CodeTransform::variableHeightDiff(Scope::Variable const& _var, YulName _v m_stackErrors.emplace_back( _varName, heightDiff - limit, - "Variable " + - _varName.str() + - " is " + - std::to_string(heightDiff - limit) + - " slot(s) too deep inside the stack. " + - stackTooDeepString + fmt::format( + "Variable {} is {} slot(s) too deep inside the stack. {}", + m_labels[_varName], + heightDiff - limit, + stackTooDeepString + ) ); m_assembly.markAsInvalid(); return _forSwap ? 2 : 1; diff --git a/libyul/backends/evm/EVMCodeTransform.h b/libyul/backends/evm/EVMCodeTransform.h index c0bbac81b35e..3d569f6b7bb2 100644 --- a/libyul/backends/evm/EVMCodeTransform.h +++ b/libyul/backends/evm/EVMCodeTransform.h @@ -77,7 +77,7 @@ class CodeTransform CodeTransform( AbstractAssembly& _assembly, AsmAnalysisInfo& _analysisInfo, - Block const& _block, + AST const& _ast, EVMDialect const& _dialect, BuiltinContext& _builtinContext, bool _allowStackOpt = false, @@ -86,7 +86,8 @@ class CodeTransform ): CodeTransform( _assembly, _analysisInfo, - _block, + _ast.root(), + _ast.labels(), _allowStackOpt, _dialect, _builtinContext, @@ -108,6 +109,7 @@ class CodeTransform AbstractAssembly& _assembly, AsmAnalysisInfo& _analysisInfo, Block const& _block, + ASTLabelRegistry const& _labels, bool _allowStackOpt, EVMDialect const& _dialect, BuiltinContext& _builtinContext, @@ -194,6 +196,7 @@ class CodeTransform AbstractAssembly& m_assembly; AsmAnalysisInfo& m_info; Scope* m_scope = nullptr; + ASTLabelRegistry const& m_labels; EVMDialect const& m_dialect; BuiltinContext& m_builtinContext; bool const m_allowStackOpt = true; diff --git a/libyul/backends/evm/EVMDialect.cpp b/libyul/backends/evm/EVMDialect.cpp index d68ef16348b1..147fd619393b 100644 --- a/libyul/backends/evm/EVMDialect.cpp +++ b/libyul/backends/evm/EVMDialect.cpp @@ -287,16 +287,16 @@ std::vector> createBuiltins(langutil::EVMVe yulAssert(_context.currentObject, "No object available."); yulAssert(_call.arguments.size() == 1, ""); Expression const& arg = _call.arguments.front(); - YulName const dataName (formatLiteral(std::get(arg))); - if (_context.currentObject->name == dataName.str()) + std::string const dataName = formatLiteral(std::get(arg)); + if (_context.currentObject->name == dataName) _assembly.appendAssemblySize(); else { std::vector subIdPath = - _context.subIDs.count(dataName.str()) == 0 ? - _context.currentObject->pathToSubObject(dataName.str()) : - std::vector{_context.subIDs.at(dataName.str())}; - yulAssert(!subIdPath.empty(), "Could not find assembly object <" + dataName.str() + ">."); + _context.subIDs.count(dataName) == 0 ? + _context.currentObject->pathToSubObject(dataName) : + std::vector{_context.subIDs.at(dataName)}; + yulAssert(!subIdPath.empty(), "Could not find assembly object <" + dataName + ">."); _assembly.appendDataSize(subIdPath); } })); @@ -308,16 +308,16 @@ std::vector> createBuiltins(langutil::EVMVe yulAssert(_context.currentObject, "No object available."); yulAssert(_call.arguments.size() == 1, ""); Expression const& arg = _call.arguments.front(); - YulName const dataName (formatLiteral(std::get(arg))); - if (_context.currentObject->name == dataName.str()) + std::string const dataName = formatLiteral(std::get(arg)); + if (_context.currentObject->name == dataName) _assembly.appendConstant(0); else { std::vector subIdPath = - _context.subIDs.count(dataName.str()) == 0 ? - _context.currentObject->pathToSubObject(dataName.str()) : - std::vector{_context.subIDs.at(dataName.str())}; - yulAssert(!subIdPath.empty(), "Could not find assembly object <" + dataName.str() + ">."); + _context.subIDs.count(dataName) == 0 ? + _context.currentObject->pathToSubObject(dataName) : + std::vector{_context.subIDs.at(dataName)}; + yulAssert(!subIdPath.empty(), "Could not find assembly object <" + dataName + ">."); _assembly.appendDataOffset(subIdPath); } })); diff --git a/libyul/backends/evm/EVMDialect.h b/libyul/backends/evm/EVMDialect.h index 0440daade1ce..8bc3f91c8c92 100644 --- a/libyul/backends/evm/EVMDialect.h +++ b/libyul/backends/evm/EVMDialect.h @@ -30,6 +30,7 @@ #include #include +#include namespace solidity::yul { diff --git a/libyul/backends/evm/EVMObjectCompiler.cpp b/libyul/backends/evm/EVMObjectCompiler.cpp index 830c32752dba..bdc8960d4b24 100644 --- a/libyul/backends/evm/EVMObjectCompiler.cpp +++ b/libyul/backends/evm/EVMObjectCompiler.cpp @@ -86,6 +86,7 @@ void EVMObjectCompiler::run(Object const& _object, bool _optimize) m_assembly, *_object.analysisInfo, _object.code()->root(), + _object.code()->labels(), *evmDialect, context, OptimizedEVMCodeTransform::UseNamedLabels::ForFirstFunctionOfEachName @@ -118,7 +119,7 @@ void EVMObjectCompiler::run(Object const& _object, bool _optimize) CodeTransform transform{ m_assembly, *_object.analysisInfo, - _object.code()->root(), + *_object.code(), *evmDialect, context, _optimize, diff --git a/libyul/backends/evm/OptimizedEVMCodeTransform.cpp b/libyul/backends/evm/OptimizedEVMCodeTransform.cpp index 69cd046debd0..be89a3d75a52 100644 --- a/libyul/backends/evm/OptimizedEVMCodeTransform.cpp +++ b/libyul/backends/evm/OptimizedEVMCodeTransform.cpp @@ -21,6 +21,8 @@ #include #include +#include + #include #include @@ -43,12 +45,15 @@ std::vector OptimizedEVMCodeTransform::run( AbstractAssembly& _assembly, AsmAnalysisInfo& _analysisInfo, Block const& _block, + ASTLabelRegistry const& _labels, EVMDialect const& _dialect, BuiltinContext& _builtinContext, UseNamedLabels _useNamedLabelsForFunctions ) { - std::unique_ptr dfg = ControlFlowGraphBuilder::build(_analysisInfo, _dialect, _block); + // we need to be able to spawn some ghost nodes in the CFG + LabelIDDispenser nameDispenser{_labels}; + std::unique_ptr const dfg = ControlFlowGraphBuilder::build(_analysisInfo, nameDispenser, _dialect, _block); StackLayout stackLayout = StackLayoutGenerator::run(*dfg, _dialect); if (_dialect.eofVersion().has_value()) @@ -221,7 +226,7 @@ OptimizedEVMCodeTransform::OptimizedEVMCodeTransform( bool useNamedLabel = _useNamedLabelsForFunctions != UseNamedLabels::Never && !nameAlreadySeen; functionLabels[&functionInfo] = useNamedLabel ? m_assembly.namedLabel( - function->name.str(), + std::string{m_dfg.labelOf(function->name)}, function->numArguments, function->numReturns, functionInfo.debugData ? functionInfo.debugData->astID : std::nullopt @@ -296,12 +301,12 @@ void OptimizedEVMCodeTransform::createStackLayout(langutil::DebugData::ConstPtr YulName varNameDeep = slotVariableName(deepSlot); YulName varNameTop = slotVariableName(m_stack.back()); std::string msg = - "Cannot swap " + (varNameDeep.empty() ? "Slot " + stackSlotToString(deepSlot, m_dialect) : "Variable " + varNameDeep.str()) + - " with " + (varNameTop.empty() ? "Slot " + stackSlotToString(m_stack.back(), m_dialect) : "Variable " + varNameTop.str()) + - ": too deep in the stack by " + std::to_string(deficit) + " slots in " + stackToString(m_stack, m_dialect); + "Cannot swap " + (ASTLabelRegistry::empty(varNameDeep) ? "Slot " + stackSlotToString(deepSlot, m_dfg, m_dialect) : "Variable " + std::string{m_dfg.labelOf(varNameDeep)}) + + " with " + (ASTLabelRegistry::empty(varNameTop) ? "Slot " + stackSlotToString(m_stack.back(), m_dfg, m_dialect) : "Variable " + std::string{m_dfg.labelOf(varNameTop)}) + + ": too deep in the stack by " + std::to_string(deficit) + " slots in " + stackToString(m_stack, m_dfg, m_dialect); m_stackErrors.emplace_back(StackTooDeepError( m_currentFunctionInfo ? m_currentFunctionInfo->function.name : YulName{}, - varNameDeep.empty() ? varNameTop : varNameDeep, + ASTLabelRegistry::empty(varNameDeep) ? varNameTop : varNameDeep, deficit, msg ) << langutil::errinfo_sourceLocation(sourceLocation)); @@ -325,8 +330,8 @@ void OptimizedEVMCodeTransform::createStackLayout(langutil::DebugData::ConstPtr int deficit = static_cast(*depth - (m_reachableStackDepth - 1)); YulName varName = slotVariableName(_slot); std::string msg = - (varName.empty() ? "Slot " + stackSlotToString(_slot, m_dialect) : "Variable " + varName.str()) - + " is " + std::to_string(*depth - (m_reachableStackDepth - 1)) + " too deep in the stack " + stackToString(m_stack, m_dialect); + (ASTLabelRegistry::empty(varName) ? "Slot " + stackSlotToString(_slot, m_dfg, m_dialect) : "Variable " + std::string{m_dfg.labelOf(varName)}) + + " is " + std::to_string(*depth - (m_reachableStackDepth - 1)) + " too deep in the stack " + stackToString(m_stack, m_dfg, m_dialect); m_stackErrors.emplace_back(StackTooDeepError( m_currentFunctionInfo ? m_currentFunctionInfo->function.name : YulName{}, varName, diff --git a/libyul/backends/evm/OptimizedEVMCodeTransform.h b/libyul/backends/evm/OptimizedEVMCodeTransform.h index 2cb251fba8d5..51ba39a919c7 100644 --- a/libyul/backends/evm/OptimizedEVMCodeTransform.h +++ b/libyul/backends/evm/OptimizedEVMCodeTransform.h @@ -51,6 +51,7 @@ class OptimizedEVMCodeTransform AbstractAssembly& _assembly, AsmAnalysisInfo& _analysisInfo, Block const& _block, + ASTLabelRegistry const& _labels, EVMDialect const& _dialect, BuiltinContext& _builtinContext, UseNamedLabels _useNamedLabelsForFunctions diff --git a/libyul/backends/evm/SSAControlFlowGraph.cpp b/libyul/backends/evm/SSAControlFlowGraph.cpp index 733f4967d806..cabb6d4741c8 100644 --- a/libyul/backends/evm/SSAControlFlowGraph.cpp +++ b/libyul/backends/evm/SSAControlFlowGraph.cpp @@ -39,13 +39,13 @@ namespace class SSACFGPrinter { public: - SSACFGPrinter(SSACFG const& _cfg, SSACFG::BlockId _blockId, SSACFGLiveness const* _liveness): - m_cfg(_cfg), m_functionIndex(0), m_liveness(_liveness) + SSACFGPrinter(SSACFG const& _cfg, ASTLabelRegistry const& _labels, SSACFG::BlockId _blockId, SSACFGLiveness const* _liveness): + m_cfg(_cfg), m_labels(_labels), m_functionIndex(0), m_liveness(_liveness) { printBlock(_blockId); } - SSACFGPrinter(SSACFG const& _cfg, size_t _functionIndex, Scope::Function const& _function, SSACFGLiveness const* _liveness): - m_cfg(_cfg), m_functionIndex(_functionIndex), m_liveness(_liveness) + SSACFGPrinter(SSACFG const& _cfg, ASTLabelRegistry const& _labels, size_t _functionIndex, Scope::Function const& _function, SSACFGLiveness const* _liveness): + m_cfg(_cfg), m_labels(_labels), m_functionIndex(_functionIndex), m_liveness(_liveness) { printFunction(_function); } @@ -161,11 +161,11 @@ class SSACFGPrinter } for (auto const& operation: _block.operations) { - std::string const label = std::visit(GenericVisitor{ + std::string_view const label = std::visit(GenericVisitor{ [&](SSACFG::Call const& _call) { - return _call.function.get().name.str(); + return m_labels[_call.function.get().name]; }, - [&](SSACFG::BuiltinCall const& _call) { + [&](SSACFG::BuiltinCall const& _call) -> std::string_view { return _call.builtin.get().name; }, }, operation.kind); @@ -266,19 +266,20 @@ class SSACFGPrinter void printFunction(Scope::Function const& _fun) { - static auto constexpr returnsTransform = [](auto const& functionReturnValue) { return escape(functionReturnValue.get().name.str()); }; + static auto returnsTransform = [&](auto const& functionReturnValue) { return escape(m_labels[functionReturnValue.get().name]); }; static auto constexpr argsTransform = [](auto const& arg) { return fmt::format("v{}", std::get<1>(arg).value); }; - m_result << "FunctionEntry_" << escape(_fun.name.str()) << "_" << m_cfg.entry.value << " [label=\""; + m_result << "FunctionEntry_" << escape(m_labels[_fun.name]) << "_" << m_cfg.entry.value << " [label=\""; if (!m_cfg.returns.empty()) - m_result << fmt::format("function {0}:\n {1} := {0}({2})", escape(_fun.name.str()), fmt::join(m_cfg.returns | ranges::views::transform(returnsTransform), ", "), fmt::join(m_cfg.arguments | ranges::views::transform(argsTransform), ", ")); + m_result << fmt::format("function {0}:\n {1} := {0}({2})", escape(m_labels[_fun.name]), fmt::join(m_cfg.returns | ranges::views::transform(returnsTransform), ", "), fmt::join(m_cfg.arguments | ranges::views::transform(argsTransform), ", ")); else - m_result << fmt::format("function {0}:\n {0}({1})", escape(_fun.name.str()), fmt::join(m_cfg.arguments | ranges::views::transform(argsTransform), ", ")); + m_result << fmt::format("function {0}:\n {0}({1})", escape(m_labels[_fun.name]), fmt::join(m_cfg.arguments | ranges::views::transform(argsTransform), ", ")); m_result << "\"];\n"; - m_result << "FunctionEntry_" << escape(_fun.name.str()) << "_" << m_cfg.entry.value << " -> Block" << m_functionIndex << "_" << m_cfg.entry.value << ";\n"; + m_result << "FunctionEntry_" << escape(m_labels[_fun.name]) << "_" << m_cfg.entry.value << " -> Block" << m_functionIndex << "_" << m_cfg.entry.value << ";\n"; printBlock(m_cfg.entry); } SSACFG const& m_cfg; + ASTLabelRegistry const& m_labels; size_t m_functionIndex; SSACFGLiveness const* m_liveness; std::stringstream m_result{}; @@ -286,6 +287,7 @@ class SSACFGPrinter } std::string SSACFG::toDot( + ASTLabelRegistry const& _labels, bool _includeDiGraphDefinition, std::optional _functionIndex, SSACFGLiveness const* _liveness @@ -295,9 +297,9 @@ std::string SSACFG::toDot( if (_includeDiGraphDefinition) output << "digraph SSACFG {\nnodesep=0.7;\ngraph[fontname=\"DejaVu Sans\"]\nnode[shape=box,fontname=\"DejaVu Sans\"];\n\n"; if (function) - output << SSACFGPrinter(*this, _functionIndex ? *_functionIndex : static_cast(1), *function, _liveness); + output << SSACFGPrinter(*this, _labels, _functionIndex ? *_functionIndex : static_cast(1), *function, _liveness); else - output << SSACFGPrinter(*this, entry, _liveness); + output << SSACFGPrinter(*this, _labels, entry, _liveness); if (_includeDiGraphDefinition) output << "}\n"; return output.str(); diff --git a/libyul/backends/evm/SSAControlFlowGraph.h b/libyul/backends/evm/SSAControlFlowGraph.h index 9397e0e207c1..5a39f83d1177 100644 --- a/libyul/backends/evm/SSAControlFlowGraph.h +++ b/libyul/backends/evm/SSAControlFlowGraph.h @@ -29,7 +29,10 @@ #include +#include + #include + #include #include #include @@ -221,6 +224,7 @@ class SSACFG } std::string toDot( + ASTLabelRegistry const& _labels, bool _includeDiGraphDefinition=true, std::optional _functionIndex=std::nullopt, SSACFGLiveness const* _liveness=nullptr diff --git a/libyul/backends/evm/StackHelpers.h b/libyul/backends/evm/StackHelpers.h index c5d63847153a..b22ca253c709 100644 --- a/libyul/backends/evm/StackHelpers.h +++ b/libyul/backends/evm/StackHelpers.h @@ -34,23 +34,23 @@ namespace solidity::yul { -inline std::string stackSlotToString(StackSlot const& _slot, Dialect const& _dialect) +inline std::string stackSlotToString(StackSlot const& _slot, CFG const& _cfg, Dialect const& _dialect) { return std::visit(util::GenericVisitor{ - [&](FunctionCallReturnLabelSlot const& _ret) -> std::string { return "RET[" + std::string(resolveFunctionName(_ret.call.get().functionName, _dialect)) + "]"; }, + [&](FunctionCallReturnLabelSlot const& _ret) -> std::string { return "RET[" + std::string(resolveFunctionName(_ret.call.get().functionName, *_cfg.labels, _dialect)) + "]"; }, [](FunctionReturnLabelSlot const&) -> std::string { return "RET"; }, - [](VariableSlot const& _var) { return _var.variable.get().name.str(); }, + [&](VariableSlot const& _var) { return std::string{_cfg.labelOf(_var.variable.get().name)}; }, [](LiteralSlot const& _lit) { return toCompactHexWithPrefix(_lit.value); }, - [&](TemporarySlot const& _tmp) -> std::string { return "TMP[" + std::string(resolveFunctionName(_tmp.call.get().functionName, _dialect)) + ", " + std::to_string(_tmp.index) + "]"; }, + [&](TemporarySlot const& _tmp) -> std::string { return "TMP[" + std::string(resolveFunctionName(_tmp.call.get().functionName, *_cfg.labels, _dialect)) + ", " + std::to_string(_tmp.index) + "]"; }, [](JunkSlot const&) -> std::string { return "JUNK"; } }, _slot); } -inline std::string stackToString(Stack const& _stack, Dialect const& _dialect) +inline std::string stackToString(Stack const& _stack, CFG const& _cfg, Dialect const& _dialect) { std::string result("[ "); for (auto const& slot: _stack) - result += stackSlotToString(slot, _dialect) + ' '; + result += stackSlotToString(slot, _cfg, _dialect) + ' '; result += ']'; return result; } diff --git a/libyul/backends/evm/StackLayoutGenerator.cpp b/libyul/backends/evm/StackLayoutGenerator.cpp index 69045998c859..da50fcc087b1 100644 --- a/libyul/backends/evm/StackLayoutGenerator.cpp +++ b/libyul/backends/evm/StackLayoutGenerator.cpp @@ -85,7 +85,7 @@ std::vector StackLayoutGenerator::reportStac { StackLayout stackLayout{{}, {}}; CFG::FunctionInfo const* functionInfo = nullptr; - if (!_functionName.empty()) + if (!ASTLabelRegistry::empty(_functionName)) { functionInfo = &ranges::find( _cfg.functionInfo, diff --git a/libyul/optimiser/BlockHasher.cpp b/libyul/optimiser/BlockHasher.cpp index 6e8e8ed62f57..d8ea7a0b06c6 100644 --- a/libyul/optimiser/BlockHasher.cpp +++ b/libyul/optimiser/BlockHasher.cpp @@ -65,7 +65,7 @@ void ASTHasherBase::hashFunctionCall(FunctionCall const& _funCall) [&](Identifier const& _identifier) { hash64(compileTimeLiteralHash("UserDefined")); - hash64(_identifier.name.hash()); + hash64(_identifier.name); } }; std::visit(visitor, _funCall.functionName); @@ -231,7 +231,7 @@ void ExpressionHasher::operator()(Literal const& _literal) void ExpressionHasher::operator()(Identifier const& _identifier) { hash64(compileTimeLiteralHash("Identifier")); - hash64(_identifier.name.hash()); + hash64(_identifier.name); } void ExpressionHasher::operator()(FunctionCall const& _funCall) diff --git a/libyul/optimiser/CallGraphGenerator.h b/libyul/optimiser/CallGraphGenerator.h index 722cbba4a796..00358a4389fa 100644 --- a/libyul/optimiser/CallGraphGenerator.h +++ b/libyul/optimiser/CallGraphGenerator.h @@ -63,7 +63,7 @@ class CallGraphGenerator: public ASTWalker CallGraph m_callGraph; /// The name of the function we are currently visiting during traversal. - YulName m_currentFunction; + YulName m_currentFunction = ASTLabelRegistry::emptyID(); }; } diff --git a/libyul/optimiser/CircularReferencesPruner.cpp b/libyul/optimiser/CircularReferencesPruner.cpp index d238f8da2148..707aa52d7c7c 100644 --- a/libyul/optimiser/CircularReferencesPruner.cpp +++ b/libyul/optimiser/CircularReferencesPruner.cpp @@ -51,7 +51,7 @@ void CircularReferencesPruner::operator()(Block& _block) std::set CircularReferencesPruner::functionsCalledFromOutermostContext(CallGraph const& _callGraph) { std::set verticesToTraverse = m_reservedIdentifiers; - verticesToTraverse.insert(YulName("")); + verticesToTraverse.insert(ASTLabelRegistry::emptyID()); return util::BreadthFirstSearch{{verticesToTraverse.begin(), verticesToTraverse.end()}}.run( [&_callGraph](YulName _function, auto&& _addChild) { diff --git a/libyul/optimiser/DataFlowAnalyzer.h b/libyul/optimiser/DataFlowAnalyzer.h index 7b731a4eb877..5b4ddab2537c 100644 --- a/libyul/optimiser/DataFlowAnalyzer.h +++ b/libyul/optimiser/DataFlowAnalyzer.h @@ -34,6 +34,7 @@ #include #include +#include namespace solidity::yul { diff --git a/libyul/optimiser/Disambiguator.cpp b/libyul/optimiser/Disambiguator.cpp index 343feb0be379..73ad0b198ac5 100644 --- a/libyul/optimiser/Disambiguator.cpp +++ b/libyul/optimiser/Disambiguator.cpp @@ -39,7 +39,7 @@ YulName Disambiguator::translateIdentifier(YulName const _originalName) Scope::Identifier const* id = m_scopes.back()->lookup(_originalName); assertThrow(id, OptimizerException, ""); if (!m_translations.contains(id)) - m_translations[id] = m_nameDispenser.newName(_originalName); + m_translations[id] = m_labelIDDispenser.newID(_originalName); return m_translations.at(id); } diff --git a/libyul/optimiser/Disambiguator.h b/libyul/optimiser/Disambiguator.h index 7ff186f0a8c7..ae4fdb488a61 100644 --- a/libyul/optimiser/Disambiguator.h +++ b/libyul/optimiser/Disambiguator.h @@ -21,12 +21,12 @@ #pragma once +#include +#include + #include #include -#include -#include -#include #include namespace solidity::yul @@ -42,12 +42,13 @@ class Disambiguator: public ASTCopier explicit Disambiguator( Dialect const& _dialect, AsmAnalysisInfo const& _analysisInfo, + LabelIDDispenser& _labelIDDispenser, std::set const& _externallyUsedIdentifiers = {} ): m_info(_analysisInfo), m_dialect(_dialect), m_externallyUsedIdentifiers(_externallyUsedIdentifiers), - m_nameDispenser(_dialect, m_externallyUsedIdentifiers) + m_labelIDDispenser(_labelIDDispenser) { } @@ -67,7 +68,7 @@ class Disambiguator: public ASTCopier std::vector m_scopes; std::map m_translations; - NameDispenser m_nameDispenser; + LabelIDDispenser& m_labelIDDispenser; }; } diff --git a/libyul/optimiser/ExpressionInliner.cpp b/libyul/optimiser/ExpressionInliner.cpp index 0d59dab2d2e7..a78a6b99c770 100644 --- a/libyul/optimiser/ExpressionInliner.cpp +++ b/libyul/optimiser/ExpressionInliner.cpp @@ -50,13 +50,17 @@ void ExpressionInliner::operator()(FunctionDefinition& _fun) void ExpressionInliner::visit(Expression& _expression) { ASTModifier::visit(_expression); - if (std::holds_alternative(_expression)) + + if (!std::holds_alternative(_expression)) + return; + + FunctionCall const& funCall = std::get(_expression); + if (auto const* functionNameIdentifier = std::get_if(&funCall.functionName)) { - FunctionCall& funCall = std::get(_expression); - YulString const functionName{resolveFunctionName(funCall.functionName, m_dialect)}; - if (!m_inlinableFunctions.count(functionName)) + auto const it = m_inlinableFunctions.find(functionNameIdentifier->name); + if (it == m_inlinableFunctions.end()) return; - FunctionDefinition const& fun = *m_inlinableFunctions.at(functionName); + FunctionDefinition const& fun = *it->second; std::map substitutions; for (size_t i = 0; i < funCall.arguments.size(); i++) diff --git a/libyul/optimiser/ExpressionSplitter.cpp b/libyul/optimiser/ExpressionSplitter.cpp index 649bd85834d2..47a3a0d9568c 100644 --- a/libyul/optimiser/ExpressionSplitter.cpp +++ b/libyul/optimiser/ExpressionSplitter.cpp @@ -35,9 +35,9 @@ using namespace solidity::yul; using namespace solidity::util; using namespace solidity::langutil; -ExpressionSplitter::ExpressionSplitter(Dialect const& _dialect, NameDispenser& _nameDispenser): +ExpressionSplitter::ExpressionSplitter(Dialect const& _dialect, LabelIDDispenser& _labelIDDispenser): m_dialect(_dialect), - m_nameDispenser(_nameDispenser) + m_labelIDDispenser(_labelIDDispenser) {} ExpressionSplitter::~ExpressionSplitter() = default; @@ -105,7 +105,7 @@ void ExpressionSplitter::outlineExpression(Expression& _expr) visit(_expr); langutil::DebugData::ConstPtr debugData = debugDataOf(_expr); - YulName var = m_nameDispenser.newName({}); + YulName const var = m_labelIDDispenser.newID(); m_statementsToPrefix.emplace_back(VariableDeclaration{ debugData, {{NameWithDebugData{debugData, var}}}, diff --git a/libyul/optimiser/ExpressionSplitter.h b/libyul/optimiser/ExpressionSplitter.h index 739916317765..2c41fc696e30 100644 --- a/libyul/optimiser/ExpressionSplitter.h +++ b/libyul/optimiser/ExpressionSplitter.h @@ -24,7 +24,7 @@ #include #include -#include +#include #include @@ -70,7 +70,7 @@ class ExpressionSplitter: public ASTModifier private: ExpressionSplitter( Dialect const& _dialect, - NameDispenser& _nameDispenser + LabelIDDispenser& _labelIDDispenser ); ~ExpressionSplitter() override; @@ -83,7 +83,7 @@ class ExpressionSplitter: public ASTModifier /// at the statement level. std::vector m_statementsToPrefix; Dialect const& m_dialect; - NameDispenser& m_nameDispenser; + LabelIDDispenser& m_labelIDDispenser; }; } diff --git a/libyul/optimiser/FullInliner.cpp b/libyul/optimiser/FullInliner.cpp index 894ada60962e..8cd22f5a0b41 100644 --- a/libyul/optimiser/FullInliner.cpp +++ b/libyul/optimiser/FullInliner.cpp @@ -28,7 +28,7 @@ #include #include #include -#include +#include #include #include #include @@ -51,7 +51,7 @@ void FullInliner::run(OptimiserStepContext& _context, Block& _ast) inliner.run(Pass::InlineRest); } -FullInliner::FullInliner(Block& _ast, NameDispenser& _dispenser, Dialect const& _dialect): +FullInliner::FullInliner(Block& _ast, LabelIDDispenser& _dispenser, Dialect const& _dialect): m_ast(_ast), m_recursiveFunctions(CallGraphGenerator::callGraph(_ast).recursiveFunctions()), m_nameDispenser(_dispenser), @@ -129,7 +129,7 @@ void FullInliner::run(Pass _pass) std::map FullInliner::callDepths() const { CallGraph cg = CallGraphGenerator::callGraph(m_ast); - cg.functionCalls.erase(""_yulname); + cg.functionCalls.erase(ASTLabelRegistry::emptyID()); // Remove calls to builtin functions. for (auto& call: cg.functionCalls) @@ -307,7 +307,7 @@ std::vector InlineModifier::performInline(Statement& _statement, Func // helper function to create a new variable that is supposed to model // an existing variable. auto newVariable = [&](NameWithDebugData const& _existingVariable, Expression* _value) { - YulName newName = m_nameDispenser.newName(_existingVariable.name); + YulName newName = m_nameDispenser.newID(_existingVariable.name); variableReplacements[_existingVariable.name] = newName; VariableDeclaration varDecl{_funCall.debugData, {{_funCall.debugData, newName}}, {}}; if (_value) @@ -359,7 +359,7 @@ std::vector InlineModifier::performInline(Statement& _statement, Func Statement BodyCopier::operator()(VariableDeclaration const& _varDecl) { for (auto const& var: _varDecl.variables) - m_variableReplacements[var.name] = m_nameDispenser.newName(var.name); + m_variableReplacements[var.name] = m_nameDispenser.newID(var.name); return ASTCopier::operator()(_varDecl); } diff --git a/libyul/optimiser/FullInliner.h b/libyul/optimiser/FullInliner.h index 4620194a4e51..7ca35b6ebd8d 100644 --- a/libyul/optimiser/FullInliner.h +++ b/libyul/optimiser/FullInliner.h @@ -24,7 +24,6 @@ #include #include -#include #include #include @@ -93,7 +92,7 @@ class FullInliner: public ASTModifier private: enum Pass { InlineTiny, InlineRest }; - FullInliner(Block& _ast, NameDispenser& _dispenser, Dialect const& _dialect); + FullInliner(Block& _ast, LabelIDDispenser& _dispenser, Dialect const& _dialect); void run(Pass _pass); /// @returns a map containing the maximum depths of a call chain starting at each @@ -120,7 +119,7 @@ class FullInliner: public ASTModifier /// Variables that are constants (used for inlining heuristic) std::set m_constants; std::map m_functionSizes; - NameDispenser& m_nameDispenser; + LabelIDDispenser& m_nameDispenser; Dialect const& m_dialect; }; @@ -131,7 +130,7 @@ class FullInliner: public ASTModifier class InlineModifier: public ASTModifier { public: - InlineModifier(FullInliner& _driver, NameDispenser& _nameDispenser, YulName _functionName, Dialect const& _dialect): + InlineModifier(FullInliner& _driver, LabelIDDispenser& _nameDispenser, YulName _functionName, Dialect const& _dialect): m_currentFunction(std::move(_functionName)), m_driver(_driver), m_nameDispenser(_nameDispenser), @@ -144,9 +143,9 @@ class InlineModifier: public ASTModifier std::optional> tryInlineStatement(Statement& _statement); std::vector performInline(Statement& _statement, FunctionCall& _funCall); - YulName m_currentFunction; + YulName m_currentFunction = ASTLabelRegistry::emptyID(); FullInliner& m_driver; - NameDispenser& m_nameDispenser; + LabelIDDispenser& m_nameDispenser; Dialect const& m_dialect; }; @@ -159,7 +158,7 @@ class BodyCopier: public ASTCopier { public: BodyCopier( - NameDispenser& _nameDispenser, + LabelIDDispenser& _nameDispenser, std::map _variableReplacements ): m_nameDispenser(_nameDispenser), @@ -173,7 +172,7 @@ class BodyCopier: public ASTCopier YulName translateIdentifier(YulName _name) override; - NameDispenser& m_nameDispenser; + LabelIDDispenser& m_nameDispenser; std::map m_variableReplacements; }; diff --git a/libyul/optimiser/FunctionSpecializer.cpp b/libyul/optimiser/FunctionSpecializer.cpp index cbbf14e8f84a..300c12ecdbcc 100644 --- a/libyul/optimiser/FunctionSpecializer.cpp +++ b/libyul/optimiser/FunctionSpecializer.cpp @@ -21,7 +21,7 @@ #include #include #include -#include +#include #include #include @@ -66,8 +66,8 @@ void FunctionSpecializer::operator()(FunctionCall& _f) if (ranges::any_of(arguments, [](auto& _a) { return _a.has_value(); })) { - YulName oldName = std::move(identifier.name); - auto newName = m_nameDispenser.newName(oldName); + YulName const oldName = identifier.name; + auto newName = m_nameDispenser.newID(oldName); m_oldToNewMap[oldName].emplace_back(std::make_pair(newName, arguments)); @@ -91,7 +91,7 @@ FunctionDefinition FunctionSpecializer::specialize( NameCollector{_f, NameCollector::OnlyVariables}.names(), [&](auto& _name) -> std::pair { - return std::make_pair(_name, m_nameDispenser.newName(_name)); + return std::make_pair(_name, m_nameDispenser.newID(_name)); }, std::map{} ); diff --git a/libyul/optimiser/FunctionSpecializer.h b/libyul/optimiser/FunctionSpecializer.h index 4df59b354c45..92e3cd6d5c1a 100644 --- a/libyul/optimiser/FunctionSpecializer.h +++ b/libyul/optimiser/FunctionSpecializer.h @@ -19,7 +19,6 @@ #pragma once #include -#include #include #include @@ -67,7 +66,7 @@ class FunctionSpecializer: public ASTModifier private: explicit FunctionSpecializer( std::set _recursiveFunctions, - NameDispenser& _nameDispenser + LabelIDDispenser& _nameDispenser ): m_recursiveFunctions(std::move(_recursiveFunctions)), m_nameDispenser(_nameDispenser) @@ -103,7 +102,7 @@ class FunctionSpecializer: public ASTModifier /// We skip specializing recursive functions. Need backtracking to properly deal with them. std::set const m_recursiveFunctions; - NameDispenser& m_nameDispenser; + LabelIDDispenser& m_nameDispenser; }; } diff --git a/libyul/optimiser/KnowledgeBase.cpp b/libyul/optimiser/KnowledgeBase.cpp index ceaa8f06b359..720cb59a8f4e 100644 --- a/libyul/optimiser/KnowledgeBase.cpp +++ b/libyul/optimiser/KnowledgeBase.cpp @@ -210,7 +210,7 @@ KnowledgeBase::VariableOffset KnowledgeBase::setOffset(YulName _variable, Variab m_offsets[_variable] = _value; // Constants are not tracked in m_groupMembers because // the "representative" can never be reset. - if (!_value.reference.empty()) + if (!ASTLabelRegistry::empty(_value.reference)) m_groupMembers[_value.reference].insert(_variable); return _value; } diff --git a/libyul/optimiser/KnowledgeBase.h b/libyul/optimiser/KnowledgeBase.h index 0852f8902592..8ae7f9abcff0 100644 --- a/libyul/optimiser/KnowledgeBase.h +++ b/libyul/optimiser/KnowledgeBase.h @@ -85,12 +85,12 @@ class KnowledgeBase */ struct VariableOffset { - YulName reference; + YulName reference{}; u256 offset; bool isAbsolute() const { - return reference.empty(); + return reference == ASTLabelRegistry::emptyID(); } std::optional absoluteValue() const diff --git a/libyul/optimiser/NameDisplacer.cpp b/libyul/optimiser/NameDisplacer.cpp index 7430c26c3046..aff3443631af 100644 --- a/libyul/optimiser/NameDisplacer.cpp +++ b/libyul/optimiser/NameDisplacer.cpp @@ -74,7 +74,7 @@ void NameDisplacer::checkAndReplaceNew(YulName& _name) { yulAssert(!m_translations.count(_name), ""); if (m_namesToFree.count(_name)) - _name = (m_translations[_name] = m_nameDispenser.newName(_name)); + _name = (m_translations[_name] = m_nameDispenser.newID(_name)); } void NameDisplacer::checkAndReplace(YulName& _name) const diff --git a/libyul/optimiser/NameDisplacer.h b/libyul/optimiser/NameDisplacer.h index cfe297d4d7a4..52e959d7cb7d 100644 --- a/libyul/optimiser/NameDisplacer.h +++ b/libyul/optimiser/NameDisplacer.h @@ -22,7 +22,7 @@ #pragma once #include -#include +#include #include #include @@ -43,15 +43,12 @@ class NameDisplacer: public ASTModifier { public: explicit NameDisplacer( - NameDispenser& _dispenser, + LabelIDDispenser& _dispenser, std::set const& _namesToFree ): m_nameDispenser(_dispenser), m_namesToFree(_namesToFree) - { - for (YulName n: _namesToFree) - m_nameDispenser.markUsed(n); - } + {} using ASTModifier::operator(); void operator()(Identifier& _identifier) override; @@ -68,7 +65,7 @@ class NameDisplacer: public ASTModifier /// Replace the identifier @a _name if it is in the translation map. void checkAndReplace(YulName& _name) const; - NameDispenser& m_nameDispenser; + LabelIDDispenser& m_nameDispenser; std::set const& m_namesToFree; std::map m_translations; }; diff --git a/libyul/optimiser/OptimiserStep.h b/libyul/optimiser/OptimiserStep.h index 7425a1906532..14ceb4d1d3e5 100644 --- a/libyul/optimiser/OptimiserStep.h +++ b/libyul/optimiser/OptimiserStep.h @@ -27,14 +27,14 @@ namespace solidity::yul { -class Dialect; struct Block; -class NameDispenser; +class Dialect; +class LabelIDDispenser; struct OptimiserStepContext { Dialect const& dialect; - NameDispenser& dispenser; + LabelIDDispenser& dispenser; std::set const& reservedIdentifiers; /// The value nullopt represents creation code std::optional expectedExecutionsPerDeployment; diff --git a/libyul/optimiser/SSATransform.cpp b/libyul/optimiser/SSATransform.cpp index 1d5270f8f497..c5093d3d7984 100644 --- a/libyul/optimiser/SSATransform.cpp +++ b/libyul/optimiser/SSATransform.cpp @@ -22,8 +22,8 @@ #include +#include #include -#include #include #include @@ -43,7 +43,7 @@ class IntroduceSSA: public ASTModifier { public: explicit IntroduceSSA( - NameDispenser& _nameDispenser, + LabelIDDispenser& _nameDispenser, std::set const& _variablesToReplace ): m_nameDispenser(_nameDispenser), @@ -53,7 +53,7 @@ class IntroduceSSA: public ASTModifier void operator()(Block& _block) override; private: - NameDispenser& m_nameDispenser; + LabelIDDispenser& m_nameDispenser; std::set const& m_variablesToReplace; }; @@ -85,8 +85,8 @@ void IntroduceSSA::operator()(Block& _block) NameWithDebugDataList newVariables; for (auto const& var: varDecl.variables) { - YulName oldName = var.name; - YulName newName = m_nameDispenser.newName(oldName); + YulName const oldName = var.name; + YulName const newName = m_nameDispenser.newID(oldName); newVariables.emplace_back(NameWithDebugData{debugData, newName}); statements.emplace_back(VariableDeclaration{ debugData, @@ -112,8 +112,8 @@ void IntroduceSSA::operator()(Block& _block) NameWithDebugDataList newVariables; for (auto const& var: assignment.variableNames) { - YulName oldName = var.name; - YulName newName = m_nameDispenser.newName(oldName); + YulName const oldName = var.name; + YulName const newName = m_nameDispenser.newID(oldName); newVariables.emplace_back(NameWithDebugData{debugData, newName}); statements.emplace_back(Assignment{ debugData, @@ -139,7 +139,7 @@ class IntroduceControlFlowSSA: public ASTModifier { public: explicit IntroduceControlFlowSSA( - NameDispenser& _nameDispenser, + LabelIDDispenser& _nameDispenser, std::set const& _variablesToReplace ): m_nameDispenser(_nameDispenser), @@ -152,7 +152,7 @@ class IntroduceControlFlowSSA: public ASTModifier void operator()(Block& _block) override; private: - NameDispenser& m_nameDispenser; + LabelIDDispenser& m_nameDispenser; std::set const& m_variablesToReplace; /// Variables (that are to be replaced) currently in scope. std::set m_variablesInScope; @@ -218,7 +218,7 @@ void IntroduceControlFlowSSA::operator()(Block& _block) std::vector toPrepend; for (YulName toReassign: m_variablesToReassign) { - YulName newName = m_nameDispenser.newName(toReassign); + YulName const newName = m_nameDispenser.newID(toReassign); toPrepend.emplace_back(VariableDeclaration{ debugDataOf(_s), {NameWithDebugData{debugDataOf(_s), newName}}, diff --git a/libyul/optimiser/StackCompressor.cpp b/libyul/optimiser/StackCompressor.cpp index 595e4b3ee800..2b9d127bfa49 100644 --- a/libyul/optimiser/StackCompressor.cpp +++ b/libyul/optimiser/StackCompressor.cpp @@ -27,6 +27,7 @@ #include #include #include +#include #include #include @@ -78,7 +79,7 @@ class RematCandidateSelector: public DataFlowAnalyzer using DataFlowAnalyzer::operator(); void operator()(FunctionDefinition& _function) override { - yulAssert(m_currentFunctionName.empty()); + yulAssert(ASTLabelRegistry::empty(m_currentFunctionName)); m_currentFunctionName = _function.name; DataFlowAnalyzer::operator()(_function); m_currentFunctionName = {}; @@ -264,9 +265,11 @@ std::tuple StackCompressor::run( yul::AsmAnalysisInfo analysisInfo = yul::AsmAnalyzer::analyzeStrictAssertCorrect( *_object.dialect(), astRoot, + _object.code()->labels(), _object.summarizeStructure() ); - std::unique_ptr cfg = ControlFlowGraphBuilder::build(analysisInfo, *_object.dialect(), astRoot); + LabelIDDispenser nameDispenser{_object.code()->labels()}; + std::unique_ptr cfg = ControlFlowGraphBuilder::build(analysisInfo, nameDispenser, *_object.dialect(), astRoot); yulAssert(evmDialect); eliminateVariablesOptimizedCodegen( *_object.dialect(), @@ -280,7 +283,7 @@ std::tuple StackCompressor::run( for (size_t iterations = 0; iterations < _maxIterations; iterations++) { Object object(_object); - object.setCode(std::make_shared(*_object.dialect(), ASTLabelRegistry{}, std::get(ASTCopier{}(astRoot)))); + object.setCode(std::make_shared(*_object.dialect(), _object.code()->labels(), std::get(ASTCopier{}(astRoot)))); std::map stackSurplus = CompilabilityChecker(object, _optimizeStackAllocation).stackDeficit; if (stackSurplus.empty()) return std::make_tuple(true, std::move(astRoot)); diff --git a/libyul/optimiser/StackLimitEvader.cpp b/libyul/optimiser/StackLimitEvader.cpp index f70bc0c1d2a7..b632a4696b1c 100644 --- a/libyul/optimiser/StackLimitEvader.cpp +++ b/libyul/optimiser/StackLimitEvader.cpp @@ -19,7 +19,6 @@ #include #include #include -#include #include #include #include @@ -91,7 +90,7 @@ struct MemoryOffsetAllocator for (YulName variable: *unreachables) // The empty case is a function with too many arguments or return values, // which was already handled above. - if (!variable.empty() && !slotAllocations.count(variable)) + if (!ASTLabelRegistry::empty(variable) && !slotAllocations.contains(variable)) slotAllocations[variable] = requiredSlots++; } @@ -142,9 +141,10 @@ Block StackLimitEvader::run( yul::AsmAnalysisInfo analysisInfo = yul::AsmAnalyzer::analyzeStrictAssertCorrect( *evmDialect, astRoot, + _object.code()->labels(), _object.summarizeStructure() ); - std::unique_ptr cfg = ControlFlowGraphBuilder::build(analysisInfo, *evmDialect, astRoot); + std::unique_ptr cfg = ControlFlowGraphBuilder::build(analysisInfo, _context.dispenser, *evmDialect, astRoot); run(_context, astRoot, StackLayoutGenerator::reportStackTooDeep(*cfg, *evmDialect)); } else diff --git a/libyul/optimiser/StackToMemoryMover.cpp b/libyul/optimiser/StackToMemoryMover.cpp index 15df64b3f252..3285d0ceae4c 100644 --- a/libyul/optimiser/StackToMemoryMover.cpp +++ b/libyul/optimiser/StackToMemoryMover.cpp @@ -16,7 +16,7 @@ */ #include #include -#include +#include #include #include @@ -149,7 +149,7 @@ void StackToMemoryMover::operator()(FunctionDefinition& _functionDefinition) std::not_fn(m_memoryOffsetTracker) ) | ranges::to; // Generate new function without return variable and with only the non-moved parameters. - YulName newFunctionName = m_context.dispenser.newName(_functionDefinition.name); + YulName newFunctionName = m_context.dispenser.newID(_functionDefinition.name); m_newFunctionDefinitions.emplace_back(FunctionDefinition{ _functionDefinition.debugData, newFunctionName, @@ -160,7 +160,7 @@ void StackToMemoryMover::operator()(FunctionDefinition& _functionDefinition) // Generate new names for the arguments to maintain disambiguation. std::map newArgumentNames; for (NameWithDebugData const& _var: stackParameters) - newArgumentNames[_var.name] = m_context.dispenser.newName(_var.name); + newArgumentNames[_var.name] = m_context.dispenser.newID(_var.name); for (auto& parameter: _functionDefinition.parameters) parameter.name = util::valueOrDefault(newArgumentNames, parameter.name, parameter.name); // Replace original function by a call to the new function and an assignment to the return variable from memory. @@ -257,7 +257,7 @@ void StackToMemoryMover::operator()(Block& _block) rhs = std::make_unique(generateMemoryLoad(m_context.dialect, debugData, *rhsSlot)); else { - YulName tempVarName = m_nameDispenser.newName(lhsVar.name); + YulName tempVarName = m_nameDispenser.newID(lhsVar.name); tempDecl.variables.emplace_back(NameWithDebugData{lhsVar.debugData, tempVarName}); rhs = std::make_unique(Identifier{debugData, tempVarName}); } diff --git a/libyul/optimiser/StackToMemoryMover.h b/libyul/optimiser/StackToMemoryMover.h index 89f11c1fe4f8..c31a100632f5 100644 --- a/libyul/optimiser/StackToMemoryMover.h +++ b/libyul/optimiser/StackToMemoryMover.h @@ -192,7 +192,7 @@ class StackToMemoryMover: ASTModifier OptimiserStepContext& m_context; VariableMemoryOffsetTracker const& m_memoryOffsetTracker; - NameDispenser& m_nameDispenser; + LabelIDDispenser& m_nameDispenser; /// Map from function names to the return variables of the function with that name. std::map> m_functionReturnVariables; /// List of functions generated while running this step that are to be appended to the code in the end. diff --git a/libyul/optimiser/Suite.cpp b/libyul/optimiser/Suite.cpp index b53647aeb3cc..f0fecad59f87 100644 --- a/libyul/optimiser/Suite.cpp +++ b/libyul/optimiser/Suite.cpp @@ -95,18 +95,27 @@ void OptimiserSuite::run( std::string_view _optimisationSequence, std::string_view _optimisationCleanupSequence, std::optional _expectedExecutionsPerDeployment, - std::set const& _externallyUsedIdentifiers + std::set const& _externallyUsedIdentifiers ) { yulAssert(_object.dialect()); auto const& dialect = *_object.dialect(); EVMDialect const* evmDialect = dynamic_cast(_object.dialect()); + auto const originalLabels = _object.code()->labels(); + + std::set reservedIdentifiers = _externallyUsedIdentifiers; + std::set reservedNames; + for (auto const& identifier: reservedIdentifiers) + if (auto maybeNodeId = originalLabels.findIDForLabel(identifier)) + reservedNames.insert(*maybeNodeId); + + LabelIDDispenser dispenser{originalLabels, reservedIdentifiers}; + bool usesOptimizedCodeGenerator = _optimizeStackAllocation && evmDialect && evmDialect->evmVersion().canOverchargeGasForCall() && evmDialect->providesObjectAccess(); - std::set reservedIdentifiers = _externallyUsedIdentifiers; Block astRoot; { @@ -114,12 +123,12 @@ void OptimiserSuite::run( astRoot = std::get(Disambiguator( dialect, *_object.analysisInfo, - reservedIdentifiers + dispenser, + reservedNames )(_object.code()->root())); } - NameDispenser dispenser{dialect, astRoot, reservedIdentifiers}; - OptimiserStepContext context{dialect, dispenser, reservedIdentifiers, _expectedExecutionsPerDeployment}; + OptimiserStepContext context{dialect, dispenser, reservedNames, _expectedExecutionsPerDeployment}; OptimiserSuite suite(context, Debug::None); @@ -139,7 +148,7 @@ void OptimiserSuite::run( if (!usesOptimizedCodeGenerator) { PROFILER_PROBE("StackCompressor", probe); - _object.setCode(std::make_shared(dialect, ASTLabelRegistry{}, std::move(astRoot))); + _object.setCode(std::make_shared(dialect, dispenser, std::move(astRoot))); astRoot = std::get<1>(StackCompressor::run( _object, _optimizeStackAllocation, @@ -165,41 +174,33 @@ void OptimiserSuite::run( { if (!evmDialect->eofVersion().has_value()) { - PROFILER_PROBE("StackCompressor", probe); - _object.setCode(std::make_shared(dialect, ASTLabelRegistry{}, std::move(astRoot))); - astRoot = std::get<1>(StackCompressor::run( - _object, - _optimizeStackAllocation, - stackCompressorMaxIterations - )); - } - if (evmDialect->providesObjectAccess()) - { - PROFILER_PROBE("StackLimitEvader", probe); - _object.setCode(std::make_shared(dialect, ASTLabelRegistry{}, std::move(astRoot))); - astRoot = StackLimitEvader::run(suite.m_context, _object); + { + PROFILER_PROBE("StackCompressor", probe); + _object.setCode(std::make_shared(dialect, dispenser, std::move(astRoot))); + astRoot = std::get<1>(StackCompressor::run( + _object, + _optimizeStackAllocation, + stackCompressorMaxIterations + )); + } + if (evmDialect->providesObjectAccess()) + { + PROFILER_PROBE("StackLimitEvader", probe); + _object.setCode(std::make_shared(dialect, dispenser, std::move(astRoot))); + astRoot = StackLimitEvader::run(suite.m_context, _object); + } } } else if (evmDialect->providesObjectAccess() && _optimizeStackAllocation) { PROFILER_PROBE("StackLimitEvader", probe); yulAssert(!evmDialect->eofVersion().has_value(), ""); - _object.setCode(std::make_shared(dialect, ASTLabelRegistry{}, std::move(astRoot))); + _object.setCode(std::make_shared(dialect, dispenser, std::move(astRoot))); astRoot = StackLimitEvader::run(suite.m_context, _object); } } - dispenser.reset(astRoot); - { - PROFILER_PROBE("NameSimplifier", probe); - NameSimplifier::run(suite.m_context, astRoot); - } - { - PROFILER_PROBE("VarNameCleaner", probe); - VarNameCleaner::run(suite.m_context, astRoot); - } - - _object.setCode(std::make_shared(dialect, ASTLabelRegistry{}, std::move(astRoot))); + _object.setCode(std::make_shared(dialect, dispenser, std::move(astRoot))); _object.analysisInfo = std::make_shared(AsmAnalyzer::analyzeStrictAssertCorrect(_object)); } @@ -487,7 +488,7 @@ void OptimiserSuite::runSequence(std::vector const& _steps, Block& else { std::cout << "== Running " << step << " changed the AST." << std::endl; - std::cout << AsmPrinter{m_context.dialect}(_ast) << std::endl; + std::cout << AsmPrinter{m_context.dialect, m_context.dispenser.generateNewLabels(_ast, m_context.dialect)}(_ast) << std::endl; copy = std::make_unique(std::get(ASTCopier{}(_ast))); } } diff --git a/libyul/optimiser/Suite.h b/libyul/optimiser/Suite.h index b0c3314089b7..39f33e61c065 100644 --- a/libyul/optimiser/Suite.h +++ b/libyul/optimiser/Suite.h @@ -24,7 +24,6 @@ #include #include #include -#include #include #include @@ -69,7 +68,7 @@ class OptimiserSuite std::string_view _optimisationSequence, std::string_view _optimisationCleanupSequence, std::optional _expectedExecutionsPerDeployment, - std::set const& _externallyUsedIdentifiers = {} + std::set const& _externallyUsedIdentifiers = {} ); /// Ensures that specified sequence of step abbreviations is well-formed and can be executed. diff --git a/libyul/optimiser/SyntacticalEquality.h b/libyul/optimiser/SyntacticalEquality.h index 0db52c9690df..0bdffce927dd 100644 --- a/libyul/optimiser/SyntacticalEquality.h +++ b/libyul/optimiser/SyntacticalEquality.h @@ -25,6 +25,7 @@ #include #include +#include #include namespace solidity::yul diff --git a/libyul/optimiser/UnusedFunctionsCommon.cpp b/libyul/optimiser/UnusedFunctionsCommon.cpp index a6333a786a5e..0045b1a6b874 100644 --- a/libyul/optimiser/UnusedFunctionsCommon.cpp +++ b/libyul/optimiser/UnusedFunctionsCommon.cpp @@ -18,6 +18,7 @@ #include +#include #include #include @@ -32,14 +33,14 @@ FunctionDefinition unusedFunctionsCommon::createLinkingFunction( std::pair, std::vector> const& _usedParametersAndReturns, YulName const& _originalFunctionName, YulName const& _linkingFunctionName, - NameDispenser& _nameDispenser + LabelIDDispenser& _nameDispenser ) { auto generateTypedName = [&](NameWithDebugData t) { return NameWithDebugData{ t.debugData, - _nameDispenser.newName(t.name) + _nameDispenser.newID(t.name) }; }; diff --git a/libyul/optimiser/UnusedFunctionsCommon.h b/libyul/optimiser/UnusedFunctionsCommon.h index 5aa231b1e410..6aa1ff78dfe9 100644 --- a/libyul/optimiser/UnusedFunctionsCommon.h +++ b/libyul/optimiser/UnusedFunctionsCommon.h @@ -18,7 +18,6 @@ #pragma once #include -#include #include @@ -54,7 +53,7 @@ FunctionDefinition createLinkingFunction( std::pair, std::vector> const& _usedParametersAndReturns, YulName const& _originalFunctionName, YulName const& _linkingFunctionName, - NameDispenser& _nameDispenser + LabelIDDispenser& _nameDispenser ); } From b4ae0ceda287af712fa82f12dec79ff421c6c6b5 Mon Sep 17 00:00:00 2001 From: clonker <1685266+clonker@users.noreply.github.com> Date: Wed, 26 Mar 2025 08:50:33 +0100 Subject: [PATCH 07/17] Inline assembly uses numerical label IDs --- libsolidity/analysis/PostTypeChecker.cpp | 7 ++-- libsolidity/analysis/ReferencesResolver.cpp | 30 ++++++++------- libsolidity/analysis/ReferencesResolver.h | 1 + libsolidity/analysis/TypeChecker.cpp | 1 + libsolidity/codegen/CompilerContext.cpp | 38 +++++++++---------- libsolidity/codegen/CompilerContext.h | 2 +- libsolidity/codegen/ContractCompiler.cpp | 4 +- .../codegen/ir/IRGeneratorForStatements.cpp | 28 ++++++++++---- .../experimental/analysis/TypeInference.cpp | 1 + .../codegen/IRGeneratorForStatements.cpp | 23 ++++++++--- libsolidity/lsp/RenameSymbol.cpp | 4 +- 11 files changed, 85 insertions(+), 54 deletions(-) diff --git a/libsolidity/analysis/PostTypeChecker.cpp b/libsolidity/analysis/PostTypeChecker.cpp index 49c5fa4a414d..b14ef13ef339 100644 --- a/libsolidity/analysis/PostTypeChecker.cpp +++ b/libsolidity/analysis/PostTypeChecker.cpp @@ -462,7 +462,7 @@ struct ReservedErrorSelector: public PostTypeChecker::Checker class YulLValueChecker : public solidity::yul::ASTWalker { public: - YulLValueChecker(ASTString const& _identifierName): m_identifierName(_identifierName) {} + YulLValueChecker(ASTString const& _identifierName, yul::ASTLabelRegistry const& _yulLabels): m_identifierName(_identifierName), m_yulLabels(_yulLabels) {} bool willBeWrittenTo() const { return m_willBeWrittenTo; } using solidity::yul::ASTWalker::operator(); void operator()(solidity::yul::Assignment const& _assignment) override @@ -472,12 +472,13 @@ class YulLValueChecker : public solidity::yul::ASTWalker if (ranges::any_of( _assignment.variableNames, - [&](auto const& yulIdentifier) { return yulIdentifier.name.str() == m_identifierName; } + [&](auto const& yulIdentifier) { return m_yulLabels[yulIdentifier.name] == m_identifierName; } )) m_willBeWrittenTo = true; } private: ASTString const& m_identifierName; + yul::ASTLabelRegistry const& m_yulLabels; bool m_willBeWrittenTo = false; }; @@ -505,7 +506,7 @@ class LValueChecker: public ASTConstVisitor if (m_willBeWrittenTo) return; - YulLValueChecker yulChecker{m_declaration->name()}; + YulLValueChecker yulChecker{m_declaration->name(), _inlineAssembly.operations().labels()}; yulChecker(_inlineAssembly.operations().root()); m_willBeWrittenTo = yulChecker.willBeWrittenTo(); } diff --git a/libsolidity/analysis/ReferencesResolver.cpp b/libsolidity/analysis/ReferencesResolver.cpp index cfbdec91ab52..3c5e3c88a7b9 100644 --- a/libsolidity/analysis/ReferencesResolver.cpp +++ b/libsolidity/analysis/ReferencesResolver.cpp @@ -235,10 +235,9 @@ bool ReferencesResolver::visit(UsingForDirective const& _usingFor) bool ReferencesResolver::visit(InlineAssembly const& _inlineAssembly) { - m_yulAnnotation = &_inlineAssembly.annotation(); + ScopedSaveAndRestore saveAnnotation{m_yulAnnotation, &_inlineAssembly.annotation()}; + ScopedSaveAndRestore saveYulLabels{m_yulLabels, &_inlineAssembly.operations().labels()}; (*this)(_inlineAssembly.operations().root()); - m_yulAnnotation = nullptr; - return false; } @@ -291,7 +290,7 @@ void ReferencesResolver::operator()(yul::Identifier const& _identifier) if (m_resolver.experimentalSolidity()) { std::vector splitName; - boost::split(splitName, _identifier.name.str(), boost::is_any_of(".")); + boost::split(splitName, (*m_yulLabels)[_identifier.name], boost::is_any_of(".")); solAssert(!splitName.empty()); if (splitName.size() > 2) { @@ -332,22 +331,23 @@ void ReferencesResolver::operator()(yul::Identifier const& _identifier) static std::set suffixes{"slot", "offset", "length", "address", "selector"}; std::string suffix; for (std::string const& s: suffixes) - if (boost::algorithm::ends_with(_identifier.name.str(), "." + s)) + if (boost::algorithm::ends_with((*m_yulLabels)[_identifier.name], "." + s)) suffix = s; // Could also use `pathFromCurrentScope`, split by '.'. // If we do that, suffix should only be set for when it has a special // meaning, not for normal identifierPaths. - auto declarations = m_resolver.nameFromCurrentScope(_identifier.name.str()); + auto declarations = m_resolver.nameFromCurrentScope(std::string{(*m_yulLabels)[_identifier.name]}); if (!suffix.empty()) { // special mode to access storage variables if (!declarations.empty()) // the special identifier exists itself, we should not allow that. return; - std::string realName = _identifier.name.str().substr(0, _identifier.name.str().size() - suffix.size() - 1); + std::string_view const identifierLabel = (*m_yulLabels)[_identifier.name]; + std::string_view const realName = identifierLabel.substr(0, identifierLabel.size() - suffix.size() - 1); solAssert(!realName.empty(), "Empty name."); - declarations = m_resolver.nameFromCurrentScope(realName); + declarations = m_resolver.nameFromCurrentScope(std::string{realName}); if (!declarations.empty()) // To support proper path resolution, we have to use pathFromCurrentScope. solAssert(!util::contains(realName, '.'), ""); @@ -363,9 +363,10 @@ void ReferencesResolver::operator()(yul::Identifier const& _identifier) } else if (declarations.size() == 0) { + std::string_view const identifierLabel = (*m_yulLabels)[_identifier.name]; if ( - boost::algorithm::ends_with(_identifier.name.str(), "_slot") || - boost::algorithm::ends_with(_identifier.name.str(), "_offset") + boost::algorithm::ends_with(identifierLabel, "_slot") || + boost::algorithm::ends_with(identifierLabel, "_offset") ) m_errorReporter.declarationError( 9467_error, @@ -397,7 +398,7 @@ void ReferencesResolver::operator()(yul::VariableDeclaration const& _varDecl) validateYulIdentifierName(identifier.name, nativeLocationOf(identifier)); if ( - auto declarations = m_resolver.nameFromCurrentScope(identifier.name.str()); + auto declarations = m_resolver.nameFromCurrentScope(std::string{(*m_yulLabels)[identifier.name]}); !declarations.empty() ) { @@ -490,17 +491,18 @@ void ReferencesResolver::resolveInheritDoc(StructuredDocumentation const& _docum void ReferencesResolver::validateYulIdentifierName(yul::YulName _name, SourceLocation const& _location) { - if (util::contains(_name.str(), '.')) + std::string_view const label = (*m_yulLabels)[_name]; + if (util::contains(label, '.')) m_errorReporter.declarationError( 3927_error, _location, "User-defined identifiers in inline assembly cannot contain '.'." ); - if (std::set{"this", "super", "_"}.count(_name.str())) + if (std::set{"this", "super", "_"}.contains(label)) m_errorReporter.declarationError( 4113_error, _location, - "The identifier name \"" + _name.str() + "\" is reserved." + fmt::format("The identifier name \"{}\" is reserved.", label) ); } diff --git a/libsolidity/analysis/ReferencesResolver.h b/libsolidity/analysis/ReferencesResolver.h index 0b7f9d37329f..71ee0af44763 100644 --- a/libsolidity/analysis/ReferencesResolver.h +++ b/libsolidity/analysis/ReferencesResolver.h @@ -104,6 +104,7 @@ class ReferencesResolver: private ASTConstVisitor, private yul::ASTWalker bool const m_resolveInsideCode; InlineAssemblyAnnotation* m_yulAnnotation = nullptr; + yul::ASTLabelRegistry const* m_yulLabels = nullptr; bool m_yulInsideFunction = false; bool m_typeContext = false; }; diff --git a/libsolidity/analysis/TypeChecker.cpp b/libsolidity/analysis/TypeChecker.cpp index e56ee157d94d..718acdccb346 100644 --- a/libsolidity/analysis/TypeChecker.cpp +++ b/libsolidity/analysis/TypeChecker.cpp @@ -941,6 +941,7 @@ bool TypeChecker::visit(InlineAssembly const& _inlineAssembly) *_inlineAssembly.annotation().analysisInfo, m_errorReporter, _inlineAssembly.dialect(), + _inlineAssembly.operations().labels(), identifierAccess ); if (!analyzer.analyze(_inlineAssembly.operations().root())) diff --git a/libsolidity/codegen/CompilerContext.cpp b/libsolidity/codegen/CompilerContext.cpp index 4d53b9c234b9..2ba0353dffba 100644 --- a/libsolidity/codegen/CompilerContext.cpp +++ b/libsolidity/codegen/CompilerContext.cpp @@ -49,6 +49,8 @@ #include #include +#include + #include // Change to "define" to output all intermediate code @@ -388,13 +390,18 @@ void CompilerContext::appendInlineAssembly( { unsigned startStackHeight = stackHeight(); - std::set externallyUsedIdentifiers; - for (auto const& fun: _externallyUsedFunctions) - externallyUsedIdentifiers.insert(yul::YulName(fun)); - for (auto const& var: _localVariables) - externallyUsedIdentifiers.insert(yul::YulName(var)); - + std::set const externallyUsedIdentifiers = _externallyUsedFunctions + _localVariables; yul::ExternalIdentifierAccess identifierAccess; + + ErrorList errors; + ErrorReporter errorReporter(errors); + langutil::CharStream charStream(_assembly, _sourceName); + yul::EVMDialect const& dialect = yul::EVMDialect::strictAssemblyForEVM(m_evmVersion, std::nullopt); + std::optional locationOverride; + if (!_system) + locationOverride = m_asm->currentSourceLocation(); + std::shared_ptr parserResult + = yul::Parser(errorReporter, dialect, std::move(locationOverride)).parse(charStream); identifierAccess.resolve = [&]( yul::Identifier const& _identifier, yul::IdentifierContext, @@ -403,7 +410,7 @@ void CompilerContext::appendInlineAssembly( { if (_insideFunction) return false; - return util::contains(_localVariables, _identifier.name.str()); + return util::contains(_localVariables, parserResult->labelOf(_identifier.name)); }; identifierAccess.generateCode = [&]( yul::Identifier const& _identifier, @@ -412,7 +419,7 @@ void CompilerContext::appendInlineAssembly( ) { solAssert(_context == yul::IdentifierContext::RValue || _context == yul::IdentifierContext::LValue, ""); - auto it = std::find(_localVariables.begin(), _localVariables.end(), _identifier.name.str()); + auto const it = ranges::find(_localVariables, parserResult->labelOf(_identifier.name)); solAssert(it != _localVariables.end(), ""); auto stackDepth = static_cast(distance(it, _localVariables.end())); size_t stackDiff = static_cast(_assembly.stackHeight()) - startStackHeight + stackDepth; @@ -433,16 +440,6 @@ void CompilerContext::appendInlineAssembly( } }; - ErrorList errors; - ErrorReporter errorReporter(errors); - langutil::CharStream charStream(_assembly, _sourceName); - yul::EVMDialect const& dialect = yul::EVMDialect::strictAssemblyForEVM(m_evmVersion, std::nullopt); - std::optional locationOverride; - if (!_system) - locationOverride = m_asm->currentSourceLocation(); - std::shared_ptr parserResult = - yul::Parser(errorReporter, dialect, std::move(locationOverride)) - .parse(charStream); #ifdef SOL_OUTPUT_ASM std::cout << yul::AsmPrinter::format(*parserResult) << std::endl; #endif @@ -471,6 +468,7 @@ void CompilerContext::appendInlineAssembly( analysisInfo, errorReporter, dialect, + parserResult->labels(), identifierAccess.resolve ).analyze(parserResult->root()); if (!parserResult || errorReporter.hasErrorsWarningsOrInfos() || !analyzerResult) @@ -517,7 +515,7 @@ void CompilerContext::appendInlineAssembly( solAssert(!errorReporter.hasErrorsWarningsOrInfos(), "Failed to analyze inline assembly block."); yul::CodeGenerator::assemble( - toBeAssembledAST->root(), + *toBeAssembledAST, analysisInfo, *m_asm, m_evmVersion, @@ -532,7 +530,7 @@ void CompilerContext::appendInlineAssembly( } -void CompilerContext::optimizeYul(yul::Object& _object, OptimiserSettings const& _optimiserSettings, std::set const& _externalIdentifiers) +void CompilerContext::optimizeYul(yul::Object& _object, OptimiserSettings const& _optimiserSettings, std::set const& _externalIdentifiers) { yulAssert(_object.dialect()); auto const* evmDialect = dynamic_cast(_object.dialect()); diff --git a/libsolidity/codegen/CompilerContext.h b/libsolidity/codegen/CompilerContext.h index e8c4e9bc77f7..2dffad3bac17 100644 --- a/libsolidity/codegen/CompilerContext.h +++ b/libsolidity/codegen/CompilerContext.h @@ -278,7 +278,7 @@ class CompilerContext /// Otherwise returns "revert(0, 0)". std::string revertReasonIfDebug(std::string const& _message = ""); - void optimizeYul(yul::Object& _object, OptimiserSettings const& _optimiserSetting, std::set const& _externalIdentifiers = {}); + void optimizeYul(yul::Object& _object, OptimiserSettings const& _optimiserSetting, std::set const& _externalIdentifiers = {}); /// Appends arbitrary data to the end of the bytecode. void appendToAuxiliaryData(bytes const& _data) { m_asm->appendToAuxiliaryData(_data); } diff --git a/libsolidity/codegen/ContractCompiler.cpp b/libsolidity/codegen/ContractCompiler.cpp index 6ad824a47098..d1bfaaaf2fa6 100644 --- a/libsolidity/codegen/ContractCompiler.cpp +++ b/libsolidity/codegen/ContractCompiler.cpp @@ -944,7 +944,7 @@ bool ContractCompiler::visit(InlineAssembly const& _inlineAssembly) solAssert(dialect, ""); // Create a modifiable copy of the code and analysis - object.setCode(std::make_shared(_inlineAssembly.dialect(), yul::ASTLabelRegistry{}, yul::ASTCopier().translate(code->root()))); + object.setCode(std::make_shared(_inlineAssembly.dialect(), code->labels(), yul::ASTCopier().translate(code->root()))); object.analysisInfo = std::make_shared(yul::AsmAnalyzer::analyzeStrictAssertCorrect(object)); m_context.optimizeYul(object, m_optimiserSettings); @@ -954,7 +954,7 @@ bool ContractCompiler::visit(InlineAssembly const& _inlineAssembly) } yul::CodeGenerator::assemble( - code->root(), + *code, *analysisInfo, *m_context.assemblyPtr(), m_context.evmVersion(), diff --git a/libsolidity/codegen/ir/IRGeneratorForStatements.cpp b/libsolidity/codegen/ir/IRGeneratorForStatements.cpp index 5902cfef68b6..252558d13b24 100644 --- a/libsolidity/codegen/ir/IRGeneratorForStatements.cpp +++ b/libsolidity/codegen/ir/IRGeneratorForStatements.cpp @@ -63,8 +63,18 @@ struct CopyTranslate: public yul::ASTCopier { using ExternalRefsMap = std::map; - CopyTranslate(IRGenerationContext& _context, ExternalRefsMap const& _references): - m_context(_context), m_references(_references) {} + CopyTranslate( + yul::ASTLabelRegistry const& _originalLabels, + yul::ASTLabelRegistryBuilder& _labelBuilder, + IRGenerationContext& _context, + ExternalRefsMap const& _references + ): + m_originalLabels(_originalLabels), + m_labelBuilder(_labelBuilder), + m_context(_context), + m_references(_references) + { + } using ASTCopier::operator(); @@ -84,7 +94,7 @@ struct CopyTranslate: public yul::ASTCopier // from the Yul dialect we are compiling to. By only translating `YulName`s which correspond to Identifiers, // we are implicitly excluding builtins together with the assumption, that numerical builtin handles // stay identical. Special care has to be taken, that these numerical handles stay consistent. - return yul::YulName{"usr$" + _name.str()}; + return m_labelBuilder.define(fmt::format("usr${}", m_originalLabels[_name])); } yul::Identifier translate(yul::Identifier const& _identifier) override @@ -203,9 +213,11 @@ struct CopyTranslate: public yul::ASTCopier if (isDigit(value.front())) return yul::Literal{_identifier.debugData, yul::LiteralKind::Number, yul::valueOfNumberLiteral(value)}; else - return yul::Identifier{_identifier.debugData, yul::YulName{value}}; + return yul::Identifier{_identifier.debugData, m_labelBuilder.define(value)}; } + yul::ASTLabelRegistry const& m_originalLabels; + yul::ASTLabelRegistryBuilder& m_labelBuilder; IRGenerationContext& m_context; ExternalRefsMap const& m_references; }; @@ -2289,13 +2301,15 @@ bool IRGeneratorForStatements::visit(InlineAssembly const& _inlineAsm) setLocation(_inlineAsm); if (*_inlineAsm.annotation().hasMemoryEffects && !_inlineAsm.annotation().markedMemorySafe) m_context.setMemoryUnsafeInlineAssemblySeen(); - CopyTranslate bodyCopier{m_context, _inlineAsm.annotation().externalReferences}; - + auto const& originalLabels = _inlineAsm.operations().labels(); + yul::ASTLabelRegistryBuilder labelBuilder{originalLabels}; + CopyTranslate bodyCopier{originalLabels, labelBuilder, m_context, _inlineAsm.annotation().externalReferences}; yul::Statement modified = bodyCopier(_inlineAsm.operations().root()); + auto const modifiedLabels = labelBuilder.build(); solAssert(std::holds_alternative(modified)); - appendCode() << yul::AsmPrinter(_inlineAsm.dialect())(std::get(modified)) << "\n"; + appendCode() << yul::AsmPrinter(_inlineAsm.dialect(), modifiedLabels)(std::get(modified)) << "\n"; return false; } diff --git a/libsolidity/experimental/analysis/TypeInference.cpp b/libsolidity/experimental/analysis/TypeInference.cpp index 19f019c86c4e..ef5a6e414c52 100644 --- a/libsolidity/experimental/analysis/TypeInference.cpp +++ b/libsolidity/experimental/analysis/TypeInference.cpp @@ -300,6 +300,7 @@ bool TypeInference::visit(InlineAssembly const& _inlineAssembly) *_inlineAssembly.annotation().analysisInfo, m_errorReporter, _inlineAssembly.dialect(), + _inlineAssembly.operations().labels(), identifierAccess ); if (!analyzer.analyze(_inlineAssembly.operations().root())) diff --git a/libsolidity/experimental/codegen/IRGeneratorForStatements.cpp b/libsolidity/experimental/codegen/IRGeneratorForStatements.cpp index 14aef1107dd3..775b0c9e660e 100644 --- a/libsolidity/experimental/codegen/IRGeneratorForStatements.cpp +++ b/libsolidity/experimental/codegen/IRGeneratorForStatements.cpp @@ -54,8 +54,16 @@ struct CopyTranslate: public yul::ASTCopier { CopyTranslate( IRGenerationContext const& _context, + yul::ASTLabelRegistry const& _originalLabels, + yul::ASTLabelRegistryBuilder& _labelsBuilder, std::map _references - ): m_context(_context), m_references(std::move(_references)) {} + ): + m_context(_context), + m_originalLabels(_originalLabels), + m_labelsBuilder(_labelsBuilder), + m_references(std::move(_references)) + { + } using ASTCopier::operator(); @@ -71,7 +79,7 @@ struct CopyTranslate: public yul::ASTCopier yul::YulName translateIdentifier(yul::YulName _name) override { - return yul::YulName{"usr$" + _name.str()}; + return m_labelsBuilder.define(fmt::format("usr${}", m_originalLabels[_name])); } yul::Identifier translate(yul::Identifier const& _identifier) override @@ -98,10 +106,12 @@ struct CopyTranslate: public yul::ASTCopier solAssert(type); solAssert(m_context.env->typeEquals(*type, m_context.analysis.typeSystem().type(PrimitiveType::Word, {}))); std::string value = IRNames::localVariable(*varDecl); - return yul::Identifier{_identifier.debugData, yul::YulName{value}}; + return yul::Identifier{_identifier.debugData, m_labelsBuilder.define(value)}; } IRGenerationContext const& m_context; + yul::ASTLabelRegistry const& m_originalLabels; + yul::ASTLabelRegistryBuilder& m_labelsBuilder; std::map m_references; }; @@ -124,10 +134,13 @@ bool IRGeneratorForStatements::visit(TupleExpression const& _tupleExpression) bool IRGeneratorForStatements::visit(InlineAssembly const& _assembly) { - CopyTranslate bodyCopier{m_context, _assembly.annotation().externalReferences}; + auto const& originalLabels = _assembly.operations().labels(); + yul::ASTLabelRegistryBuilder labelBuilder{originalLabels}; + CopyTranslate bodyCopier{m_context, originalLabels, labelBuilder, _assembly.annotation().externalReferences}; yul::Statement modified = bodyCopier(_assembly.operations().root()); + auto const modifiedLabels = labelBuilder.build(); solAssert(std::holds_alternative(modified)); - m_code << yul::AsmPrinter(_assembly.dialect())(std::get(modified)) << "\n"; + m_code << yul::AsmPrinter(_assembly.dialect(), modifiedLabels)(std::get(modified)) << "\n"; return false; } diff --git a/libsolidity/lsp/RenameSymbol.cpp b/libsolidity/lsp/RenameSymbol.cpp index 497ee50fb451..7728fa65e578 100644 --- a/libsolidity/lsp/RenameSymbol.cpp +++ b/libsolidity/lsp/RenameSymbol.cpp @@ -283,7 +283,7 @@ void RenameSymbol::extractNameAndDeclaration(InlineAssembly const& _inlineAssemb if (location.containsOffset(_cursorBytePosition)) { m_declarationToRename = externalReference.declaration; - m_symbolName = identifier->name.str(); + m_symbolName = _inlineAssembly.operations().labelOf(identifier->name); if (!externalReference.suffix.empty()) m_symbolName = m_symbolName.substr(0, m_symbolName.length() - externalReference.suffix.size() - 1); @@ -296,7 +296,7 @@ void RenameSymbol::Visitor::endVisit(InlineAssembly const& _node) { for (auto&& [identifier, externalReference]: _node.annotation().externalReferences) { - std::string identifierName = identifier->name.str(); + std::string_view identifierName = _node.operations().labelOf(identifier->name); if (!externalReference.suffix.empty()) identifierName = identifierName.substr(0, identifierName.length() - externalReference.suffix.size() - 1); From 95e5db49517f47520c39073f6f5f8f6c22b69efe Mon Sep 17 00:00:00 2001 From: clonker <1685266+clonker@users.noreply.github.com> Date: Mon, 17 Mar 2025 11:02:55 +0100 Subject: [PATCH 08/17] Yul tests: Integrate numerical label IDs --- test/libyul/Common.cpp | 7 +- test/libyul/Common.h | 2 +- test/libyul/CompilabilityChecker.cpp | 11 +- test/libyul/ControlFlowGraphTest.cpp | 37 +++--- test/libyul/ControlFlowSideEffectsTest.cpp | 3 +- test/libyul/FunctionSideEffects.cpp | 6 +- test/libyul/Inliner.cpp | 6 +- test/libyul/KnowledgeBaseTest.cpp | 56 +++++---- test/libyul/Parser.cpp | 3 +- test/libyul/SSAControlFlowGraphTest.cpp | 4 +- test/libyul/StackLayoutGeneratorTest.cpp | 51 ++++---- test/libyul/StackShufflingTest.cpp | 36 +++--- test/libyul/StackShufflingTest.h | 1 + test/libyul/YulOptimizerTestCommon.cpp | 131 +++++++++++---------- test/libyul/YulOptimizerTestCommon.h | 7 +- test/tools/yulopti.cpp | 34 +++--- test/tools/yulrun.cpp | 2 +- 17 files changed, 229 insertions(+), 168 deletions(-) diff --git a/test/libyul/Common.cpp b/test/libyul/Common.cpp index a9f4c59a74ac..e379d77acfc4 100644 --- a/test/libyul/Common.cpp +++ b/test/libyul/Common.cpp @@ -78,15 +78,18 @@ YulStack yul::test::parseYul( return yulStack; } -yul::Block yul::test::disambiguate(std::string const& _source) +AST yul::test::disambiguate(std::string const& _source) { YulStack yulStack = parseYul(_source); soltestAssert(!yulStack.hasErrorsWarningsOrInfos()); - return std::get(Disambiguator( + LabelIDDispenser nameDispenser(yulStack.parserResult()->code()->labels()); + auto block = std::get(Disambiguator( yulStack.dialect(), *yulStack.parserResult()->analysisInfo, + nameDispenser, {} )(yulStack.parserResult()->code()->root())); + return AST{yulStack.dialect(), nameDispenser, std::move(block)}; } std::string yul::test::format(std::string const& _source) diff --git a/test/libyul/Common.h b/test/libyul/Common.h index de402c29a9da..d8d72a648f14 100644 --- a/test/libyul/Common.h +++ b/test/libyul/Common.h @@ -55,7 +55,7 @@ yul::YulStack parseYul( std::optional _optimiserSettings = std::nullopt ); -Block disambiguate(std::string const& _source); +AST disambiguate(std::string const& _source); std::string format(std::string const& _source); solidity::yul::Dialect const& dialect(std::string const& _name, langutil::EVMVersion _evmVersion, std::optional _eofVersion); diff --git a/test/libyul/CompilabilityChecker.cpp b/test/libyul/CompilabilityChecker.cpp index a030af487eb1..78036d0cdfde 100644 --- a/test/libyul/CompilabilityChecker.cpp +++ b/test/libyul/CompilabilityChecker.cpp @@ -24,6 +24,7 @@ #include +#include #include #include @@ -43,7 +44,7 @@ std::string check(std::string const& _input) auto functions = CompilabilityChecker(*yulStack.parserResult(), true).stackDeficit; std::string out; for (auto const& function: functions) - out += function.first.str() + ": " + std::to_string(function.second) + " "; + out += fmt::format("{}: {} ", yulStack.parserResult()->code()->labels()[function.first], function.second); return out; } } @@ -171,7 +172,7 @@ BOOST_AUTO_TEST_CASE(multiple_functions_used_arguments) x := add(add(add(add(add(add(add(add(add(add(add(add(x, r12), r11), r10), r9), r8), r7), r6), r5), r4), r3), r2), r1) } })"); - BOOST_CHECK_EQUAL(out, "h: 9 g: 5 f: 5 "); + BOOST_CHECK_EQUAL(out, "f: 5 g: 5 h: 9 "); } BOOST_AUTO_TEST_CASE(multiple_functions_unused_arguments) @@ -203,7 +204,7 @@ BOOST_AUTO_TEST_CASE(multiple_functions_unused_arguments) x := add(add(add(add(add(add(add(add(add(add(add(add(x, r12), r11), r10), r9), r8), r7), r6), r5), r4), r3), r2), r1) } })"); - BOOST_CHECK_EQUAL(out, "h: 9 f: 3 "); + BOOST_CHECK_EQUAL(out, "f: 3 h: 9 "); } BOOST_AUTO_TEST_CASE(nested_used_arguments) @@ -239,7 +240,7 @@ BOOST_AUTO_TEST_CASE(nested_used_arguments) x := add(add(add(add(add(add(add(add(add(add(add(add(x, r12), r11), r10), r9), r8), r7), r6), r5), r4), r3), r2), r1) } })"); - BOOST_CHECK_EQUAL(out, "h: 9 g: 5 f: 5 "); + BOOST_CHECK_EQUAL(out, "h: 9 f: 5 g: 5 "); } @@ -304,7 +305,7 @@ BOOST_AUTO_TEST_CASE(also_in_outer_block_used_arguments) sstore(s1, s2) } })"); - BOOST_CHECK_EQUAL(out, "g: 5 : 9 "); + BOOST_CHECK_EQUAL(out, ": 9 g: 5 "); } BOOST_AUTO_TEST_CASE(also_in_outer_block_unused_arguments) diff --git a/test/libyul/ControlFlowGraphTest.cpp b/test/libyul/ControlFlowGraphTest.cpp index 594b2f6c96ee..9e1fcf9b0e45 100644 --- a/test/libyul/ControlFlowGraphTest.cpp +++ b/test/libyul/ControlFlowGraphTest.cpp @@ -23,6 +23,7 @@ #include #include #include +#include #include #include @@ -59,18 +60,19 @@ ControlFlowGraphTest::ControlFlowGraphTest(std::string const& _filename): namespace { -static std::string variableSlotToString(VariableSlot const& _slot) +std::string_view variableSlotToString(VariableSlot const& _slot, CFG const& _cfg) { - return _slot.variable.get().name.str(); + return _cfg.labelOf(_slot.variable.get().name); } } class ControlFlowGraphPrinter { public: - ControlFlowGraphPrinter(std::ostream& _stream, Dialect const& _dialect): + ControlFlowGraphPrinter(std::ostream& _stream, Dialect const& _dialect, CFG const& _cfg): m_stream(_stream), - m_dialect(_dialect) + m_dialect(_dialect), + m_cfg(_cfg) { } void operator()(CFG::BasicBlock const& _block, bool _isMainEntry = true) @@ -92,17 +94,18 @@ class ControlFlowGraphPrinter CFG::FunctionInfo const& _info ) { - m_stream << "FunctionEntry_" << _info.function.name.str() << "_" << getBlockId(*_info.entry) << " [label=\""; - m_stream << "function " << _info.function.name.str() << "("; - m_stream << joinHumanReadable(_info.parameters | ranges::views::transform(variableSlotToString)); + m_stream << "FunctionEntry_" << m_cfg.labelOf(_info.function.name) << "_" << getBlockId(*_info.entry) << " [label=\""; + m_stream << "function " << m_cfg.labelOf(_info.function.name) << "("; + auto const slotTransform = [&](VariableSlot const& _slot) { return variableSlotToString(_slot, m_cfg); }; + m_stream << joinHumanReadable(_info.parameters | ranges::views::transform(slotTransform)); m_stream << ")"; if (!_info.returnVariables.empty()) { m_stream << " -> "; - m_stream << joinHumanReadable(_info.returnVariables | ranges::views::transform(variableSlotToString)); + m_stream << joinHumanReadable(_info.returnVariables | ranges::views::transform(slotTransform)); } m_stream << "\"];\n"; - m_stream << "FunctionEntry_" << _info.function.name.str() << "_" << getBlockId(*_info.entry) << " -> Block" << getBlockId(*_info.entry) << ";\n"; + m_stream << "FunctionEntry_" << m_cfg.labelOf(_info.function.name) << "_" << getBlockId(*_info.entry) << " -> Block" << getBlockId(*_info.entry) << ";\n"; (*this)(*_info.entry, false); } @@ -135,18 +138,18 @@ class ControlFlowGraphPrinter { std::visit(util::GenericVisitor{ [&](CFG::FunctionCall const& _call) { - m_stream << _call.function.get().name.str() << ": "; + m_stream << m_cfg.labelOf(_call.function.get().name) << ": "; }, [&](CFG::BuiltinCall const& _call) { m_stream << _call.builtin.get().name << ": "; }, [&](CFG::Assignment const& _assignment) { m_stream << "Assignment("; - m_stream << joinHumanReadable(_assignment.variables | ranges::views::transform(variableSlotToString)); + m_stream << joinHumanReadable(_assignment.variables | ranges::views::transform([&](VariableSlot const& _slot) { return variableSlotToString(_slot, m_cfg); })); m_stream << "): "; } }, operation.operation); - m_stream << stackToString(operation.input, m_dialect) << " => " << stackToString(operation.output, m_dialect) << "\\l\\\n"; + m_stream << stackToString(operation.input, m_cfg, m_dialect) << " => " << stackToString(operation.output, m_cfg, m_dialect) << "\\l\\\n"; } m_stream << "\"];\n"; std::visit(util::GenericVisitor{ @@ -168,7 +171,7 @@ class ControlFlowGraphPrinter { m_stream << "Block" << getBlockId(_block) << " -> Block" << getBlockId(_block) << "Exit;\n"; m_stream << "Block" << getBlockId(_block) << "Exit [label=\"{ "; - m_stream << stackSlotToString(_conditionalJump.condition, m_dialect); + m_stream << stackSlotToString(_conditionalJump.condition, m_cfg, m_dialect); m_stream << "| { <0> Zero | <1> NonZero }}\" shape=Mrecord];\n"; m_stream << "Block" << getBlockId(_block); m_stream << "Exit:0 -> Block" << getBlockId(*_conditionalJump.zero) << ";\n"; @@ -177,7 +180,7 @@ class ControlFlowGraphPrinter }, [&](CFG::BasicBlock::FunctionReturn const& _return) { - m_stream << "Block" << getBlockId(_block) << "Exit [label=\"FunctionReturn[" << _return.info->function.name.str() << "]\"];\n"; + m_stream << "Block" << getBlockId(_block) << "Exit [label=\"FunctionReturn[" << m_cfg.labelOf(_return.info->function.name) << "]\"];\n"; m_stream << "Block" << getBlockId(_block) << " -> Block" << getBlockId(_block) << "Exit;\n"; }, [&](CFG::BasicBlock::Terminated const&) @@ -198,6 +201,7 @@ class ControlFlowGraphPrinter } std::ostream& m_stream; Dialect const& m_dialect; + CFG const& m_cfg; std::map m_blockIds; size_t m_blockCount = 0; std::list m_blocksToPrint; @@ -215,14 +219,17 @@ TestCase::TestResult ControlFlowGraphTest::run(std::ostream& _stream, std::strin std::ostringstream output; + LabelIDDispenser nameDispenser(yulStack.parserResult()->code()->labels()); std::unique_ptr cfg = ControlFlowGraphBuilder::build( *yulStack.parserResult()->analysisInfo, + nameDispenser, yulStack.dialect(), yulStack.parserResult()->code()->root() ); output << "digraph CFG {\nnodesep=0.7;\nnode[shape=box];\n\n"; - ControlFlowGraphPrinter printer{output, yulStack.dialect()}; + auto const labels = nameDispenser.generateNewLabels(yulStack.parserResult()->code()->root(), yulStack.dialect()); + ControlFlowGraphPrinter printer{output, yulStack.dialect(), *cfg}; printer(*cfg->entry); for (auto function: cfg->functions) printer(cfg->functionInfo.at(function)); diff --git a/test/libyul/ControlFlowSideEffectsTest.cpp b/test/libyul/ControlFlowSideEffectsTest.cpp index 2249ba110cb1..9e5e21788783 100644 --- a/test/libyul/ControlFlowSideEffectsTest.cpp +++ b/test/libyul/ControlFlowSideEffectsTest.cpp @@ -73,9 +73,10 @@ TestCase::TestResult ControlFlowSideEffectsTest::run(std::ostream& _stream, std: yulStack.parserResult()->code()->root() ); m_obtainedResult.clear(); + auto const& labels = yulStack.parserResult()->code()->labels(); forEach(yulStack.parserResult()->code()->root(), [&](FunctionDefinition const& _fun) { std::string effectStr = toString(sideEffects.functionSideEffects().at(&_fun)); - m_obtainedResult += _fun.name.str() + (effectStr.empty() ? ":" : ": " + effectStr) + "\n"; + m_obtainedResult += fmt::format("{}{}\n", labels[_fun.name], effectStr.empty() ? ":" : ": " + effectStr); }); return checkResult(_stream, _linePrefix, _formatted); diff --git a/test/libyul/FunctionSideEffects.cpp b/test/libyul/FunctionSideEffects.cpp index cb24ed764c32..0596b8a193de 100644 --- a/test/libyul/FunctionSideEffects.cpp +++ b/test/libyul/FunctionSideEffects.cpp @@ -101,10 +101,10 @@ TestCase::TestResult FunctionSideEffects::run(std::ostream& _stream, std::string for (auto const& fun: functionSideEffects) { auto const& functionNameStr = std::visit(GenericVisitor{ - [](YulName const& _name) { return _name.str(); }, - [&](BuiltinHandle const& _builtin) { return yulStack.dialect().builtin(_builtin).name; } + [&](YulName const& _name) { return yulStack.parserResult()->code()->labels()[_name]; }, + [&](BuiltinHandle const& _builtin) -> std::string_view { return yulStack.dialect().builtin(_builtin).name; } }, fun.first); - functionSideEffectsStr[functionNameStr] = toString(fun.second); + functionSideEffectsStr.emplace(functionNameStr, toString(fun.second)); } m_obtainedResult.clear(); diff --git a/test/libyul/Inliner.cpp b/test/libyul/Inliner.cpp index f6da0c95c2b3..ed72a63ec2a4 100644 --- a/test/libyul/Inliner.cpp +++ b/test/libyul/Inliner.cpp @@ -43,11 +43,11 @@ std::string inlinableFunctions(std::string const& _source) auto ast = disambiguate(_source); InlinableExpressionFunctionFinder funFinder; - funFinder(ast); + funFinder(ast.root()); std::vector functionNames; for (auto const& f: funFinder.inlinableFunctions()) - functionNames.emplace_back(f.first.str()); + functionNames.emplace_back(ast.labelOf(f.first)); return boost::algorithm::join(functionNames, ","); } @@ -88,7 +88,7 @@ BOOST_AUTO_TEST_CASE(simple_inside_structures) "{" "function h() -> y { y := 2 }" "}" - "}"), "h,g,f"); + "}"), "g,f,h"); } BOOST_AUTO_TEST_CASE(negative) diff --git a/test/libyul/KnowledgeBaseTest.cpp b/test/libyul/KnowledgeBaseTest.cpp index 84e5a988a5d2..a2b874cef591 100644 --- a/test/libyul/KnowledgeBaseTest.cpp +++ b/test/libyul/KnowledgeBaseTest.cpp @@ -29,8 +29,8 @@ #include #include #include -#include #include +#include #include #include @@ -51,7 +51,7 @@ class KnowledgeBaseTest m_object = yulStack.parserResult(); auto astRoot = std::get(yul::ASTCopier{}(m_object->code()->root())); - NameDispenser dispenser(*m_object->dialect(), astRoot); + LabelIDDispenser dispenser(m_object->code()->labels()); std::set reserved; OptimiserStepContext context{*m_object->dialect(), dispenser, reserved, 0}; CommonSubexpressionEliminator::run(context, astRoot); @@ -60,7 +60,7 @@ class KnowledgeBaseTest for (auto const& [name, expression]: m_ssaValues.values()) m_values[name].value = expression; - m_object->setCode(std::make_shared(*m_object->dialect(), ASTLabelRegistry{}, std::move(astRoot))); + m_object->setCode(std::make_shared(*m_object->dialect(), dispenser, std::move(astRoot))); return KnowledgeBase( [this](YulName _var) { return util::valueOrNullptr(m_values, _var); }, *m_object->dialect() @@ -85,14 +85,22 @@ BOOST_AUTO_TEST_CASE(basic) let e := sub(a, b) })"); - BOOST_CHECK(!kb.knownToBeDifferent("a"_yulname, "b"_yulname)); + const auto& labels = m_object->code()->labels(); + std::map labelToIdMap; + for (auto const label: {"a", "b", "c", "e", "zero"}) + { + auto const maybeNodeId = labels.findIDForLabel(label); + yulAssert(maybeNodeId); + labelToIdMap[label] = *maybeNodeId; + } + BOOST_CHECK(!kb.knownToBeDifferent(labelToIdMap["a"], labelToIdMap["b"])); // This only works if the variable names are the same. // It assumes that SSA+CSE+Simplifier actually replaces the variables. - BOOST_CHECK(!kb.valueIfKnownConstant("a"_yulname)); - BOOST_CHECK(kb.valueIfKnownConstant("zero"_yulname) == u256(0)); - BOOST_CHECK(kb.differenceIfKnownConstant("a"_yulname, "b"_yulname) == u256(0)); - BOOST_CHECK(kb.differenceIfKnownConstant("a"_yulname, "c"_yulname) == u256(0)); - BOOST_CHECK(kb.valueIfKnownConstant("e"_yulname) == u256(0)); + BOOST_CHECK(!kb.valueIfKnownConstant(labelToIdMap["a"])); + BOOST_CHECK(kb.valueIfKnownConstant(labelToIdMap["zero"]) == u256(0)); + BOOST_CHECK(kb.differenceIfKnownConstant(labelToIdMap["a"], labelToIdMap["b"]) == u256(0)); + BOOST_CHECK(kb.differenceIfKnownConstant(labelToIdMap["a"], labelToIdMap["c"]) == u256(0)); + BOOST_CHECK(kb.valueIfKnownConstant(labelToIdMap["e"]) == u256(0)); } BOOST_AUTO_TEST_CASE(difference) @@ -105,21 +113,29 @@ BOOST_AUTO_TEST_CASE(difference) let e := sub(c, 12) })"); - BOOST_CHECK(kb.differenceIfKnownConstant("c"_yulname, "b"_yulname) == + const auto& labels = m_object->code()->labels(); + std::map labelToIdMap; + for (auto const label: {"a", "b", "c", "d", "e"}) + { + auto const maybeNodeId = labels.findIDForLabel(label); + yulAssert(maybeNodeId); + labelToIdMap[label] = *maybeNodeId; + } + BOOST_CHECK(kb.differenceIfKnownConstant(labelToIdMap["c"], labelToIdMap["b"]) == u256(20) ); - BOOST_CHECK(kb.differenceIfKnownConstant("b"_yulname, "c"_yulname) == + BOOST_CHECK(kb.differenceIfKnownConstant(labelToIdMap["b"], labelToIdMap["c"]) == u256(-20) ); - BOOST_CHECK(!kb.knownToBeDifferentByAtLeast32("b"_yulname, "c"_yulname)); - BOOST_CHECK(kb.knownToBeDifferentByAtLeast32("b"_yulname, "d"_yulname)); - BOOST_CHECK(kb.knownToBeDifferentByAtLeast32("a"_yulname, "b"_yulname)); - BOOST_CHECK(kb.knownToBeDifferentByAtLeast32("b"_yulname, "a"_yulname)); - - BOOST_CHECK(kb.differenceIfKnownConstant("e"_yulname, "a"_yulname) == u256(208)); - BOOST_CHECK(kb.differenceIfKnownConstant("e"_yulname, "b"_yulname) == u256(8)); - BOOST_CHECK(kb.differenceIfKnownConstant("a"_yulname, "e"_yulname) == u256(-208)); - BOOST_CHECK(kb.differenceIfKnownConstant("b"_yulname, "e"_yulname) == u256(-8)); + BOOST_CHECK(!kb.knownToBeDifferentByAtLeast32(labelToIdMap["b"], labelToIdMap["c"])); + BOOST_CHECK(kb.knownToBeDifferentByAtLeast32(labelToIdMap["b"], labelToIdMap["d"])); + BOOST_CHECK(kb.knownToBeDifferentByAtLeast32(labelToIdMap["a"], labelToIdMap["b"])); + BOOST_CHECK(kb.knownToBeDifferentByAtLeast32(labelToIdMap["b"], labelToIdMap["a"])); + + BOOST_CHECK(kb.differenceIfKnownConstant(labelToIdMap["e"], labelToIdMap["a"]) == u256(208)); + BOOST_CHECK(kb.differenceIfKnownConstant(labelToIdMap["e"], labelToIdMap["b"]) == u256(8)); + BOOST_CHECK(kb.differenceIfKnownConstant(labelToIdMap["a"], labelToIdMap["e"]) == u256(-208)); + BOOST_CHECK(kb.differenceIfKnownConstant(labelToIdMap["b"], labelToIdMap["e"]) == u256(-8)); } diff --git a/test/libyul/Parser.cpp b/test/libyul/Parser.cpp index d9ea91cbd351..5cd885b6c236 100644 --- a/test/libyul/Parser.cpp +++ b/test/libyul/Parser.cpp @@ -72,7 +72,8 @@ std::shared_ptr parse(std::string const& _source, Dialect const& _dialect, if (yul::AsmAnalyzer( analysisInfo, errorReporter, - _dialect + _dialect, + parserResult->labels() ).analyze(parserResult->root())) return parserResult; } diff --git a/test/libyul/SSAControlFlowGraphTest.cpp b/test/libyul/SSAControlFlowGraphTest.cpp index d2acee7bcb85..cc68fc4f4342 100644 --- a/test/libyul/SSAControlFlowGraphTest.cpp +++ b/test/libyul/SSAControlFlowGraphTest.cpp @@ -75,8 +75,8 @@ TestCase::TestResult SSAControlFlowGraphTest::run(std::ostream& _stream, std::st yulStack.dialect(), yulStack.parserResult()->code()->root() ); - ControlFlowLiveness liveness(*controlFlow); - m_obtainedResult = controlFlow->toDot(&liveness); + ControlFlowLiveness const liveness(*controlFlow); + m_obtainedResult = liveness.toDot(yulStack.parserResult()->code()->labels()); auto result = checkResult(_stream, _linePrefix, _formatted); diff --git a/test/libyul/StackLayoutGeneratorTest.cpp b/test/libyul/StackLayoutGeneratorTest.cpp index 0c85b1a7b968..51269f26033d 100644 --- a/test/libyul/StackLayoutGeneratorTest.cpp +++ b/test/libyul/StackLayoutGeneratorTest.cpp @@ -25,6 +25,7 @@ #include #include #include +#include #include #include @@ -63,17 +64,24 @@ StackLayoutGeneratorTest::StackLayoutGeneratorTest(std::string const& _filename) namespace { -static std::string variableSlotToString(VariableSlot const& _slot) +class VariableSlotToStringTransform { - return _slot.variable.get().name.str(); -} +public: + explicit VariableSlotToStringTransform(CFG const& _cfg): m_cfg(_cfg) {} + std::string_view operator()(VariableSlot const& _slot) const + { + return m_cfg.labelOf(_slot.variable.get().name); + } +private: + CFG const& m_cfg; +}; } class StackLayoutPrinter { public: - StackLayoutPrinter(std::ostream& _stream, StackLayout const& _stackLayout, Dialect const& _dialect): - m_stream(_stream), m_stackLayout(_stackLayout), m_dialect(_dialect) + StackLayoutPrinter(std::ostream& _stream, StackLayout const& _stackLayout, Dialect const& _dialect, CFG const& _cfg): + m_stream(_stream), m_stackLayout(_stackLayout), m_dialect(_dialect), m_cfg(_cfg) { } void operator()(CFG::BasicBlock const& _block, bool _isMainEntry = true) @@ -95,20 +103,20 @@ class StackLayoutPrinter CFG::FunctionInfo const& _info ) { - m_stream << "FunctionEntry_" << _info.function.name.str() << " [label=\""; - m_stream << "function " << _info.function.name.str() << "("; - m_stream << joinHumanReadable(_info.parameters | ranges::views::transform(variableSlotToString)); + m_stream << "FunctionEntry_" << m_cfg.labelOf(_info.function.name) << " [label=\""; + m_stream << "function " << m_cfg.labelOf(_info.function.name) << "("; + m_stream << joinHumanReadable(_info.parameters | ranges::views::transform(VariableSlotToStringTransform{m_cfg})); m_stream << ")"; if (!_info.returnVariables.empty()) { m_stream << " -> "; - m_stream << joinHumanReadable(_info.returnVariables | ranges::views::transform(variableSlotToString)); + m_stream << joinHumanReadable(_info.returnVariables | ranges::views::transform(VariableSlotToStringTransform{m_cfg})); } m_stream << "\\l\\\n"; Stack functionEntryStack = {FunctionReturnLabelSlot{_info.function}}; functionEntryStack += _info.parameters | ranges::views::reverse; - m_stream << stackToString(functionEntryStack, m_dialect) << "\"];\n"; - m_stream << "FunctionEntry_" << _info.function.name.str() << " -> Block" << getBlockId(*_info.entry) << ";\n"; + m_stream << stackToString(functionEntryStack, m_cfg, m_dialect) << "\"];\n"; + m_stream << "FunctionEntry_" << m_cfg.labelOf(_info.function.name) << " -> Block" << getBlockId(*_info.entry) << ";\n"; (*this)(*_info.entry, false); } @@ -138,14 +146,14 @@ class StackLayoutPrinter }, entry->exit); auto const& blockInfo = m_stackLayout.blockInfos.at(&_block); - m_stream << stackToString(blockInfo.entryLayout, m_dialect) << "\\l\\\n"; + m_stream << stackToString(blockInfo.entryLayout, m_cfg, m_dialect) << "\\l\\\n"; for (auto const& operation: _block.operations) { auto entryLayout = m_stackLayout.operationEntryLayout.at(&operation); - m_stream << stackToString(m_stackLayout.operationEntryLayout.at(&operation), m_dialect) << "\\l\\\n"; + m_stream << stackToString(m_stackLayout.operationEntryLayout.at(&operation), m_cfg, m_dialect) << "\\l\\\n"; std::visit(util::GenericVisitor{ [&](CFG::FunctionCall const& _call) { - m_stream << _call.function.get().name.str(); + m_stream << m_cfg.labelOf(_call.function.get().name); }, [&](CFG::BuiltinCall const& _call) { m_stream << _call.builtin.get().name; @@ -153,7 +161,7 @@ class StackLayoutPrinter }, [&](CFG::Assignment const& _assignment) { m_stream << "Assignment("; - m_stream << joinHumanReadable(_assignment.variables | ranges::views::transform(variableSlotToString)); + m_stream << joinHumanReadable(_assignment.variables | ranges::views::transform(VariableSlotToStringTransform{m_cfg})); m_stream << ")"; } }, operation.operation); @@ -162,9 +170,9 @@ class StackLayoutPrinter for (size_t i = 0; i < operation.input.size(); ++i) entryLayout.pop_back(); entryLayout += operation.output; - m_stream << stackToString(entryLayout, m_dialect) << "\\l\\\n"; + m_stream << stackToString(entryLayout, m_cfg, m_dialect) << "\\l\\\n"; } - m_stream << stackToString(blockInfo.exitLayout, m_dialect) << "\\l\\\n"; + m_stream << stackToString(blockInfo.exitLayout, m_cfg, m_dialect) << "\\l\\\n"; m_stream << "\"];\n"; std::visit(util::GenericVisitor{ [&](CFG::BasicBlock::MainExit const&) @@ -185,7 +193,7 @@ class StackLayoutPrinter { m_stream << "Block" << getBlockId(_block) << " -> Block" << getBlockId(_block) << "Exit;\n"; m_stream << "Block" << getBlockId(_block) << "Exit [label=\"{ "; - m_stream << stackSlotToString(_conditionalJump.condition, m_dialect); + m_stream << stackSlotToString(_conditionalJump.condition, m_cfg, m_dialect); m_stream << "| { <0> Zero | <1> NonZero }}\" shape=Mrecord];\n"; m_stream << "Block" << getBlockId(_block); m_stream << "Exit:0 -> Block" << getBlockId(*_conditionalJump.zero) << ";\n"; @@ -194,7 +202,7 @@ class StackLayoutPrinter }, [&](CFG::BasicBlock::FunctionReturn const& _return) { - m_stream << "Block" << getBlockId(_block) << "Exit [label=\"FunctionReturn[" << _return.info->function.name.str() << "]\"];\n"; + m_stream << "Block" << getBlockId(_block) << "Exit [label=\"FunctionReturn[" << m_cfg.labelOf(_return.info->function.name) << "]\"];\n"; m_stream << "Block" << getBlockId(_block) << " -> Block" << getBlockId(_block) << "Exit;\n"; }, [&](CFG::BasicBlock::Terminated const&) @@ -216,6 +224,7 @@ class StackLayoutPrinter std::ostream& m_stream; StackLayout const& m_stackLayout; Dialect const& m_dialect; + CFG const& m_cfg; std::map m_blockIds; size_t m_blockCount = 0; std::list m_blocksToPrint; @@ -234,8 +243,10 @@ TestCase::TestResult StackLayoutGeneratorTest::run(std::ostream& _stream, std::s std::ostringstream output; + LabelIDDispenser nameDispenser(yulStack.parserResult()->code()->labels()); std::unique_ptr cfg = ControlFlowGraphBuilder::build( *yulStack.parserResult()->analysisInfo, + nameDispenser, yulStack.dialect(), yulStack.parserResult()->code()->root() ); @@ -246,7 +257,7 @@ TestCase::TestResult StackLayoutGeneratorTest::run(std::ostream& _stream, std::s StackLayout stackLayout = StackLayoutGenerator::run(*cfg, *evmDialect); output << "digraph CFG {\nnodesep=0.7;\nnode[shape=box];\n\n"; - StackLayoutPrinter printer{output, stackLayout, yulStack.dialect()}; + StackLayoutPrinter printer{output, stackLayout, yulStack.dialect(), *cfg}; printer(*cfg->entry); for (auto function: cfg->functions) printer(cfg->functionInfo.at(function)); diff --git a/test/libyul/StackShufflingTest.cpp b/test/libyul/StackShufflingTest.cpp index 58ea124fb1df..e8cc7df2318f 100644 --- a/test/libyul/StackShufflingTest.cpp +++ b/test/libyul/StackShufflingTest.cpp @@ -60,14 +60,13 @@ bool StackShufflingTest::parse(std::string const& _source) if (scanner.currentToken() == Token::LBrack) { scanner.next(); - std::string functionName = scanner.currentLiteral(); + std::string functionLabel = scanner.currentLiteral(); + auto const functionLabelID = m_labelRegistryBuilder.define(functionLabel); auto call = yul::FunctionCall{ - {}, yul::Identifier{{}, YulName(functionName)}, {} + {}, yul::Identifier{{}, functionLabelID}, {} }; stack.emplace_back(FunctionCallReturnLabelSlot{ - m_functions.insert( - make_pair(functionName, call) - ).first->second + m_functions.emplace(functionLabelID, call).first->second }); expectToken(Token::RBrack); } @@ -83,14 +82,15 @@ bool StackShufflingTest::parse(std::string const& _source) expectToken(Token::LBrack); scanner.next(); std::string functionName = scanner.currentLiteral(); + auto const functionLabelID = m_labelRegistryBuilder.define(functionName); auto call = yul::FunctionCall{ - {}, yul::Identifier{{}, YulName(functionName)}, {} + {}, yul::Identifier{{}, functionLabelID}, {} }; expectToken(Token::Comma); scanner.next(); size_t index = size_t(atoi(scanner.currentLiteral().c_str())); stack.emplace_back(TemporarySlot{ - m_functions.insert(make_pair(functionName, call)).first->second, + m_functions.emplace(functionLabelID, call).first->second, index }); expectToken(Token::RBrack); @@ -108,7 +108,8 @@ bool StackShufflingTest::parse(std::string const& _source) expectToken(Token::LBrack); scanner.next(); // read number of ghost variables as ghostVariableId std::string ghostVariableId = scanner.currentLiteral(); - Scope::Variable ghostVar = Scope::Variable{YulName(literal + "[" + ghostVariableId + "]")}; + auto const ghostID = m_labelRegistryBuilder.addGhost(); + Scope::Variable ghostVar = Scope::Variable{ghostID}; stack.emplace_back(VariableSlot{ m_variables.insert(std::make_pair(ghostVar.name, ghostVar)).first->second }); @@ -116,11 +117,10 @@ bool StackShufflingTest::parse(std::string const& _source) } else { - Scope::Variable var = Scope::Variable{YulName(literal)}; + auto const labelID = m_labelRegistryBuilder.define(literal); + Scope::Variable var = Scope::Variable{labelID}; stack.emplace_back(VariableSlot{ - m_variables.insert( - make_pair(literal, var) - ).first->second + m_variables.emplace(labelID, var).first->second }); } scanner.next(); @@ -160,6 +160,8 @@ TestCase::TestResult StackShufflingTest::run(std::ostream& _stream, std::string return TestResult::FatalError; } + CFG cfg; + cfg.labels = std::make_unique(m_labelRegistryBuilder.build()); std::ostringstream output; size_t operations = 0; createStackLayout( @@ -168,15 +170,15 @@ TestCase::TestResult StackShufflingTest::run(std::ostream& _stream, std::string [&](unsigned _swapDepth) // swap { ++operations; - output << stackToString(m_sourceStack, dialect) << std::endl; + output << stackToString(m_sourceStack, cfg, dialect) << std::endl; output << "SWAP" << _swapDepth << std::endl; }, [&](StackSlot const& _slot) // dupOrPush { ++operations; - output << stackToString(m_sourceStack, dialect) << std::endl; + output << stackToString(m_sourceStack, cfg, dialect) << std::endl; if (canBeFreelyGenerated(_slot)) - output << "PUSH " << stackSlotToString(_slot, dialect) << std::endl; + output << "PUSH " << stackSlotToString(_slot, cfg, dialect) << std::endl; else { if (auto depth = util::findOffset(m_sourceStack | ranges::views::reverse, _slot)) @@ -187,13 +189,13 @@ TestCase::TestResult StackShufflingTest::run(std::ostream& _stream, std::string }, [&](){ // pop ++operations; - output << stackToString(m_sourceStack, dialect) << std::endl; + output << stackToString(m_sourceStack, cfg, dialect) << std::endl; output << "POP" << std::endl; }, m_maximumStackDepth ); - output << stackToString(m_sourceStack, dialect) << std::endl; + output << stackToString(m_sourceStack, cfg, dialect) << std::endl; output << operations << " operations" << std::endl; m_obtainedResult = output.str(); diff --git a/test/libyul/StackShufflingTest.h b/test/libyul/StackShufflingTest.h index 5485ed081805..74bb339d1855 100644 --- a/test/libyul/StackShufflingTest.h +++ b/test/libyul/StackShufflingTest.h @@ -45,5 +45,6 @@ class StackShufflingTest: public TestCase Stack m_targetStack; std::map m_functions; std::map m_variables; + ASTLabelRegistryBuilder m_labelRegistryBuilder; }; } diff --git a/test/libyul/YulOptimizerTestCommon.cpp b/test/libyul/YulOptimizerTestCommon.cpp index 478cbb8864f0..dd6b72fe01cd 100644 --- a/test/libyul/YulOptimizerTestCommon.cpp +++ b/test/libyul/YulOptimizerTestCommon.cpp @@ -66,6 +66,8 @@ #include +#include + #include using namespace solidity; @@ -90,60 +92,65 @@ YulOptimizerTestCommon::YulOptimizerTestCommon(std::shared_ptr _ob ) solUnimplemented("The current implementation of YulOptimizerTests ignores subobjects that are not Data."); + m_labels = std::make_unique(m_object->code()->labels()); + m_nameDispenser = std::make_unique(*m_labels); m_namedSteps = { {"disambiguator", [&]() { return disambiguate(); }}, {"nameDisplacer", [&]() { auto block = disambiguate(); - updateContext(block); + updateContext(); + ASTLabelRegistryBuilder builder{m_nameDispenser->generateNewLabels(block, m_context->dialect)}; + std::set namesToFree; + std::set labelsToFree; + for (size_t i = 1; i <= 5; ++i) + { + auto const label = fmt::format("illegal{}", i); + labelsToFree.insert(label); + namesToFree.insert(builder.define(label)); + } + m_labels = std::make_unique(builder.build()); + m_nameDispenser = std::make_unique(*m_labels, labelsToFree); NameDisplacer{ *m_nameDispenser, - {"illegal1"_yulname, "illegal2"_yulname, "illegal3"_yulname, "illegal4"_yulname, "illegal5"_yulname} + namesToFree }(block); return block; }}, {"blockFlattener", [&]() { auto block = disambiguate(); - updateContext(block); + updateContext(); FunctionGrouper::run(*m_context, block); BlockFlattener::run(*m_context, block); return block; }}, {"constantOptimiser", [&]() { auto block = std::get(ASTCopier{}(m_object->code()->root())); - updateContext(block); + updateContext(); GasMeter meter(dynamic_cast(*m_object->dialect()), false, 200); ConstantOptimiser{dynamic_cast(*m_object->dialect()), meter}(block); return block; }}, {"varDeclInitializer", [&]() { auto block = std::get(ASTCopier{}(m_object->code()->root())); - updateContext(block); + updateContext(); VarDeclInitializer::run(*m_context, block); return block; }}, - {"varNameCleaner", [&]() { - auto block = disambiguate(); - updateContext(block); - FunctionHoister::run(*m_context, block); - FunctionGrouper::run(*m_context, block); - VarNameCleaner::run(*m_context, block); - return block; - }}, {"forLoopConditionIntoBody", [&]() { auto block = disambiguate(); - updateContext(block); + updateContext(); ForLoopConditionIntoBody::run(*m_context, block); return block; }}, {"forLoopInitRewriter", [&]() { auto block = disambiguate(); - updateContext(block); + updateContext(); ForLoopInitRewriter::run(*m_context, block); return block; }}, {"commonSubexpressionEliminator", [&]() { auto block = disambiguate(); - updateContext(block); + updateContext(); ForLoopInitRewriter::run(*m_context, block); FunctionHoister::run(*m_context, block); CommonSubexpressionEliminator::run(*m_context, block); @@ -151,31 +158,31 @@ YulOptimizerTestCommon::YulOptimizerTestCommon(std::shared_ptr _ob }}, {"conditionalUnsimplifier", [&]() { auto block = disambiguate(); - updateContext(block); + updateContext(); ConditionalUnsimplifier::run(*m_context, block); return block; }}, {"conditionalSimplifier", [&]() { auto block = disambiguate(); - updateContext(block); + updateContext(); ConditionalSimplifier::run(*m_context, block); return block; }}, {"expressionSplitter", [&]() { auto block = std::get(ASTCopier{}(m_object->code()->root())); - updateContext(block); + updateContext(); ExpressionSplitter::run(*m_context, block); return block; }}, {"expressionJoiner", [&]() { auto block = disambiguate(); - updateContext(block); + updateContext(); ExpressionJoiner::run(*m_context, block); return block; }}, {"splitJoin", [&]() { auto block = disambiguate(); - updateContext(block); + updateContext(); ExpressionSplitter::run(*m_context, block); ExpressionJoiner::run(*m_context, block); ExpressionJoiner::run(*m_context, block); @@ -183,32 +190,32 @@ YulOptimizerTestCommon::YulOptimizerTestCommon(std::shared_ptr _ob }}, {"functionGrouper", [&]() { auto block = disambiguate(); - updateContext(block); + updateContext(); FunctionGrouper::run(*m_context, block); return block; }}, {"functionHoister", [&]() { auto block = disambiguate(); - updateContext(block); + updateContext(); FunctionHoister::run(*m_context, block); return block; }}, {"functionSpecializer", [&]() { auto block = disambiguate(); - updateContext(block); + updateContext(); FunctionHoister::run(*m_context, block); FunctionSpecializer::run(*m_context, block); return block; }}, {"expressionInliner", [&]() { auto block = disambiguate(); - updateContext(block); + updateContext(); ExpressionInliner::run(*m_context, block); return block; }}, {"fullInliner", [&]() { auto block = disambiguate(); - updateContext(block); + updateContext(); FunctionHoister::run(*m_context, block); FunctionGrouper::run(*m_context, block); ExpressionSplitter::run(*m_context, block); @@ -218,7 +225,7 @@ YulOptimizerTestCommon::YulOptimizerTestCommon(std::shared_ptr _ob }}, {"fullInlinerWithoutSplitter", [&]() { auto block = disambiguate(); - updateContext(block); + updateContext(); FunctionHoister::run(*m_context, block); FunctionGrouper::run(*m_context, block); FullInliner::run(*m_context, block); @@ -226,7 +233,7 @@ YulOptimizerTestCommon::YulOptimizerTestCommon(std::shared_ptr _ob }}, {"rematerialiser", [&]() { auto block = disambiguate(); - updateContext(block); + updateContext(); ForLoopInitRewriter::run(*m_context, block); FunctionHoister::run(*m_context, block); Rematerialiser::run(*m_context, block); @@ -234,7 +241,7 @@ YulOptimizerTestCommon::YulOptimizerTestCommon(std::shared_ptr _ob }}, {"expressionSimplifier", [&]() { auto block = disambiguate(); - updateContext(block); + updateContext(); ForLoopInitRewriter::run(*m_context, block); FunctionHoister::run(*m_context, block); ExpressionSplitter::run(*m_context, block); @@ -249,7 +256,7 @@ YulOptimizerTestCommon::YulOptimizerTestCommon(std::shared_ptr _ob }}, {"fullSimplify", [&]() { auto block = disambiguate(); - updateContext(block); + updateContext(); FunctionGrouper::run(*m_context, block); BlockFlattener::run(*m_context, block); ExpressionSplitter::run(*m_context, block); @@ -266,7 +273,7 @@ YulOptimizerTestCommon::YulOptimizerTestCommon(std::shared_ptr _ob }}, {"unusedFunctionParameterPruner", [&]() { auto block = disambiguate(); - updateContext(block); + updateContext(); ForLoopInitRewriter::run(*m_context, block); FunctionHoister::run(*m_context, block); LiteralRematerialiser::run(*m_context, block); @@ -275,41 +282,41 @@ YulOptimizerTestCommon::YulOptimizerTestCommon(std::shared_ptr _ob }}, {"unusedPruner", [&]() { auto block = disambiguate(); - updateContext(block); + updateContext(); UnusedPruner::run(*m_context, block); return block; }}, {"circularReferencesPruner", [&]() { auto block = disambiguate(); - updateContext(block); + updateContext(); FunctionHoister::run(*m_context, block); CircularReferencesPruner::run(*m_context, block); return block; }}, {"deadCodeEliminator", [&]() { auto block = disambiguate(); - updateContext(block); + updateContext(); ForLoopInitRewriter::run(*m_context, block); DeadCodeEliminator::run(*m_context, block); return block; }}, {"ssaTransform", [&]() { auto block = disambiguate(); - updateContext(block); + updateContext(); ForLoopInitRewriter::run(*m_context, block); SSATransform::run(*m_context, block); return block; }}, {"unusedAssignEliminator", [&]() { auto block = disambiguate(); - updateContext(block); + updateContext(); ForLoopInitRewriter::run(*m_context, block); UnusedAssignEliminator::run(*m_context, block); return block; }}, {"unusedStoreEliminator", [&]() { auto block = disambiguate(); - updateContext(block); + updateContext(); ForLoopInitRewriter::run(*m_context, block); ExpressionSplitter::run(*m_context, block); SSATransform::run(*m_context, block); @@ -320,7 +327,7 @@ YulOptimizerTestCommon::YulOptimizerTestCommon(std::shared_ptr _ob }}, {"equalStoreEliminator", [&]() { auto block = disambiguate(); - updateContext(block); + updateContext(); FunctionHoister::run(*m_context, block); ForLoopInitRewriter::run(*m_context, block); EqualStoreEliminator::run(*m_context, block); @@ -328,7 +335,7 @@ YulOptimizerTestCommon::YulOptimizerTestCommon(std::shared_ptr _ob }}, {"ssaPlusCleanup", [&]() { auto block = disambiguate(); - updateContext(block); + updateContext(); ForLoopInitRewriter::run(*m_context, block); SSATransform::run(*m_context, block); UnusedAssignEliminator::run(*m_context, block); @@ -336,7 +343,7 @@ YulOptimizerTestCommon::YulOptimizerTestCommon(std::shared_ptr _ob }}, {"loadResolver", [&]() { auto block = disambiguate(); - updateContext(block); + updateContext(); FunctionGrouper::run(*m_context, block); BlockFlattener::run(*m_context, block); ForLoopInitRewriter::run(*m_context, block); @@ -354,7 +361,7 @@ YulOptimizerTestCommon::YulOptimizerTestCommon(std::shared_ptr _ob }}, {"loopInvariantCodeMotion", [&]() { auto block = disambiguate(); - updateContext(block); + updateContext(); ForLoopInitRewriter::run(*m_context, block); FunctionHoister::run(*m_context, block); LoopInvariantCodeMotion::run(*m_context, block); @@ -362,14 +369,14 @@ YulOptimizerTestCommon::YulOptimizerTestCommon(std::shared_ptr _ob }}, {"controlFlowSimplifier", [&]() { auto block = disambiguate(); - updateContext(block); + updateContext(); ForLoopInitRewriter::run(*m_context, block); ControlFlowSimplifier::run(*m_context, block); return block; }}, {"structuralSimplifier", [&]() { auto block = disambiguate(); - updateContext(block); + updateContext(); ForLoopInitRewriter::run(*m_context, block); FunctionHoister::run(*m_context, block); LiteralRematerialiser::run(*m_context, block); @@ -378,7 +385,7 @@ YulOptimizerTestCommon::YulOptimizerTestCommon(std::shared_ptr _ob }}, {"equivalentFunctionCombiner", [&]() { auto block = disambiguate(); - updateContext(block); + updateContext(); ForLoopInitRewriter::run(*m_context, block); FunctionHoister::run(*m_context, block); EquivalentFunctionCombiner::run(*m_context, block); @@ -386,13 +393,13 @@ YulOptimizerTestCommon::YulOptimizerTestCommon(std::shared_ptr _ob }}, {"ssaReverser", [&]() { auto block = disambiguate(); - updateContext(block); + updateContext(); SSAReverser::run(*m_context, block); return block; }}, {"ssaAndBack", [&]() { auto block = disambiguate(); - updateContext(block); + updateContext(); ForLoopInitRewriter::run(*m_context, block); // apply SSA SSATransform::run(*m_context, block); @@ -406,16 +413,19 @@ YulOptimizerTestCommon::YulOptimizerTestCommon(std::shared_ptr _ob }}, {"stackCompressor", [&]() { auto block = disambiguate(); - updateContext(block); + updateContext(); ForLoopInitRewriter::run(*m_context, block); FunctionHoister::run(*m_context, block); FunctionGrouper::run(*m_context, block); size_t maxIterations = 16; { - Object object(*m_optimizedObject); - object.setCode(std::make_shared(*m_object->dialect(), ASTLabelRegistry{}, std::get(ASTCopier{}(block)))); + m_labels = std::make_unique(m_nameDispenser->generateNewLabels(block, m_context->dialect)); + m_nameDispenser = std::make_unique(*m_labels); + Object object{*m_optimizedObject}; + object.setCode(std::make_shared(*m_object->dialect(), *m_labels, std::get(ASTCopier{}(block)))); block = std::get<1>(StackCompressor::run(object, true, maxIterations)); } + updateContext(); BlockFlattener::run(*m_context, block); return block; }}, @@ -429,13 +439,14 @@ YulOptimizerTestCommon::YulOptimizerTestCommon(std::shared_ptr _ob frontend::OptimiserSettings::DefaultYulOptimiserCleanupSteps, frontend::OptimiserSettings::standard().expectedExecutionsPerDeployment ); + m_nameDispenser = std::make_unique(m_optimizedObject->code()->labels()); return std::get(ASTCopier{}(m_optimizedObject->code()->root())); }}, {"stackLimitEvader", [&]() { auto block = disambiguate(); - updateContext(block); + updateContext(); Object object(*m_optimizedObject); - object.setCode(std::make_shared(*m_object->dialect(), ASTLabelRegistry{}, std::get(ASTCopier{}(block)))); + object.setCode(std::make_shared(*m_object->dialect(), *m_nameDispenser, std::get(ASTCopier{}(block)))); auto const unreachables = CompilabilityChecker{ object, true @@ -445,10 +456,11 @@ YulOptimizerTestCommon::YulOptimizerTestCommon(std::shared_ptr _ob }}, {"fakeStackLimitEvader", [&]() { auto block = disambiguate(); - updateContext(block); + updateContext(); // Mark all variables with a name starting with "$" for escalation to memory. struct FakeUnreachableGenerator: ASTWalker { + explicit FakeUnreachableGenerator(ASTLabelRegistry const& _labels): m_labels(_labels) {} std::map> fakeUnreachables; using ASTWalker::operator(); void operator()(FunctionDefinition const& _function) override @@ -464,7 +476,7 @@ YulOptimizerTestCommon::YulOptimizerTestCommon(std::shared_ptr _ob } void visitVariableName(YulName _var) { - if (!_var.empty() && _var.str().front() == '$') + if (!ASTLabelRegistry::empty(_var) && m_labels[_var].front() == '$') if (!util::contains(fakeUnreachables[m_currentFunction], _var)) fakeUnreachables[m_currentFunction].emplace_back(_var); } @@ -479,9 +491,11 @@ YulOptimizerTestCommon::YulOptimizerTestCommon(std::shared_ptr _ob visitVariableName(_identifier.name); ASTWalker::operator()(_identifier); } - YulName m_currentFunction = YulName{}; + YulName m_currentFunction = ASTLabelRegistry::emptyID(); + ASTLabelRegistry const& m_labels; }; - FakeUnreachableGenerator fakeUnreachableGenerator; + auto const labels = m_nameDispenser->generateNewLabels(block, m_context->dialect); + FakeUnreachableGenerator fakeUnreachableGenerator(labels); fakeUnreachableGenerator(block); StackLimitEvader::run(*m_context, block, fakeUnreachableGenerator.fakeUnreachables); return block; @@ -499,7 +513,7 @@ bool YulOptimizerTestCommon::runStep() if (m_namedSteps.count(m_optimizerStep)) { auto block = m_namedSteps[m_optimizerStep](); - m_optimizedObject->setCode(std::make_shared(*m_object->dialect(), ASTLabelRegistry{}, std::move(block))); + m_optimizedObject->setCode(std::make_shared(*m_object->dialect(), *m_nameDispenser, std::move(block))); } else return false; @@ -543,13 +557,12 @@ Block const* YulOptimizerTestCommon::run() Block YulOptimizerTestCommon::disambiguate() { - auto block = std::get(Disambiguator(*m_object->dialect(), *m_object->analysisInfo)(m_object->code()->root())); + auto block = std::get(Disambiguator(*m_object->dialect(), *m_object->analysisInfo, *m_nameDispenser)(m_object->code()->root())); return block; } -void YulOptimizerTestCommon::updateContext(Block const& _block) +void YulOptimizerTestCommon::updateContext() { - m_nameDispenser = std::make_unique(*m_object->dialect(), _block, m_reservedIdentifiers); m_context = std::make_unique(OptimiserStepContext{ *m_object->dialect(), *m_nameDispenser, diff --git a/test/libyul/YulOptimizerTestCommon.h b/test/libyul/YulOptimizerTestCommon.h index df5c84039b0f..b6881d5d97eb 100644 --- a/test/libyul/YulOptimizerTestCommon.h +++ b/test/libyul/YulOptimizerTestCommon.h @@ -19,7 +19,7 @@ #pragma once #include -#include +#include #include @@ -57,12 +57,13 @@ class YulOptimizerTestCommon std::shared_ptr optimizedObject() const; private: Block disambiguate(); - void updateContext(Block const& _block); + void updateContext(); std::string m_optimizerStep; std::set m_reservedIdentifiers; - std::unique_ptr m_nameDispenser; + std::unique_ptr m_labels; + std::unique_ptr m_nameDispenser; std::unique_ptr m_context; std::shared_ptr m_object; diff --git a/test/tools/yulopti.cpp b/test/tools/yulopti.cpp index 1a3b3cd5acbf..bc73e7a41fd3 100644 --- a/test/tools/yulopti.cpp +++ b/test/tools/yulopti.cpp @@ -98,11 +98,21 @@ class YulOpti throw std::runtime_error("Could not parse source."); } m_astRoot = std::make_shared(std::get(ASTCopier{}(ast->root()))); + m_dispenser = std::make_unique(ast->labels()); + m_context = std::make_unique( + OptimiserStepContext{ + m_dialect, + *m_dispenser, + m_reservedIdentifiers, + OptimiserSettings::standard().expectedExecutionsPerDeployment + } + ); m_analysisInfo = std::make_unique(); AsmAnalyzer analyzer( *m_analysisInfo, errorReporter, - m_dialect + m_dialect, + ast->labels() ); if (!analyzer.analyze(*m_astRoot) || errorReporter.hasErrors()) { @@ -170,17 +180,16 @@ class YulOpti void disambiguate() { - *m_astRoot = std::get(Disambiguator(m_dialect, *m_analysisInfo)(*m_astRoot)); + *m_astRoot = std::get(Disambiguator(m_dialect, *m_analysisInfo, *m_dispenser)(*m_astRoot)); m_analysisInfo.reset(); - m_nameDispenser.reset(*m_astRoot); } void runSteps(std::string _source, std::string _steps) { parse(_source); disambiguate(); - OptimiserSuite{m_context}.runSequence(_steps, *m_astRoot); - std::cout << AsmPrinter{m_dialect}(*m_astRoot) << std::endl; + OptimiserSuite{*m_context}.runSequence(_steps, *m_astRoot); + std::cout << AsmPrinter{m_dialect, m_dispenser->generateNewLabels(*m_astRoot, m_dialect)}(*m_astRoot) << std::endl; } void runInteractive(std::string _source, bool _disambiguated = false) @@ -218,17 +227,17 @@ class YulOpti case ';': { Object obj; - obj.setCode(std::make_shared(m_dialect, ASTLabelRegistry{}, std::get(ASTCopier{}(*m_astRoot)))); + obj.setCode(std::make_shared(m_dialect, m_context->dispenser, std::get(ASTCopier{}(*m_astRoot)))); *m_astRoot = std::get<1>(StackCompressor::run(obj, true, 16)); break; } default: - OptimiserSuite{m_context}.runSequence( + OptimiserSuite{*m_context}.runSequence( std::string_view(&option, 1), *m_astRoot ); } - _source = AsmPrinter{m_dialect}(*m_astRoot); + _source = AsmPrinter{m_dialect, m_dispenser->generateNewLabels(*m_astRoot, m_dialect)}(*m_astRoot); } catch (...) { @@ -242,16 +251,11 @@ class YulOpti private: std::shared_ptr m_astRoot; + std::unique_ptr m_dispenser; Dialect const& m_dialect{EVMDialect::strictAssemblyForEVMObjects(EVMVersion{}, std::nullopt)}; std::unique_ptr m_analysisInfo; std::set const m_reservedIdentifiers = {}; - NameDispenser m_nameDispenser{m_dialect, m_reservedIdentifiers}; - OptimiserStepContext m_context{ - m_dialect, - m_nameDispenser, - m_reservedIdentifiers, - solidity::frontend::OptimiserSettings::standard().expectedExecutionsPerDeployment - }; + std::unique_ptr m_context; }; int main(int argc, char** argv) diff --git a/test/tools/yulrun.cpp b/test/tools/yulrun.cpp index a5fa05d934ce..1b874b3312ca 100644 --- a/test/tools/yulrun.cpp +++ b/test/tools/yulrun.cpp @@ -91,7 +91,7 @@ void interpret(std::string const& _source, bool _inspect, bool _disableExternalC try { if (_inspect) - InspectedInterpreter::run(std::make_shared(_source, state), state, *ast, _disableExternalCalls, /*disableMemoryTracing=*/false); + InspectedInterpreter::run(std::make_shared(_source, state, ast->labels()), state, *ast, _disableExternalCalls, /*disableMemoryTracing=*/false); else Interpreter::run(state, *ast, _disableExternalCalls, /*disableMemoryTracing=*/false); } From f259a86851113a5c0fdb54e9b034c79d89cf599a Mon Sep 17 00:00:00 2001 From: clonker <1685266+clonker@users.noreply.github.com> Date: Fri, 21 Mar 2025 14:43:45 +0100 Subject: [PATCH 09/17] Yul Phaser: Integrate numerical label IDs --- test/yulPhaser/Program.cpp | 4 ++-- tools/yulPhaser/Program.cpp | 24 ++++++++++++------------ tools/yulPhaser/Program.h | 10 +++------- 3 files changed, 17 insertions(+), 21 deletions(-) diff --git a/test/yulPhaser/Program.cpp b/test/yulPhaser/Program.cpp index 018de32ee2e7..431104aaaf1b 100644 --- a/test/yulPhaser/Program.cpp +++ b/test/yulPhaser/Program.cpp @@ -119,8 +119,8 @@ BOOST_AUTO_TEST_CASE(load_should_disambiguate) VariableDeclaration const& declaration1 = get(innerBlock1.statements[0]); VariableDeclaration const& declaration2 = get(innerBlock2.statements[0]); - BOOST_TEST(declaration1.variables[0].name.str() == "x"); - BOOST_TEST(declaration2.variables[0].name.str() != "x"); + BOOST_TEST(program.labels()[declaration1.variables[0].name] == "x"); + BOOST_TEST(program.labels()[declaration2.variables[0].name] != "x"); } BOOST_AUTO_TEST_CASE(load_should_do_function_grouping_and_hoisting) diff --git a/tools/yulPhaser/Program.cpp b/tools/yulPhaser/Program.cpp index 36675116167b..ba4aea0bf18d 100644 --- a/tools/yulPhaser/Program.cpp +++ b/tools/yulPhaser/Program.cpp @@ -59,9 +59,8 @@ std::ostream& operator<<(std::ostream& _stream, Program const& _program); } Program::Program(Program const& program): - m_ast(std::make_unique(program.m_dialect, ASTLabelRegistry{}, std::get(ASTCopier{}(program.m_ast->root())))), - m_dialect{program.m_dialect}, - m_nameDispenser(program.m_nameDispenser) + m_ast(std::make_unique(program.m_dialect, program.m_ast->labels(), std::get(ASTCopier{}(program.m_ast->root())))), + m_dialect{program.m_dialect} { } @@ -101,7 +100,7 @@ std::variant Program::load(CharStream& _sourceCode) void Program::optimise(std::vector const& _optimisationSteps) { - m_ast = applyOptimisationSteps(m_dialect, m_nameDispenser, std::move(m_ast), _optimisationSteps); + m_ast = applyOptimisationSteps(m_dialect, std::move(m_ast), _optimisationSteps); } std::ostream& phaser::operator<<(std::ostream& _stream, Program const& _program) @@ -111,7 +110,7 @@ std::ostream& phaser::operator<<(std::ostream& _stream, Program const& _program) std::string Program::toJson() const { - Json serializedAst = AsmJsonConverter(m_dialect, 0)(m_ast->root()); + Json serializedAst = AsmJsonConverter(m_dialect, m_ast->labels(), 0)(m_ast->root()); return jsonPrettyPrint(removeNullMembers(std::move(serializedAst))); } @@ -150,7 +149,7 @@ std::variant, ErrorList> Program::parseObject(Dialect const // The public API of the class does not provide access to the smart pointer so it won't be hard // to switch to shared_ptr if the copying turns out to be an issue (though it would be better // to refactor ObjectParser and Object to use unique_ptr instead). - auto astCopy = std::make_unique(_dialect, ASTLabelRegistry{}, std::get(ASTCopier{}(selectedObject->code()->root()))); + auto astCopy = std::make_unique(_dialect, selectedObject->code()->labels(), std::get(ASTCopier{}(selectedObject->code()->root()))); return std::variant, ErrorList>(std::move(astCopy)); } @@ -160,7 +159,7 @@ std::variant, ErrorList> Program::analyzeAST(Di ErrorList errors; ErrorReporter errorReporter(errors); auto analysisInfo = std::make_unique(); - AsmAnalyzer analyzer(*analysisInfo, errorReporter, _dialect); + AsmAnalyzer analyzer(*analysisInfo, errorReporter, _dialect, _ast.labels()); bool analysisSuccessful = analyzer.analyze(_ast.root()); if (!analysisSuccessful) @@ -176,25 +175,26 @@ std::unique_ptr Program::disambiguateAST( AsmAnalysisInfo const& _analysisInfo ) { + LabelIDDispenser dispenser(_ast.labels()); std::set const externallyUsedIdentifiers = {}; - Disambiguator disambiguator(_dialect, _analysisInfo, externallyUsedIdentifiers); + Disambiguator disambiguator(_dialect, _analysisInfo, dispenser, externallyUsedIdentifiers); - return std::make_unique(_dialect, ASTLabelRegistry{}, std::get(disambiguator(_ast.root()))); + return std::make_unique(_dialect, dispenser, std::get(disambiguator(_ast.root()))); } std::unique_ptr Program::applyOptimisationSteps( Dialect const& _dialect, - NameDispenser& _nameDispenser, std::unique_ptr _ast, std::vector const& _optimisationSteps ) { + LabelIDDispenser dispenser(_ast->labels()); // An empty set of reserved identifiers. It could be a constructor parameter but I don't // think it would be useful in this tool. Other tools (like yulopti) have it empty too. std::set const externallyUsedIdentifiers = {}; OptimiserStepContext context{ _dialect, - _nameDispenser, + dispenser, externallyUsedIdentifiers, frontend::OptimiserSettings::standard().expectedExecutionsPerDeployment }; @@ -203,7 +203,7 @@ std::unique_ptr Program::applyOptimisationSteps( for (std::string const& step: _optimisationSteps) OptimiserSuite::allSteps().at(step)->run(context, astRoot); - return std::make_unique(_dialect, ASTLabelRegistry{}, std::move(astRoot)); + return std::make_unique(_dialect, context.dispenser, std::move(astRoot)); } size_t Program::computeCodeSize(Block const& _ast, CodeWeights const& _weights) diff --git a/tools/yulPhaser/Program.h b/tools/yulPhaser/Program.h index 7ac7f3aad157..a997c83d4c5e 100644 --- a/tools/yulPhaser/Program.h +++ b/tools/yulPhaser/Program.h @@ -18,7 +18,6 @@ #pragma once -#include #include #include @@ -66,8 +65,7 @@ class Program Program(Program const& program); Program(Program&& program): m_ast(std::move(program.m_ast)), - m_dialect{program.m_dialect}, - m_nameDispenser(std::move(program.m_nameDispenser)) + m_dialect{program.m_dialect} {} Program operator=(Program const& program) = delete; Program operator=(Program&& program) = delete; @@ -77,6 +75,7 @@ class Program size_t codeSize(yul::CodeWeights const& _weights) const { return computeCodeSize(m_ast->root(), _weights); } yul::Block const& ast() const { return m_ast->root(); } + yul::ASTLabelRegistry const& labels() const { return m_ast->labels(); } friend std::ostream& operator<<(std::ostream& _stream, Program const& _program); std::string toJson() const; @@ -87,8 +86,7 @@ class Program std::unique_ptr _ast ): m_ast(std::move(_ast)), - m_dialect{_dialect}, - m_nameDispenser(_dialect, m_ast->root(), {}) + m_dialect{_dialect} {} static std::variant, langutil::ErrorList> parseObject( @@ -106,7 +104,6 @@ class Program ); static std::unique_ptr applyOptimisationSteps( yul::Dialect const& _dialect, - yul::NameDispenser& _nameDispenser, std::unique_ptr _ast, std::vector const& _optimisationSteps ); @@ -114,7 +111,6 @@ class Program std::unique_ptr m_ast; yul::Dialect const& m_dialect; - yul::NameDispenser m_nameDispenser; }; } From e654f4df3e08274a0647a528ebee3970b96d0578 Mon Sep 17 00:00:00 2001 From: clonker <1685266+clonker@users.noreply.github.com> Date: Wed, 26 Mar 2025 08:40:47 +0100 Subject: [PATCH 10/17] Yul Interpreter: Integrate numerical IDs --- test/tools/yulInterpreter/Inspector.cpp | 12 ++++++------ test/tools/yulInterpreter/Inspector.h | 17 ++++++++++++----- test/tools/yulInterpreter/Interpreter.cpp | 6 +++--- test/tools/yulInterpreter/Interpreter.h | 8 ++++++++ 4 files changed, 29 insertions(+), 14 deletions(-) diff --git a/test/tools/yulInterpreter/Inspector.cpp b/test/tools/yulInterpreter/Inspector.cpp index 5fec7f1c58d4..0e82cb71d457 100644 --- a/test/tools/yulInterpreter/Inspector.cpp +++ b/test/tools/yulInterpreter/Inspector.cpp @@ -52,7 +52,7 @@ void InspectedInterpreter::run( ) { Scope scope; - InspectedInterpreter{_inspector, _state, _ast.dialect(), scope, _disableExternalCalls, _disableMemoryTrace}(_ast.root()); + InspectedInterpreter{_inspector, _state, _ast.dialect(), _ast.labels(), scope, _disableExternalCalls, _disableMemoryTrace}(_ast.root()); } Inspector::NodeAction Inspector::queryUser(langutil::DebugData const& _data, std::map const& _variables) @@ -98,7 +98,7 @@ Inspector::NodeAction Inspector::queryUser(langutil::DebugData const& _data, std else if (input == "variables" || input == "v") { for (auto &&[yulStr, val]: _variables) - printVariable(yulStr.str(), val); + printVariable(m_labels[yulStr], val); std::cout << std::endl; } else if ( @@ -117,9 +117,9 @@ Inspector::NodeAction Inspector::queryUser(langutil::DebugData const& _data, std bool found = false; for (auto &&[yulStr, val]: _variables) - if (yulStr.str() == varname) + if (m_labels[yulStr] == varname) { - printVariable(varname, val); + printVariable(m_labels[yulStr], val); found = true; break; } @@ -140,14 +140,14 @@ std::string Inspector::currentSource(langutil::DebugData const& _data) const u256 InspectedInterpreter::evaluate(Expression const& _expression) { - InspectedExpressionEvaluator ev(m_inspector, m_state, m_dialect, *m_scope, m_variables, m_disableExternalCalls, m_disableMemoryTrace); + InspectedExpressionEvaluator ev(m_inspector, m_state, m_dialect, m_labels, *m_scope, m_variables, m_disableExternalCalls, m_disableMemoryTrace); ev.visit(_expression); return ev.value(); } std::vector InspectedInterpreter::evaluateMulti(Expression const& _expression) { - InspectedExpressionEvaluator ev(m_inspector, m_state, m_dialect, *m_scope, m_variables, m_disableExternalCalls, m_disableMemoryTrace); + InspectedExpressionEvaluator ev(m_inspector, m_state, m_dialect, m_labels, *m_scope, m_variables, m_disableExternalCalls, m_disableMemoryTrace); ev.visit(_expression); return ev.values(); } diff --git a/test/tools/yulInterpreter/Inspector.h b/test/tools/yulInterpreter/Inspector.h index 3ea669b438a9..50611b23b15b 100644 --- a/test/tools/yulInterpreter/Inspector.h +++ b/test/tools/yulInterpreter/Inspector.h @@ -46,8 +46,8 @@ class Inspector StepThroughNode, }; - Inspector(std::string const& _source, InterpreterState const& _state) - :m_source(_source), m_state(_state) {} + Inspector(std::string const& _source, InterpreterState const& _state, ASTLabelRegistry const& _labels): + m_source(_source), m_state(_state), m_labels(_labels) {} /* Asks the user what action to take. * @returns NodeAction::RunNode if the current AST node (and all children nodes!) should be @@ -86,6 +86,8 @@ class Inspector /// State of the interpreter InterpreterState const& m_state; + ASTLabelRegistry const& m_labels; + /// Last user query command std::string m_lastInput; @@ -112,12 +114,13 @@ class InspectedInterpreter: public Interpreter std::shared_ptr _inspector, InterpreterState& _state, Dialect const& _dialect, + ASTLabelRegistry const& _labels, Scope& _scope, bool _disableExternalCalls, bool _disableMemoryTracing, std::map _variables = {} ): - Interpreter(_state, _dialect, _scope, _disableExternalCalls, _disableMemoryTracing, _variables), + Interpreter(_state, _dialect, _labels, _scope, _disableExternalCalls, _disableMemoryTracing, _variables), m_inspector(_inspector) { } @@ -158,12 +161,13 @@ class InspectedExpressionEvaluator: public ExpressionEvaluator std::shared_ptr _inspector, InterpreterState& _state, Dialect const& _dialect, + ASTLabelRegistry const& _labels, Scope& _scope, std::map const& _variables, bool _disableExternalCalls, bool _disableMemoryTrace ): - ExpressionEvaluator(_state, _dialect, _scope, _variables, _disableExternalCalls, _disableMemoryTrace), + ExpressionEvaluator(_state, _dialect, _labels, _scope, _variables, _disableExternalCalls, _disableMemoryTrace), m_inspector(_inspector) {} @@ -185,6 +189,7 @@ class InspectedExpressionEvaluator: public ExpressionEvaluator m_inspector, m_state, m_dialect, + m_labels, m_scope, m_disableExternalCalls, m_disableMemoryTrace, @@ -196,10 +201,12 @@ class InspectedExpressionEvaluator: public ExpressionEvaluator return std::make_unique( std::make_unique( m_inspector->source(), - _state + _state, + m_labels ), _state, m_dialect, + m_labels, _scope, m_disableExternalCalls, m_disableMemoryTrace diff --git a/test/tools/yulInterpreter/Interpreter.cpp b/test/tools/yulInterpreter/Interpreter.cpp index 05db9f581fa5..67494376407c 100644 --- a/test/tools/yulInterpreter/Interpreter.cpp +++ b/test/tools/yulInterpreter/Interpreter.cpp @@ -115,7 +115,7 @@ void Interpreter::run( ) { Scope scope; - Interpreter{_state, _ast.dialect(), scope, _disableExternalCalls, _disableMemoryTrace}(_ast.root()); + Interpreter{_state, _ast.dialect(), _ast.labels(), scope, _disableExternalCalls, _disableMemoryTrace}(_ast.root()); } void Interpreter::operator()(ExpressionStatement const& _expressionStatement) @@ -250,14 +250,14 @@ void Interpreter::operator()(Block const& _block) u256 Interpreter::evaluate(Expression const& _expression) { - ExpressionEvaluator ev(m_state, m_dialect, *m_scope, m_variables, m_disableExternalCalls, m_disableMemoryTrace); + ExpressionEvaluator ev(m_state, m_dialect, m_labels, *m_scope, m_variables, m_disableExternalCalls, m_disableMemoryTrace); ev.visit(_expression); return ev.value(); } std::vector Interpreter::evaluateMulti(Expression const& _expression) { - ExpressionEvaluator ev(m_state, m_dialect, *m_scope, m_variables, m_disableExternalCalls, m_disableMemoryTrace); + ExpressionEvaluator ev(m_state, m_dialect, m_labels, *m_scope, m_variables, m_disableExternalCalls, m_disableMemoryTrace); ev.visit(_expression); return ev.values(); } diff --git a/test/tools/yulInterpreter/Interpreter.h b/test/tools/yulInterpreter/Interpreter.h index 3dd6a4238d97..0ba7f32395c7 100644 --- a/test/tools/yulInterpreter/Interpreter.h +++ b/test/tools/yulInterpreter/Interpreter.h @@ -171,12 +171,14 @@ class Interpreter: public ASTWalker Interpreter( InterpreterState& _state, Dialect const& _dialect, + ASTLabelRegistry const& _labels, Scope& _scope, bool _disableExternalCalls, bool _disableMemoryTracing, std::map _variables = {} ): m_dialect(_dialect), + m_labels(_labels), m_state(_state), m_variables(std::move(_variables)), m_scope(&_scope), @@ -216,6 +218,7 @@ class Interpreter: public ASTWalker void incrementStep(); Dialect const& m_dialect; + ASTLabelRegistry const& m_labels; InterpreterState& m_state; /// Values of variables. std::map m_variables; @@ -235,6 +238,7 @@ class ExpressionEvaluator: public ASTWalker ExpressionEvaluator( InterpreterState& _state, Dialect const& _dialect, + ASTLabelRegistry const& _labels, Scope& _scope, std::map const& _variables, bool _disableExternalCalls, @@ -242,6 +246,7 @@ class ExpressionEvaluator: public ASTWalker ): m_state(_state), m_dialect(_dialect), + m_labels(_labels), m_variables(_variables), m_scope(_scope), m_disableExternalCalls(_disableExternalCalls), @@ -264,6 +269,7 @@ class ExpressionEvaluator: public ASTWalker return std::make_unique( m_state, m_dialect, + m_labels, m_scope, m_disableExternalCalls, m_disableMemoryTrace, @@ -275,6 +281,7 @@ class ExpressionEvaluator: public ASTWalker return std::make_unique( _state, m_dialect, + m_labels, _scope, m_disableExternalCalls, m_disableMemoryTrace @@ -297,6 +304,7 @@ class ExpressionEvaluator: public ASTWalker InterpreterState& m_state; Dialect const& m_dialect; + ASTLabelRegistry const& m_labels; /// Values of variables. std::map const& m_variables; Scope& m_scope; From be4072b69c18a2112c4ba65a1e274fc4e99a0231 Mon Sep 17 00:00:00 2001 From: clonker <1685266+clonker@users.noreply.github.com> Date: Wed, 12 Mar 2025 14:12:20 +0100 Subject: [PATCH 11/17] Update test expectations for numerical label IDs in Yul --- test/cmdlineTests/ast_ir/output | 14 +- .../constant_optimizer_yul/output | 10 +- .../output | 10 +- .../output | 10 +- .../output | 10 +- .../debug_info_in_yul_snippet_escaping/output | 30 +-- .../output | 64 ++--- .../output | 20 +- .../ir_compiler_subobjects/output | 40 +-- .../output | 10 +- .../ir_optimized_with_optimize/output | 10 +- test/cmdlineTests/ir_subobject_order/output | 40 +-- .../output | 10 +- .../keccak_optimization_low_runs/output | 10 +- .../output | 10 +- .../output | 10 +- test/cmdlineTests/name_simplifier/output | 10 +- .../cmdlineTests/optimizer_array_sload/output | 28 +- .../stack_too_deep_from_code_transform/err | 2 +- .../output.json | 10 +- .../output.json | 10 +- .../output.json | 10 +- .../output.json | 140 +++++----- .../output.json | 18 +- .../output.json | 84 +++--- .../output.json | 248 +++++++++--------- .../output.json | 248 +++++++++--------- .../output.json | 248 +++++++++--------- .../output.json | 248 +++++++++--------- .../output.json | 248 +++++++++--------- .../output.json | 20 +- .../output.json | 4 +- .../output.json | 4 +- .../output.json | 4 +- .../output | 10 +- .../strict_asm_debug_info_print_all/output | 4 +- .../output | 4 +- .../strict_asm_debug_info_print_none/output | 4 +- test/cmdlineTests/viair_subobjects/output | 40 +-- .../yul_function_name_clashes/output | 4 +- .../output | 12 +- .../output | 18 +- .../output | 84 +++--- ...on_external_storage_to_storage_dynamic.sol | 2 +- test/libyul/yulControlFlowGraph/complex.yul | 10 +- test/libyul/yulControlFlowGraph/switch.yul | 6 +- .../movable_functions.yul | 4 +- .../disambiguator/for_statement.yul | 2 +- .../disambiguator/function_call.yul | 4 +- .../disambiguator/if_statement.yul | 2 +- .../disambiguator/switch_statement.yul | 4 +- .../variables_inside_functions.yul | 6 +- .../simple_different_vars.yul | 4 +- .../argument_duplication_heuristic.yul | 4 +- .../combine_add_and_mod_constant.yul | 6 +- .../combine_mul_and_mod_constant.yul | 6 +- .../combine_shift_and_and_2.yul | 26 +- .../combine_shift_and_and_3.yul | 4 +- .../expressionSimplifier/create_and_mask.yul | 6 +- .../exp_simplifications.yul | 4 +- .../mcopy_non_zero_size.yul | 4 +- .../expressionSimplifier/mod_and_1.yul | 4 +- .../expressionSimplifier/mod_and_2.yul | 4 +- ...lied_function_call_different_arguments.yul | 6 +- .../remove_redundant_shift_masking.yul | 12 +- .../replace_too_large_shift.yul | 8 +- .../unassigend_vars_multi.yul | 2 +- .../fakeStackLimitEvader/connected.yul | 34 +-- ...lti_variable_declaration_without_value.yul | 4 +- .../fakeStackLimitEvader/return_leave.yul | 12 +- .../return_one_with_args.yul | 4 +- .../fakeStackLimitEvader/stub.yul | 56 ++-- .../call_arguments_with_side_effects.yul | 12 +- .../call_arguments_without_side_effects.yul | 34 +-- .../fullInliner/double_inline.yul | 26 +- .../fullInliner/inside_condition.yul | 12 +- .../fullInliner/large_function_multi_use.yul | 42 +-- .../fullInliner/large_function_single_use.yul | 18 +- .../fullInliner/long_names.yul | 8 +- .../move_up_rightwards_argument.yul | 24 +- .../fullInliner/multi_fun.yul | 32 +-- .../fullInliner/multi_fun_callback.yul | 8 +- .../fullInliner/multi_return.yul | 14 +- .../no_inline_into_big_function.yul | 82 +++--- .../no_inline_into_big_global_context.yul | 80 +++--- .../fullInliner/no_inline_leave.yul | 4 +- .../fullInliner/no_return.yul | 4 +- .../fullInliner/not_inside_for.yul | 30 +-- .../fullInliner/pop_result.yul | 10 +- .../yulOptimizerTests/fullInliner/simple.yul | 12 +- .../call_arguments_without_side_effects.yul | 10 +- .../fullInlinerWithoutSplitter/simple.yul | 6 +- .../fullSimplify/constant_propagation.yul | 4 +- .../fullSimplify/invariant.yul | 4 +- .../fullSimplify/mod_and_1.yul | 4 +- .../fullSimplify/mod_and_2.yul | 4 +- ...lied_function_call_different_arguments.yul | 6 +- .../scoped_var_ref_in_function_call.yul | 10 +- .../yulOptimizerTests/fullSuite/abi2.yul | 66 ++--- .../fullSuite/abi_example1.yul | 88 +++---- .../yulOptimizerTests/fullSuite/aztec.yul | 72 ++--- .../fullSuite/loopInvariantCodeMotion.yul | 10 +- .../fullSuite/name_cleaner_reserved.yul | 10 +- .../name_dependent_cse_bug_part_2.yul | 4 +- ..._dependent_cse_bug_part_2_pre_shanghai.yul | 4 +- .../fullSuite/reserved_identifiers.yul | 15 +- .../fullSuite/ssaReverse.yul | 26 +- .../fullSuite/stack_compressor_msize.yul | 4 +- .../unusedFunctionParameterPruner.yul | 6 +- ...nusedFunctionParameterPruner_recursion.yul | 6 +- .../unusedFunctionParameterPruner_return.yul | 4 +- .../functionSpecializer/multiple.yul | 12 +- .../functionSpecializer/partial.yul | 10 +- .../functionSpecializer/simple.yul | 10 +- .../loadResolver/keccak_reuse_expr_mstore.yul | 4 +- .../keccak_reuse_in_expression.yul | 4 +- .../keccak_reuse_reassigned_branch.yul | 10 +- .../keccak_reuse_reassigned_value.yul | 10 +- .../loadResolver/keccak_short.yul | 8 +- .../memory_with_call_invalidation.yul | 10 +- .../memory_with_extcall_invalidation.yul | 10 +- .../loadResolver/memory_with_msize.yul | 6 +- .../loadResolver/merge_known_write.yul | 16 +- .../merge_known_write_with_distance.yul | 12 +- .../merge_mload_with_known_distance.yul | 10 +- .../loadResolver/merge_unknown_write.yul | 16 +- .../loadResolver/mload_in_function.yul | 6 +- .../mstore_in_function_loop_body.yul | 4 +- .../mstore_in_function_loop_init.yul | 4 +- .../loadResolver/multi_sload_loop.yul | 2 +- .../reassign_value_expression.yul | 12 +- .../loadResolver/second_mstore_with_delta.yul | 10 +- .../loadResolver/second_store.yul | 8 +- .../loadResolver/second_store_same_value.yul | 10 +- .../loadResolver/second_store_with_delta.yul | 10 +- .../side_effects_of_user_functions.yul | 8 +- .../yulOptimizerTests/loadResolver/simple.yul | 6 +- .../loadResolver/simple_memory.yul | 6 +- .../loadResolver/verbatim_sload.yul | 8 +- .../no_move_memory.yul | 8 +- .../no_move_memory_msize.yul | 6 +- .../loopInvariantCodeMotion/no_move_state.yul | 20 +- .../nameDisplacer/funtion_call.yul | 10 +- .../nameDisplacer/variables.yul | 4 +- .../variables_inside_functions.yul | 6 +- .../yulOptimizerTests/ssaAndBack/for_loop.yul | 4 +- .../ssaAndBack/multi_assign.yul | 4 +- .../ssaAndBack/multi_assign_multi_var_if.yul | 6 +- .../multi_assign_multi_var_switch.yul | 12 +- .../yulOptimizerTests/ssaAndBack/simple.yul | 4 +- .../yulOptimizerTests/ssaAndBack/two_vars.yul | 14 +- .../ssaPlusCleanup/control_structures.yul | 26 +- .../ssaTransform/for_def_in_init.yul | 14 +- .../ssaTransform/function.yul | 18 +- .../ssaTransform/multi_assign.yul | 18 +- .../ssaTransform/multi_decl.yul | 14 +- .../yulOptimizerTests/ssaTransform/nested.yul | 22 +- .../yulOptimizerTests/ssaTransform/typed.yul | 34 +-- .../stackLimitEvader/cycle_before_2.yul | 6 +- .../stackLimitEvader/tree.yul | 196 +++++++------- .../verbatim_many_arguments_and_returns.yul | 42 +-- .../verbatim_many_returns.yul | 66 ++--- .../unusedAssignEliminator/leave.yul | 8 +- .../LiteralRematerialiser.yul | 4 +- .../multiple_param.yul | 4 +- .../multiple_return.yul | 4 +- .../nested_function.yul | 10 +- .../nested_function_name_collision.yul | 18 +- .../no_return.yul | 4 +- .../recursion.yul | 4 +- .../unusedFunctionParameterPruner/simple.yul | 4 +- .../too_many_arguments.yul | 4 +- .../covering_calldatacopy.yul | 22 +- .../covering_calldatacopy_fixed.yul | 8 +- .../unusedStoreEliminator/function_end.yul | 2 +- .../if_overwrite_all_branches.yul | 4 +- .../unusedStoreEliminator/leave.yul | 4 +- .../unusedStoreEliminator/memoryguard.yul | 6 +- .../no_storage_inside_function.yul | 4 +- .../remove_before_revert.yul | 4 +- .../unusedStoreEliminator/tstore.yul | 2 +- .../unusedStoreEliminator/unknown_length2.yul | 16 +- .../unrelated_relative.yul | 10 +- .../varNameCleaner/builtins.yul | 7 - .../varNameCleaner/function_names.yul | 16 -- .../varNameCleaner/function_parameters.yul | 25 -- .../varNameCleaner/function_scopes.yul | 14 - .../varNameCleaner/instructions.yul | 7 - .../varNameCleaner/name_stripping.yul | 17 -- .../varNameCleaner/reshuffling-inverse.yul | 17 -- .../varNameCleaner/reshuffling.yul | 15 -- test/libyul/yulStackLayout/complex.yul | 30 +-- test/libyul/yulStackLayout/switch.yul | 14 +- 193 files changed, 2064 insertions(+), 2177 deletions(-) delete mode 100644 test/libyul/yulOptimizerTests/varNameCleaner/builtins.yul delete mode 100644 test/libyul/yulOptimizerTests/varNameCleaner/function_names.yul delete mode 100644 test/libyul/yulOptimizerTests/varNameCleaner/function_parameters.yul delete mode 100644 test/libyul/yulOptimizerTests/varNameCleaner/function_scopes.yul delete mode 100644 test/libyul/yulOptimizerTests/varNameCleaner/instructions.yul delete mode 100644 test/libyul/yulOptimizerTests/varNameCleaner/name_stripping.yul delete mode 100644 test/libyul/yulOptimizerTests/varNameCleaner/reshuffling-inverse.yul delete mode 100644 test/libyul/yulOptimizerTests/varNameCleaner/reshuffling.yul diff --git a/test/cmdlineTests/ast_ir/output b/test/cmdlineTests/ast_ir/output index 88047ade02b3..883e5434520f 100644 --- a/test/cmdlineTests/ast_ir/output +++ b/test/cmdlineTests/ast_ir/output @@ -673,7 +673,7 @@ Optimized IR AST: }, "variables": [ { - "name": "_1", + "name": "_2", "nativeSrc": "125:2:0", "nodeType": "YulTypedName", "src": "60:13:0", @@ -693,7 +693,7 @@ Optimized IR AST: "value": "64" }, { - "name": "_1", + "name": "_2", "nativeSrc": "172:2:0", "nodeType": "YulIdentifier", "src": "60:13:0" @@ -799,7 +799,7 @@ Optimized IR AST: }, "variables": [ { - "name": "_2", + "name": "_1", "nativeSrc": "236:2:0", "nodeType": "YulTypedName", "src": "60:13:0", @@ -811,7 +811,7 @@ Optimized IR AST: "expression": { "arguments": [ { - "name": "_1", + "name": "_2", "nativeSrc": "288:2:0", "nodeType": "YulIdentifier", "src": "60:13:0" @@ -839,7 +839,7 @@ Optimized IR AST: "src": "60:13:0" }, { - "name": "_2", + "name": "_1", "nativeSrc": "320:2:0", "nodeType": "YulIdentifier", "src": "60:13:0" @@ -863,13 +863,13 @@ Optimized IR AST: "expression": { "arguments": [ { - "name": "_1", + "name": "_2", "nativeSrc": "343:2:0", "nodeType": "YulIdentifier", "src": "60:13:0" }, { - "name": "_2", + "name": "_1", "nativeSrc": "347:2:0", "nodeType": "YulIdentifier", "src": "60:13:0" diff --git a/test/cmdlineTests/constant_optimizer_yul/output b/test/cmdlineTests/constant_optimizer_yul/output index c0d3ab934641..6ffd3c5c5717 100644 --- a/test/cmdlineTests/constant_optimizer_yul/output +++ b/test/cmdlineTests/constant_optimizer_yul/output @@ -4,15 +4,15 @@ object "C_12" { code { { /// @src 0:61:418 "contract C {..." - let _1 := memoryguard(0x80) - mstore(64, _1) + let _2 := memoryguard(0x80) + mstore(64, _2) if callvalue() { revert(0, 0) } /// @src 0:103:238 "assembly {..." sstore(0, shl(180, 1)) /// @src 0:61:418 "contract C {..." - let _2 := datasize("C_12_deployed") - codecopy(_1, dataoffset("C_12_deployed"), _2) - return(_1, _2) + let _1 := datasize("C_12_deployed") + codecopy(_2, dataoffset("C_12_deployed"), _1) + return(_2, _1) } } /// @use-src 0:"input.sol" diff --git a/test/cmdlineTests/debug_info_in_yul_and_evm_asm_print_all/output b/test/cmdlineTests/debug_info_in_yul_and_evm_asm_print_all/output index 7ad569ba1107..987f82dbe4de 100644 --- a/test/cmdlineTests/debug_info_in_yul_and_evm_asm_print_all/output +++ b/test/cmdlineTests/debug_info_in_yul_and_evm_asm_print_all/output @@ -168,12 +168,12 @@ object "C_6" { code { { /// @src 0:60:101 "contract C {..." - let _1 := memoryguard(0x80) - mstore(64, _1) + let _2 := memoryguard(0x80) + mstore(64, _2) if callvalue() { revert(0, 0) } - let _2 := datasize("C_6_deployed") - codecopy(_1, dataoffset("C_6_deployed"), _2) - return(_1, _2) + let _1 := datasize("C_6_deployed") + codecopy(_2, dataoffset("C_6_deployed"), _1) + return(_2, _1) } } /// @use-src 0:"input.sol" diff --git a/test/cmdlineTests/debug_info_in_yul_and_evm_asm_print_location_only/output b/test/cmdlineTests/debug_info_in_yul_and_evm_asm_print_location_only/output index 36ef4d8294ab..c7e9ec57f97b 100644 --- a/test/cmdlineTests/debug_info_in_yul_and_evm_asm_print_location_only/output +++ b/test/cmdlineTests/debug_info_in_yul_and_evm_asm_print_location_only/output @@ -167,12 +167,12 @@ object "C_6" { code { { /// @src 0:60:101 - let _1 := memoryguard(0x80) - mstore(64, _1) + let _2 := memoryguard(0x80) + mstore(64, _2) if callvalue() { revert(0, 0) } - let _2 := datasize("C_6_deployed") - codecopy(_1, dataoffset("C_6_deployed"), _2) - return(_1, _2) + let _1 := datasize("C_6_deployed") + codecopy(_2, dataoffset("C_6_deployed"), _1) + return(_2, _1) } } /// @use-src 0:"input.sol" diff --git a/test/cmdlineTests/debug_info_in_yul_and_evm_asm_print_none/output b/test/cmdlineTests/debug_info_in_yul_and_evm_asm_print_none/output index ea3cb35a2849..d63b0b1ec2b8 100644 --- a/test/cmdlineTests/debug_info_in_yul_and_evm_asm_print_none/output +++ b/test/cmdlineTests/debug_info_in_yul_and_evm_asm_print_none/output @@ -157,12 +157,12 @@ Optimized IR: object "C_6" { code { { - let _1 := memoryguard(0x80) - mstore(64, _1) + let _2 := memoryguard(0x80) + mstore(64, _2) if callvalue() { revert(0, 0) } - let _2 := datasize("C_6_deployed") - codecopy(_1, dataoffset("C_6_deployed"), _2) - return(_1, _2) + let _1 := datasize("C_6_deployed") + codecopy(_2, dataoffset("C_6_deployed"), _1) + return(_2, _1) } } /// @use-src 0:"input.sol" diff --git a/test/cmdlineTests/debug_info_in_yul_snippet_escaping/output b/test/cmdlineTests/debug_info_in_yul_snippet_escaping/output index c29dfd89265d..51bc3e120aae 100644 --- a/test/cmdlineTests/debug_info_in_yul_snippet_escaping/output +++ b/test/cmdlineTests/debug_info_in_yul_snippet_escaping/output @@ -68,12 +68,12 @@ object "C_2" { code { { /// @src 0:265:278 "contract C {}" - let _1 := memoryguard(0x80) - mstore(64, _1) + let _2 := memoryguard(0x80) + mstore(64, _2) if callvalue() { revert(0, 0) } - let _2 := datasize("C_2_deployed") - codecopy(_1, dataoffset("C_2_deployed"), _2) - return(_1, _2) + let _1 := datasize("C_2_deployed") + codecopy(_2, dataoffset("C_2_deployed"), _1) + return(_2, _1) } } /// @use-src 0:"input.sol" @@ -415,12 +415,12 @@ object "D_27" { code { { /// @src 0:279:599 "contract D /** @src 0:96:165 \"contract D {...\" *\/ {..." - let _1 := memoryguard(0x80) - mstore(64, _1) + let _2 := memoryguard(0x80) + mstore(64, _2) if callvalue() { revert(0, 0) } - let _2 := datasize("D_27_deployed") - codecopy(_1, dataoffset("D_27_deployed"), _2) - return(_1, _2) + let _1 := datasize("D_27_deployed") + codecopy(_2, dataoffset("D_27_deployed"), _1) + return(_2, _1) } } /// @use-src 0:"input.sol" @@ -504,12 +504,12 @@ object "D_27" { code { { /// @src 0:265:278 "contract C {}" - let _1 := memoryguard(0x80) - mstore(64, _1) + let _2 := memoryguard(0x80) + mstore(64, _2) if callvalue() { revert(0, 0) } - let _2 := datasize("C_2_deployed") - codecopy(_1, dataoffset("C_2_deployed"), _2) - return(_1, _2) + let _1 := datasize("C_2_deployed") + codecopy(_2, dataoffset("C_2_deployed"), _1) + return(_2, _1) } } /// @use-src 0:"input.sol" diff --git a/test/cmdlineTests/inline_assembly_function_name_clash/output b/test/cmdlineTests/inline_assembly_function_name_clash/output index d21576ff0ba0..dfaa6bfee741 100644 --- a/test/cmdlineTests/inline_assembly_function_name_clash/output +++ b/test/cmdlineTests/inline_assembly_function_name_clash/output @@ -2,64 +2,64 @@ "contracts": { "input.sol:C": { "function-debug-runtime": { - "abi_decode": { + "abi_decode_tuple_": { "entryPoint": 80, "parameterSlots": 2, "returnSlots": 0 }, - "abi_encode_uint256": { - "entryPoint": 111, - "parameterSlots": 2, - "returnSlots": 1 - }, - "abi_encode_uint256_to_uint256": { + "abi_encode_t_uint256_to_t_uint256_fromStack": { "entryPoint": 98, "parameterSlots": 2, "returnSlots": 0 }, + "abi_encode_tuple_t_uint256__to_t_uint256__fromStack": { + "entryPoint": 111, + "parameterSlots": 2, + "returnSlots": 1 + }, "allocate_unbounded": { "entryPoint": 66, "parameterSlots": 0, "returnSlots": 1 }, - "cleanup_uint256": { + "cleanup_t_uint256": { "entryPoint": 95, "parameterSlots": 1, "returnSlots": 1 }, - "convert_uint256_to_uint256": { + "convert_t_uint256_to_t_uint256": { "entryPoint": 276, "parameterSlots": 1, "returnSlots": 1 }, - "external_fun_f": { + "external_fun_f_25": { "entryPoint": 132, "parameterSlots": 0, "returnSlots": 0 }, - "external_fun_g": { + "external_fun_g_36": { "entryPoint": 185, "parameterSlots": 0, "returnSlots": 0 }, - "fun_f": { + "fun_f_25": { "entryPoint": 442, "id": 25, "parameterSlots": 0, "returnSlots": 1 }, - "fun_f_inner": { + "fun_f_25_inner": { "entryPoint": 430, "parameterSlots": 1, "returnSlots": 1 }, - "fun_g": { + "fun_g_36": { "entryPoint": 564, "id": 36, "parameterSlots": 0, "returnSlots": 1 }, - "fun_g_inner": { + "fun_g_36_inner": { "entryPoint": 552, "parameterSlots": 1, "returnSlots": 1 @@ -69,12 +69,6 @@ "parameterSlots": 1, "returnSlots": 1 }, - "modifier_m": { - "entryPoint": 509, - "id": 14, - "parameterSlots": 1, - "returnSlots": 1 - }, "modifier_m_17": { "entryPoint": 344, "id": 14, @@ -93,7 +87,13 @@ "parameterSlots": 1, "returnSlots": 1 }, - "prepare_store_uint256": { + "modifier_m_30": { + "entryPoint": 509, + "id": 14, + "parameterSlots": 1, + "returnSlots": 1 + }, + "prepare_store_t_uint256": { "entryPoint": 304, "parameterSlots": 1, "returnSlots": 1 @@ -113,22 +113,22 @@ "parameterSlots": 0, "returnSlots": 0 }, - "shift_left": { + "shift_left_0": { "entryPoint": 246, "parameterSlots": 1, "returnSlots": 1 }, - "shift_right_unsigned": { + "shift_right_224_unsigned": { "entryPoint": 60, "parameterSlots": 1, "returnSlots": 1 }, - "update_byte_slice_shift": { + "update_byte_slice_32_shift_0": { "entryPoint": 251, "parameterSlots": 2, "returnSlots": 1 }, - "update_storage_value_offset_uint256_to_uint256": { + "update_storage_value_offset_0_t_uint256_to_t_uint256": { "entryPoint": 307, "parameterSlots": 2, "returnSlots": 0 @@ -138,32 +138,32 @@ "parameterSlots": 0, "returnSlots": 1 }, - "usr$f_17": { + "usr$f_1": { "entryPoint": 382, "parameterSlots": 0, "returnSlots": 1 }, - "usr$f_22": { + "usr$f_2": { "entryPoint": 425, "parameterSlots": 0, "returnSlots": 1 }, - "usr$f_26": { + "usr$f_3": { "entryPoint": 461, "parameterSlots": 0, "returnSlots": 1 }, - "usr$f_32": { + "usr$f_4": { "entryPoint": 504, "parameterSlots": 0, "returnSlots": 1 }, - "usr$f_37": { + "usr$f_5": { "entryPoint": 547, "parameterSlots": 0, "returnSlots": 1 }, - "zero_value_for_split_uint256": { + "zero_value_for_split_t_uint256": { "entryPoint": 242, "parameterSlots": 0, "returnSlots": 1 diff --git a/test/cmdlineTests/ir_compiler_inheritance_nosubobjects/output b/test/cmdlineTests/ir_compiler_inheritance_nosubobjects/output index 2d715d0abaad..9e099faad0b4 100644 --- a/test/cmdlineTests/ir_compiler_inheritance_nosubobjects/output +++ b/test/cmdlineTests/ir_compiler_inheritance_nosubobjects/output @@ -4,12 +4,12 @@ object "C_7" { code { { /// @src 0:82:117 "contract C {..." - let _1 := memoryguard(0x80) - mstore(64, _1) + let _2 := memoryguard(0x80) + mstore(64, _2) if callvalue() { revert(0, 0) } - let _2 := datasize("C_7_deployed") - codecopy(_1, dataoffset("C_7_deployed"), _2) - return(_1, _2) + let _1 := datasize("C_7_deployed") + codecopy(_2, dataoffset("C_7_deployed"), _1) + return(_2, _1) } } /// @use-src 0:"input.sol" @@ -30,12 +30,12 @@ object "D_10" { code { { /// @src 0:118:137 "contract D is C {..." - let _1 := memoryguard(0x80) - mstore(64, _1) + let _2 := memoryguard(0x80) + mstore(64, _2) if callvalue() { revert(0, 0) } - let _2 := datasize("D_10_deployed") - codecopy(_1, dataoffset("D_10_deployed"), _2) - return(_1, _2) + let _1 := datasize("D_10_deployed") + codecopy(_2, dataoffset("D_10_deployed"), _1) + return(_2, _1) } } /// @use-src 0:"input.sol" diff --git a/test/cmdlineTests/ir_compiler_subobjects/output b/test/cmdlineTests/ir_compiler_subobjects/output index 08ee8bf5d0b5..b5f141539bf0 100644 --- a/test/cmdlineTests/ir_compiler_subobjects/output +++ b/test/cmdlineTests/ir_compiler_subobjects/output @@ -4,12 +4,12 @@ object "C_3" { code { { /// @src 0:82:95 "contract C {}" - let _1 := memoryguard(0x80) - mstore(64, _1) + let _2 := memoryguard(0x80) + mstore(64, _2) if callvalue() { revert(0, 0) } - let _2 := datasize("C_3_deployed") - codecopy(_1, dataoffset("C_3_deployed"), _2) - return(_1, _2) + let _1 := datasize("C_3_deployed") + codecopy(_2, dataoffset("C_3_deployed"), _1) + return(_2, _1) } } /// @use-src 0:"input.sol" @@ -30,12 +30,12 @@ object "D_16" { code { { /// @src 0:96:165 "contract D {..." - let _1 := memoryguard(0x80) - mstore(64, _1) + let _2 := memoryguard(0x80) + mstore(64, _2) if callvalue() { revert(0, 0) } - let _2 := datasize("D_16_deployed") - codecopy(_1, dataoffset("D_16_deployed"), _2) - return(_1, _2) + let _1 := datasize("D_16_deployed") + codecopy(_2, dataoffset("D_16_deployed"), _1) + return(_2, _1) } } /// @use-src 0:"input.sol" @@ -52,9 +52,9 @@ object "D_16" { if callvalue() { revert(0, 0) } if slt(add(calldatasize(), not(3)), 0) { revert(0, 0) } /// @src 0:149:156 "new C()" - let _2 := datasize("C_3") - let _3 := add(_1, _2) - if or(gt(_3, 0xffffffffffffffff), lt(_3, _1)) + let _3 := datasize("C_3") + let _2 := add(_1, _3) + if or(gt(_2, 0xffffffffffffffff), lt(_2, _1)) { /// @src 0:96:165 "contract D {..." mstore(0, shl(224, 0x4e487b71)) @@ -62,8 +62,8 @@ object "D_16" { revert(0, 0x24) } /// @src 0:149:156 "new C()" - datacopy(_1, dataoffset("C_3"), _2) - if iszero(create(/** @src 0:96:165 "contract D {..." */ 0, /** @src 0:149:156 "new C()" */ _1, sub(_3, _1))) + datacopy(_1, dataoffset("C_3"), _3) + if iszero(create(/** @src 0:96:165 "contract D {..." */ 0, /** @src 0:149:156 "new C()" */ _1, sub(_2, _1))) { /// @src 0:96:165 "contract D {..." let pos := mload(64) @@ -81,12 +81,12 @@ object "D_16" { code { { /// @src 0:82:95 "contract C {}" - let _1 := memoryguard(0x80) - mstore(64, _1) + let _2 := memoryguard(0x80) + mstore(64, _2) if callvalue() { revert(0, 0) } - let _2 := datasize("C_3_deployed") - codecopy(_1, dataoffset("C_3_deployed"), _2) - return(_1, _2) + let _1 := datasize("C_3_deployed") + codecopy(_2, dataoffset("C_3_deployed"), _1) + return(_2, _1) } } /// @use-src 0:"input.sol" diff --git a/test/cmdlineTests/ir_optimized_transient_storage_value_type/output b/test/cmdlineTests/ir_optimized_transient_storage_value_type/output index 2f6918cabb36..fc200eea8f55 100644 --- a/test/cmdlineTests/ir_optimized_transient_storage_value_type/output +++ b/test/cmdlineTests/ir_optimized_transient_storage_value_type/output @@ -3,12 +3,12 @@ Optimized IR: object "C_14" { code { { - let _1 := memoryguard(0x80) - mstore(64, _1) + let _2 := memoryguard(0x80) + mstore(64, _2) if callvalue() { revert(0, 0) } - let _2 := datasize("C_14_deployed") - codecopy(_1, dataoffset("C_14_deployed"), _2) - return(_1, _2) + let _1 := datasize("C_14_deployed") + codecopy(_2, dataoffset("C_14_deployed"), _1) + return(_2, _1) } } /// @use-src 0:"input.sol" diff --git a/test/cmdlineTests/ir_optimized_with_optimize/output b/test/cmdlineTests/ir_optimized_with_optimize/output index bae07ea4eb05..9d3f03b32295 100644 --- a/test/cmdlineTests/ir_optimized_with_optimize/output +++ b/test/cmdlineTests/ir_optimized_with_optimize/output @@ -3,12 +3,12 @@ Optimized IR: object "C_2" { code { { - let _1 := memoryguard(0x80) - mstore(64, _1) + let _2 := memoryguard(0x80) + mstore(64, _2) if callvalue() { revert(0, 0) } - let _2 := datasize("C_2_deployed") - codecopy(_1, dataoffset("C_2_deployed"), _2) - return(_1, _2) + let _1 := datasize("C_2_deployed") + codecopy(_2, dataoffset("C_2_deployed"), _1) + return(_2, _1) } } /// @use-src 0:"input.sol" diff --git a/test/cmdlineTests/ir_subobject_order/output b/test/cmdlineTests/ir_subobject_order/output index d41b65bf9a62..d3c5da5037a4 100644 --- a/test/cmdlineTests/ir_subobject_order/output +++ b/test/cmdlineTests/ir_subobject_order/output @@ -25,48 +25,48 @@ Optimized IR: object "C_33" { code { { - let _1 := memoryguard(0x80) - mstore(64, _1) + let _6 := memoryguard(0x80) + mstore(64, _6) if callvalue() { revert(0, 0) } - let _2 := datasize("A_13") - let _3 := add(_1, _2) - if or(gt(_3, sub(shl(64, 1), 1)), lt(_3, _1)) + let _7 := datasize("A_13") + let _3 := add(_6, _7) + if or(gt(_3, sub(shl(64, 1), 1)), lt(_3, _6)) { mstore(0, shl(224, 0x4e487b71)) mstore(4, 0x41) revert(0, 0x24) } - datacopy(_1, dataoffset("A_13"), _2) - let expr_address := create(0, _1, sub(_3, _1)) - if iszero(expr_address) + datacopy(_6, dataoffset("A_13"), _7) + let expr_19_address := create(0, _6, sub(_3, _6)) + if iszero(expr_19_address) { let pos := mload(64) returndatacopy(pos, 0, returndatasize()) revert(pos, returndatasize()) } - sstore(0, or(and(sload(0), not(sub(shl(160, 1), 1))), and(expr_address, sub(shl(160, 1), 1)))) + sstore(0, or(and(sload(0), not(sub(shl(160, 1), 1))), and(expr_19_address, sub(shl(160, 1), 1)))) let _4 := mload(64) - let _5 := datasize("B_7") - let _6 := add(_4, _5) - if or(gt(_6, sub(shl(64, 1), 1)), lt(_6, _4)) + let _8 := datasize("B_7") + let _5 := add(_4, _8) + if or(gt(_5, sub(shl(64, 1), 1)), lt(_5, _4)) { mstore(0, shl(224, 0x4e487b71)) mstore(4, 0x41) revert(0, 0x24) } - datacopy(_4, dataoffset("B_7"), _5) - let expr_address_1 := create(0, _4, sub(_6, _4)) - if iszero(expr_address_1) + datacopy(_4, dataoffset("B_7"), _8) + let expr_26_address := create(0, _4, sub(_5, _4)) + if iszero(expr_26_address) { let pos_1 := mload(64) returndatacopy(pos_1, 0, returndatasize()) revert(pos_1, returndatasize()) } - sstore(0x01, or(and(sload(0x01), not(sub(shl(160, 1), 1))), and(expr_address_1, sub(shl(160, 1), 1)))) - let _7 := mload(64) - let _8 := datasize("C_33_deployed") - codecopy(_7, dataoffset("C_33_deployed"), _8) - return(_7, _8) + sstore(0x01, or(and(sload(0x01), not(sub(shl(160, 1), 1))), and(expr_26_address, sub(shl(160, 1), 1)))) + let _1 := mload(64) + let _2 := datasize("C_33_deployed") + codecopy(_1, dataoffset("C_33_deployed"), _2) + return(_1, _2) } } /// @use-src 0:"input.sol" diff --git a/test/cmdlineTests/ir_with_assembly_no_memoryguard_runtime/output b/test/cmdlineTests/ir_with_assembly_no_memoryguard_runtime/output index 9d07cd910e9f..446d4f8618c3 100644 --- a/test/cmdlineTests/ir_with_assembly_no_memoryguard_runtime/output +++ b/test/cmdlineTests/ir_with_assembly_no_memoryguard_runtime/output @@ -4,12 +4,12 @@ object "D_8" { code { { /// @src 0:82:166 "contract D {..." - let _1 := memoryguard(0x80) - mstore(64, _1) + let _2 := memoryguard(0x80) + mstore(64, _2) if callvalue() { revert(0, 0) } - let _2 := datasize("D_8_deployed") - codecopy(_1, dataoffset("D_8_deployed"), _2) - return(_1, _2) + let _1 := datasize("D_8_deployed") + codecopy(_2, dataoffset("D_8_deployed"), _1) + return(_2, _1) } } /// @use-src 0:"input.sol" diff --git a/test/cmdlineTests/keccak_optimization_low_runs/output b/test/cmdlineTests/keccak_optimization_low_runs/output index 328bdd59e621..bb189857347b 100644 --- a/test/cmdlineTests/keccak_optimization_low_runs/output +++ b/test/cmdlineTests/keccak_optimization_low_runs/output @@ -4,12 +4,12 @@ object "C_7" { code { { /// @src 0:62:285 "contract C {..." - let _1 := memoryguard(0x80) - mstore(64, _1) + let _2 := memoryguard(0x80) + mstore(64, _2) if callvalue() { revert(0, 0) } - let _2 := datasize("C_7_deployed") - codecopy(_1, dataoffset("C_7_deployed"), _2) - return(_1, _2) + let _1 := datasize("C_7_deployed") + codecopy(_2, dataoffset("C_7_deployed"), _1) + return(_2, _1) } } /// @use-src 0:"input.sol" diff --git a/test/cmdlineTests/mcopy_bytes_array_returned_from_function/output b/test/cmdlineTests/mcopy_bytes_array_returned_from_function/output index f3cd766954c5..daaa6b047fec 100644 --- a/test/cmdlineTests/mcopy_bytes_array_returned_from_function/output +++ b/test/cmdlineTests/mcopy_bytes_array_returned_from_function/output @@ -3,12 +3,12 @@ Optimized IR: object "C_14" { code { { - let _1 := memoryguard(0x80) - mstore(64, _1) + let _2 := memoryguard(0x80) + mstore(64, _2) if callvalue() { revert(0, 0) } - let _2 := datasize("C_14_deployed") - codecopy(_1, dataoffset("C_14_deployed"), _2) - return(_1, _2) + let _1 := datasize("C_14_deployed") + codecopy(_2, dataoffset("C_14_deployed"), _1) + return(_2, _1) } } /// @use-src 0:"input.sol" diff --git a/test/cmdlineTests/mcopy_string_literal_returned_from_function/output b/test/cmdlineTests/mcopy_string_literal_returned_from_function/output index 3adeae0f58e6..36d1dbab6161 100644 --- a/test/cmdlineTests/mcopy_string_literal_returned_from_function/output +++ b/test/cmdlineTests/mcopy_string_literal_returned_from_function/output @@ -3,12 +3,12 @@ Optimized IR: object "C_10" { code { { - let _1 := memoryguard(0x80) - mstore(64, _1) + let _2 := memoryguard(0x80) + mstore(64, _2) if callvalue() { revert(0, 0) } - let _2 := datasize("C_10_deployed") - codecopy(_1, dataoffset("C_10_deployed"), _2) - return(_1, _2) + let _1 := datasize("C_10_deployed") + codecopy(_2, dataoffset("C_10_deployed"), _1) + return(_2, _1) } } /// @use-src 0:"input.sol" diff --git a/test/cmdlineTests/name_simplifier/output b/test/cmdlineTests/name_simplifier/output index 8eeff65b91a6..0b59cd6d1f1f 100644 --- a/test/cmdlineTests/name_simplifier/output +++ b/test/cmdlineTests/name_simplifier/output @@ -4,12 +4,12 @@ object "C_59" { code { { /// @src 0:346:625 "contract C {..." - let _1 := memoryguard(0x80) - mstore(64, _1) + let _2 := memoryguard(0x80) + mstore(64, _2) if callvalue() { revert(0, 0) } - let _2 := datasize("C_59_deployed") - codecopy(_1, dataoffset("C_59_deployed"), _2) - return(_1, _2) + let _1 := datasize("C_59_deployed") + codecopy(_2, dataoffset("C_59_deployed"), _1) + return(_2, _1) } } /// @use-src 0:"input.sol" diff --git a/test/cmdlineTests/optimizer_array_sload/output b/test/cmdlineTests/optimizer_array_sload/output index a16ac43a0fda..3583e3adccfb 100644 --- a/test/cmdlineTests/optimizer_array_sload/output +++ b/test/cmdlineTests/optimizer_array_sload/output @@ -4,12 +4,12 @@ object "Arraysum_34" { code { { /// @src 0:80:429 "contract Arraysum {..." - let _1 := memoryguard(0x80) - mstore(64, _1) + let _2 := memoryguard(0x80) + mstore(64, _2) if callvalue() { revert(0, 0) } - let _2 := datasize("Arraysum_34_deployed") - codecopy(_1, dataoffset("Arraysum_34_deployed"), _2) - return(_1, _2) + let _1 := datasize("Arraysum_34_deployed") + codecopy(_2, dataoffset("Arraysum_34_deployed"), _1) + return(_2, _1) } } /// @use-src 0:"input.sol" @@ -24,11 +24,11 @@ object "Arraysum_34" { { if callvalue() { revert(0, 0) } if slt(add(calldatasize(), not(3)), 0) { revert(0, 0) } - let var_sum := 0 + let var_sum_8 := 0 /// @src 0:175:182 "sum = 0" - var_sum := /** @src 0:80:429 "contract Arraysum {..." */ 0 + var_sum_8 := /** @src 0:80:429 "contract Arraysum {..." */ 0 /// @src 0:368:378 "uint i = 0" - let var_i := /** @src 0:80:429 "contract Arraysum {..." */ 0 + let var_i_15 := /** @src 0:80:429 "contract Arraysum {..." */ 0 let _1 := sload(0) /// @src 0:364:423 "for(uint i = 0; i < values.length; i++)..." for { } @@ -36,29 +36,29 @@ object "Arraysum_34" { /// @src 0:368:378 "uint i = 0" { /// @src 0:399:402 "i++" - var_i := /** @src 0:80:429 "contract Arraysum {..." */ add(/** @src 0:399:402 "i++" */ var_i, /** @src 0:80:429 "contract Arraysum {..." */ 1) + var_i_15 := /** @src 0:80:429 "contract Arraysum {..." */ add(/** @src 0:399:402 "i++" */ var_i_15, /** @src 0:80:429 "contract Arraysum {..." */ 1) } /// @src 0:399:402 "i++" { /// @src 0:380:397 "i < values.length" - let _2 := iszero(lt(var_i, _1)) + let _2 := iszero(lt(var_i_15, _1)) if _2 { break } /// @src 0:80:429 "contract Arraysum {..." _2 := 0 mstore(0, 0) - let sum := add(var_sum, sload(add(18569430475105882587588266137607568536673111973893317399460219858819262702947, var_i))) - if gt(var_sum, sum) + let sum := add(var_sum_8, sload(add(18569430475105882587588266137607568536673111973893317399460219858819262702947, var_i_15))) + if gt(var_sum_8, sum) { mstore(0, shl(224, 0x4e487b71)) mstore(4, 0x11) revert(0, 0x24) } /// @src 0:407:423 "sum += values[i]" - var_sum := sum + var_sum_8 := sum } /// @src 0:80:429 "contract Arraysum {..." let memPos := mload(64) - mstore(memPos, var_sum) + mstore(memPos, var_sum_8) return(memPos, 0x20) } } diff --git a/test/cmdlineTests/stack_too_deep_from_code_transform/err b/test/cmdlineTests/stack_too_deep_from_code_transform/err index 8820cce05aff..6be1c0ebead3 100644 --- a/test/cmdlineTests/stack_too_deep_from_code_transform/err +++ b/test/cmdlineTests/stack_too_deep_from_code_transform/err @@ -1,4 +1,4 @@ -Error: Cannot swap Variable value23 with Slot 0x20: too deep in the stack by 9 slots in [ RET value23 value22 value21 value20 value19 value18 value17 value16 value15 value14 value13 value12 value11 value10 value9 value8 value7 value6 value5 value4 value3 value2 value1 value0 pos 0x20 ] +Error: Cannot swap Variable value23 with Slot 0x20: too deep in the stack by 9 slots in [ RET value23 value22 value21 value20 value19 value18 value17 value16 value15 value14 value13 value12 value11 value10 value9 value8 value7 value6 value5 value4 value3 value2 value1 value0 pos_1 0x20 ] memoryguard was present. --> input.sol:1:1: | diff --git a/test/cmdlineTests/standard_debug_info_in_yul_and_evm_asm_print_all/output.json b/test/cmdlineTests/standard_debug_info_in_yul_and_evm_asm_print_all/output.json index e004ab7424b0..588f5931ee18 100644 --- a/test/cmdlineTests/standard_debug_info_in_yul_and_evm_asm_print_all/output.json +++ b/test/cmdlineTests/standard_debug_info_in_yul_and_evm_asm_print_all/output.json @@ -169,12 +169,12 @@ object \"C_6\" { code { { /// @src 0:60:101 \"contract C {...\" - let _1 := memoryguard(0x80) - mstore(64, _1) + let _2 := memoryguard(0x80) + mstore(64, _2) if callvalue() { revert(0, 0) } - let _2 := datasize(\"C_6_deployed\") - codecopy(_1, dataoffset(\"C_6_deployed\"), _2) - return(_1, _2) + let _1 := datasize(\"C_6_deployed\") + codecopy(_2, dataoffset(\"C_6_deployed\"), _1) + return(_2, _1) } } /// @use-src 0:\"C\" diff --git a/test/cmdlineTests/standard_debug_info_in_yul_and_evm_asm_print_location_only/output.json b/test/cmdlineTests/standard_debug_info_in_yul_and_evm_asm_print_location_only/output.json index 5c7a93644757..e1a58c388ade 100644 --- a/test/cmdlineTests/standard_debug_info_in_yul_and_evm_asm_print_location_only/output.json +++ b/test/cmdlineTests/standard_debug_info_in_yul_and_evm_asm_print_location_only/output.json @@ -168,12 +168,12 @@ object \"C_6\" { code { { /// @src 0:60:101 - let _1 := memoryguard(0x80) - mstore(64, _1) + let _2 := memoryguard(0x80) + mstore(64, _2) if callvalue() { revert(0, 0) } - let _2 := datasize(\"C_6_deployed\") - codecopy(_1, dataoffset(\"C_6_deployed\"), _2) - return(_1, _2) + let _1 := datasize(\"C_6_deployed\") + codecopy(_2, dataoffset(\"C_6_deployed\"), _1) + return(_2, _1) } } /// @use-src 0:\"C\" diff --git a/test/cmdlineTests/standard_debug_info_in_yul_and_evm_asm_print_none/output.json b/test/cmdlineTests/standard_debug_info_in_yul_and_evm_asm_print_none/output.json index 6f2f9243c63a..9e06c36a8ab6 100644 --- a/test/cmdlineTests/standard_debug_info_in_yul_and_evm_asm_print_none/output.json +++ b/test/cmdlineTests/standard_debug_info_in_yul_and_evm_asm_print_none/output.json @@ -158,12 +158,12 @@ object \"C_6\" { object \"C_6\" { code { { - let _1 := memoryguard(0x80) - mstore(64, _1) + let _2 := memoryguard(0x80) + mstore(64, _2) if callvalue() { revert(0, 0) } - let _2 := datasize(\"C_6_deployed\") - codecopy(_1, dataoffset(\"C_6_deployed\"), _2) - return(_1, _2) + let _1 := datasize(\"C_6_deployed\") + codecopy(_2, dataoffset(\"C_6_deployed\"), _1) + return(_2, _1) } } /// @use-src 0:\"C\" diff --git a/test/cmdlineTests/standard_debug_info_in_yul_location/output.json b/test/cmdlineTests/standard_debug_info_in_yul_location/output.json index 16220fd619b0..5fcc5236203b 100644 --- a/test/cmdlineTests/standard_debug_info_in_yul_location/output.json +++ b/test/cmdlineTests/standard_debug_info_in_yul_location/output.json @@ -615,35 +615,35 @@ object \"C_54\" { code { { /// @src 0:79:510 \"contract C...\" - let _1 := memoryguard(0xa0) + let _3 := memoryguard(0xa0) if callvalue() { revert(0, 0) } let programSize := datasize(\"C_54\") let argSize := sub(codesize(), programSize) - let newFreePtr := add(_1, and(add(argSize, 31), not(31))) - if or(gt(newFreePtr, sub(shl(64, 1), 1)), lt(newFreePtr, _1)) + let newFreePtr := add(_3, and(add(argSize, 31), not(31))) + if or(gt(newFreePtr, sub(shl(64, 1), 1)), lt(newFreePtr, _3)) { mstore(/** @src -1:-1:-1 */ 0, /** @src 0:79:510 \"contract C...\" */ shl(224, 0x4e487b71)) mstore(4, 0x41) revert(/** @src -1:-1:-1 */ 0, /** @src 0:79:510 \"contract C...\" */ 0x24) } mstore(64, newFreePtr) - codecopy(_1, programSize, argSize) - if slt(sub(add(_1, argSize), _1), 32) + codecopy(_3, programSize, argSize) + if slt(sub(add(_3, argSize), _3), 32) { revert(/** @src -1:-1:-1 */ 0, 0) } /// @src 0:79:510 \"contract C...\" - let value := mload(_1) + let value := mload(_3) /// @src 0:160:162 \"42\" mstore(128, 0x2a) /// @src 0:79:510 \"contract C...\" sstore(/** @src -1:-1:-1 */ 0, /** @src 0:79:510 \"contract C...\" */ value) let _2 := mload(64) - let _3 := datasize(\"C_54_deployed\") - codecopy(_2, dataoffset(\"C_54_deployed\"), _3) + let _1 := datasize(\"C_54_deployed\") + codecopy(_2, dataoffset(\"C_54_deployed\"), _1) setimmutable(_2, \"8\", mload(/** @src 0:160:162 \"42\" */ 128)) /// @src 0:79:510 \"contract C...\" - return(_2, _3) + return(_2, _1) } } /// @use-src 0:\"C\" @@ -659,47 +659,47 @@ object \"C_54\" { if callvalue() { revert(0, 0) } if slt(add(calldatasize(), not(3)), 0) { revert(0, 0) } /// @src 0:333:341 \"immutVar\" - let _1 := loadimmutable(\"8\") + let _3 := loadimmutable(\"8\") /// @src 0:322:341 \"constVar + immutVar\" - let sum := /** @src 0:79:510 \"contract C...\" */ 0 - sum := add(/** @src 0:127:129 \"41\" */ 0x29, /** @src 0:79:510 \"contract C...\" */ _1) - if and(1, slt(sum, _1)) + let sum_1 := /** @src 0:79:510 \"contract C...\" */ 0 + sum_1 := add(/** @src 0:127:129 \"41\" */ 0x29, /** @src 0:79:510 \"contract C...\" */ _3) + if and(1, slt(sum_1, _3)) { mstore(0, shl(224, 0x4e487b71)) mstore(4, 0x11) revert(0, 0x24) } let memPos := mload(64) - mstore(memPos, sum) + mstore(memPos, sum_1) return(memPos, 32) } case 0x793816ec { if callvalue() { revert(0, 0) } if slt(add(calldatasize(), not(3)), 0) { revert(0, 0) } - let _2 := sload(0) + let _4 := sload(0) let memPos_1 := mload(64) - mstore(memPos_1, _2) + mstore(memPos_1, _4) return(memPos_1, 32) } case 0x9942ec6f { if callvalue() { revert(0, 0) } if slt(add(calldatasize(), not(3)), 0) { revert(0, 0) } - let _3 := sload(0) - if eq(_3, sub(shl(255, 1), 1)) + let _5 := sload(0) + if eq(_5, sub(shl(255, 1), 1)) { mstore(0, shl(224, 0x4e487b71)) mstore(4, 0x11) revert(0, 0x24) } - let ret := add(_3, 1) + let ret := add(_5, 1) sstore(0, ret) /// @src 0:482:490 \"this.f()\" - let _4 := /** @src 0:79:510 \"contract C...\" */ mload(64) + let _10 := /** @src 0:79:510 \"contract C...\" */ mload(64) /// @src 0:482:490 \"this.f()\" - mstore(_4, /** @src 0:79:510 \"contract C...\" */ shl(228, 0x026121ff)) + mstore(_10, /** @src 0:79:510 \"contract C...\" */ shl(228, 0x026121ff)) /// @src 0:482:490 \"this.f()\" - let _5 := staticcall(gas(), /** @src 0:482:486 \"this\" */ address(), /** @src 0:482:490 \"this.f()\" */ _4, /** @src 0:79:510 \"contract C...\" */ 4, /** @src 0:482:490 \"this.f()\" */ _4, 32) - if iszero(_5) + let _12 := staticcall(gas(), /** @src 0:482:486 \"this\" */ address(), /** @src 0:482:490 \"this.f()\" */ _10, /** @src 0:79:510 \"contract C...\" */ 4, /** @src 0:482:490 \"this.f()\" */ _10, 32) + if iszero(_12) { /// @src 0:79:510 \"contract C...\" let pos := mload(64) @@ -707,34 +707,34 @@ object \"C_54\" { revert(pos, returndatasize()) } /// @src 0:482:490 \"this.f()\" - let expr := /** @src 0:79:510 \"contract C...\" */ 0 + let expr_47 := /** @src 0:79:510 \"contract C...\" */ 0 /// @src 0:482:490 \"this.f()\" - if _5 + if _12 { - let _6 := 32 - if gt(32, returndatasize()) { _6 := returndatasize() } + let _13 := 32 + if gt(32, returndatasize()) { _13 := returndatasize() } /// @src 0:79:510 \"contract C...\" - let newFreePtr := add(_4, and(add(_6, 31), not(31))) - if or(gt(newFreePtr, 0xffffffffffffffff), lt(newFreePtr, _4)) + let newFreePtr := add(_10, and(add(_13, 31), not(31))) + if or(gt(newFreePtr, 0xffffffffffffffff), lt(newFreePtr, _10)) { mstore(0, shl(224, 0x4e487b71)) mstore(4, 0x41) revert(0, 0x24) } mstore(64, newFreePtr) - if slt(sub(/** @src 0:482:490 \"this.f()\" */ add(_4, _6), /** @src 0:79:510 \"contract C...\" */ _4), /** @src 0:482:490 \"this.f()\" */ 32) + if slt(sub(/** @src 0:482:490 \"this.f()\" */ add(_10, _13), /** @src 0:79:510 \"contract C...\" */ _10), /** @src 0:482:490 \"this.f()\" */ 32) /// @src 0:79:510 \"contract C...\" { revert(0, 0) } /// @src 0:482:490 \"this.f()\" - expr := /** @src 0:79:510 \"contract C...\" */ mload(_4) + expr_47 := /** @src 0:79:510 \"contract C...\" */ mload(_10) } /// @src 0:471:490 \"stateVar + this.f()\" - let expr_1 := checked_add_int256(ret, expr) + let expr_48 := checked_add_t_int256(ret, expr_47) /// @src 0:464:501 \"return stateVar + this.f() + immutVar\" - let var := /** @src 0:471:501 \"stateVar + this.f() + immutVar\" */ checked_add_int256(expr_1, /** @src 0:493:501 \"immutVar\" */ loadimmutable(\"8\")) + let var__42 := /** @src 0:471:501 \"stateVar + this.f() + immutVar\" */ checked_add_t_int256(expr_48, /** @src 0:493:501 \"immutVar\" */ loadimmutable(\"8\")) /// @src 0:79:510 \"contract C...\" let memPos_2 := mload(64) - mstore(memPos_2, var) + mstore(memPos_2, var__42) return(memPos_2, /** @src 0:482:490 \"this.f()\" */ 32) } case /** @src 0:79:510 \"contract C...\" */ 0xa00b982b { @@ -748,7 +748,7 @@ object \"C_54\" { } revert(0, 0) } - function checked_add_int256(x, y) -> sum + function checked_add_t_int256(x, y) -> sum { sum := add(x, y) let _1 := slt(sum, y) @@ -1452,25 +1452,25 @@ object \"D_72\" { code { { /// @src 1:91:181 \"contract D is C(3)...\" - let _1 := memoryguard(0xa0) + let _3 := memoryguard(0xa0) if callvalue() { revert(0, 0) } let programSize := datasize(\"D_72\") let argSize := sub(codesize(), programSize) - let newFreePtr := add(_1, and(add(argSize, 31), not(31))) - if or(gt(newFreePtr, sub(shl(64, 1), 1)), lt(newFreePtr, _1)) + let newFreePtr := add(_3, and(add(argSize, 31), not(31))) + if or(gt(newFreePtr, sub(shl(64, 1), 1)), lt(newFreePtr, _3)) { mstore(/** @src -1:-1:-1 */ 0, /** @src 1:91:181 \"contract D is C(3)...\" */ shl(224, 0x4e487b71)) mstore(4, 0x41) revert(/** @src -1:-1:-1 */ 0, /** @src 1:91:181 \"contract D is C(3)...\" */ 0x24) } mstore(64, newFreePtr) - codecopy(_1, programSize, argSize) - if slt(sub(add(_1, argSize), _1), 32) + codecopy(_3, programSize, argSize) + if slt(sub(add(_3, argSize), _3), 32) { revert(/** @src -1:-1:-1 */ 0, 0) } /// @src 1:91:181 \"contract D is C(3)...\" - let value := mload(_1) + let value := mload(_3) /// @src 0:160:162 \"42\" mstore(128, 0x2a) /// @src 1:91:181 \"contract D is C(3)...\" @@ -1483,11 +1483,11 @@ object \"D_72\" { } sstore(/** @src -1:-1:-1 */ 0, /** @src 1:91:181 \"contract D is C(3)...\" */ sum) let _2 := mload(64) - let _3 := datasize(\"D_72_deployed\") - codecopy(_2, dataoffset(\"D_72_deployed\"), _3) + let _1 := datasize(\"D_72_deployed\") + codecopy(_2, dataoffset(\"D_72_deployed\"), _1) setimmutable(_2, \"8\", mload(/** @src 0:160:162 \"42\" */ 128)) /// @src 1:91:181 \"contract D is C(3)...\" - return(_2, _3) + return(_2, _1) } } /// @use-src 0:\"C\", 1:\"D\" @@ -1503,47 +1503,47 @@ object \"D_72\" { if callvalue() { revert(0, 0) } if slt(add(calldatasize(), not(3)), 0) { revert(0, 0) } /// @src 0:333:341 \"immutVar\" - let _1 := loadimmutable(\"8\") + let _3 := loadimmutable(\"8\") /// @src 0:322:341 \"constVar + immutVar\" - let sum := /** @src 1:91:181 \"contract D is C(3)...\" */ 0 - sum := add(/** @src 0:127:129 \"41\" */ 0x29, /** @src 1:91:181 \"contract D is C(3)...\" */ _1) - if and(1, slt(sum, _1)) + let sum_1 := /** @src 1:91:181 \"contract D is C(3)...\" */ 0 + sum_1 := add(/** @src 0:127:129 \"41\" */ 0x29, /** @src 1:91:181 \"contract D is C(3)...\" */ _3) + if and(1, slt(sum_1, _3)) { mstore(0, shl(224, 0x4e487b71)) mstore(4, 0x11) revert(0, 0x24) } let memPos := mload(64) - mstore(memPos, sum) + mstore(memPos, sum_1) return(memPos, 32) } case 0x793816ec { if callvalue() { revert(0, 0) } if slt(add(calldatasize(), not(3)), 0) { revert(0, 0) } - let _2 := sload(0) + let _4 := sload(0) let memPos_1 := mload(64) - mstore(memPos_1, _2) + mstore(memPos_1, _4) return(memPos_1, 32) } case 0x9942ec6f { if callvalue() { revert(0, 0) } if slt(add(calldatasize(), not(3)), 0) { revert(0, 0) } - let _3 := sload(0) - if eq(_3, sub(shl(255, 1), 1)) + let _5 := sload(0) + if eq(_5, sub(shl(255, 1), 1)) { mstore(0, shl(224, 0x4e487b71)) mstore(4, 0x11) revert(0, 0x24) } - let ret := add(_3, 1) + let ret := add(_5, 1) sstore(0, ret) /// @src 0:482:490 \"this.f()\" - let _4 := /** @src 1:91:181 \"contract D is C(3)...\" */ mload(64) + let _10 := /** @src 1:91:181 \"contract D is C(3)...\" */ mload(64) /// @src 0:482:490 \"this.f()\" - mstore(_4, /** @src 1:91:181 \"contract D is C(3)...\" */ shl(228, 0x026121ff)) + mstore(_10, /** @src 1:91:181 \"contract D is C(3)...\" */ shl(228, 0x026121ff)) /// @src 0:482:490 \"this.f()\" - let _5 := staticcall(gas(), /** @src 0:482:486 \"this\" */ address(), /** @src 0:482:490 \"this.f()\" */ _4, /** @src 1:91:181 \"contract D is C(3)...\" */ 4, /** @src 0:482:490 \"this.f()\" */ _4, 32) - if iszero(_5) + let _12 := staticcall(gas(), /** @src 0:482:486 \"this\" */ address(), /** @src 0:482:490 \"this.f()\" */ _10, /** @src 1:91:181 \"contract D is C(3)...\" */ 4, /** @src 0:482:490 \"this.f()\" */ _10, 32) + if iszero(_12) { /// @src 1:91:181 \"contract D is C(3)...\" let pos := mload(64) @@ -1551,34 +1551,34 @@ object \"D_72\" { revert(pos, returndatasize()) } /// @src 0:482:490 \"this.f()\" - let expr := /** @src 1:91:181 \"contract D is C(3)...\" */ 0 + let expr_47 := /** @src 1:91:181 \"contract D is C(3)...\" */ 0 /// @src 0:482:490 \"this.f()\" - if _5 + if _12 { - let _6 := 32 - if gt(32, returndatasize()) { _6 := returndatasize() } + let _13 := 32 + if gt(32, returndatasize()) { _13 := returndatasize() } /// @src 1:91:181 \"contract D is C(3)...\" - let newFreePtr := add(_4, and(add(_6, 31), not(31))) - if or(gt(newFreePtr, 0xffffffffffffffff), lt(newFreePtr, _4)) + let newFreePtr := add(_10, and(add(_13, 31), not(31))) + if or(gt(newFreePtr, 0xffffffffffffffff), lt(newFreePtr, _10)) { mstore(0, shl(224, 0x4e487b71)) mstore(4, 0x41) revert(0, 0x24) } mstore(64, newFreePtr) - if slt(sub(/** @src 0:482:490 \"this.f()\" */ add(_4, _6), /** @src 1:91:181 \"contract D is C(3)...\" */ _4), /** @src 0:482:490 \"this.f()\" */ 32) + if slt(sub(/** @src 0:482:490 \"this.f()\" */ add(_10, _13), /** @src 1:91:181 \"contract D is C(3)...\" */ _10), /** @src 0:482:490 \"this.f()\" */ 32) /// @src 1:91:181 \"contract D is C(3)...\" { revert(0, 0) } /// @src 0:482:490 \"this.f()\" - expr := /** @src 1:91:181 \"contract D is C(3)...\" */ mload(_4) + expr_47 := /** @src 1:91:181 \"contract D is C(3)...\" */ mload(_10) } /// @src 0:471:490 \"stateVar + this.f()\" - let expr_1 := checked_add_int256(ret, expr) + let expr_48 := checked_add_t_int256(ret, expr_47) /// @src 0:464:501 \"return stateVar + this.f() + immutVar\" - let var := /** @src 0:471:501 \"stateVar + this.f() + immutVar\" */ checked_add_int256(expr_1, /** @src 0:493:501 \"immutVar\" */ loadimmutable(\"8\")) + let var__42 := /** @src 0:471:501 \"stateVar + this.f() + immutVar\" */ checked_add_t_int256(expr_48, /** @src 0:493:501 \"immutVar\" */ loadimmutable(\"8\")) /// @src 1:91:181 \"contract D is C(3)...\" let memPos_2 := mload(64) - mstore(memPos_2, var) + mstore(memPos_2, var__42) return(memPos_2, /** @src 0:482:490 \"this.f()\" */ 32) } case /** @src 1:91:181 \"contract D is C(3)...\" */ 0xa00b982b { @@ -1592,7 +1592,7 @@ object \"D_72\" { } revert(0, 0) } - function checked_add_int256(x, y) -> sum + function checked_add_t_int256(x, y) -> sum { sum := add(x, y) let _1 := slt(sum, y) diff --git a/test/cmdlineTests/standard_irOptimized_requested/output.json b/test/cmdlineTests/standard_irOptimized_requested/output.json index 849b436b24a5..fa0bea9d9b5a 100644 --- a/test/cmdlineTests/standard_irOptimized_requested/output.json +++ b/test/cmdlineTests/standard_irOptimized_requested/output.json @@ -29,14 +29,14 @@ object \"C_7\" { mstore(64, memoryguard(0x80)) if iszero(lt(calldatasize(), 4)) { - let selector := shift_right_unsigned(calldataload(0)) + let selector := shift_right_224_unsigned(calldataload(0)) switch selector - case 0x26121ff0 { external_fun_f() } + case 0x26121ff0 { external_fun_f_6() } default { } } revert_error_42b3090547df1d2001c96683413b8cf91c1b902ef5e3cb8d9f6f304cf7446f74() } - function shift_right_unsigned(value) -> newValue + function shift_right_224_unsigned(value) -> newValue { newValue := shr(224, value) } function allocate_unbounded() -> memPtr { memPtr := mload(64) } @@ -44,24 +44,24 @@ object \"C_7\" { { revert(0, 0) } function revert_error_dbdddcbe895c83990c08b3492a0e83918d802a52331272ac6fdb6a7c4aea3b1b() { revert(0, 0) } - function abi_decode(headStart, dataEnd) + function abi_decode_tuple_(headStart, dataEnd) { if slt(sub(dataEnd, headStart), 0) { revert_error_dbdddcbe895c83990c08b3492a0e83918d802a52331272ac6fdb6a7c4aea3b1b() } } - function abi_encode_tuple(headStart) -> tail - { tail := add(headStart, 0) } - function external_fun_f() + function abi_encode_tuple__to__fromStack(headStart_1) -> tail + { tail := add(headStart_1, 0) } + function external_fun_f_6() { if callvalue() { revert_error_ca66f745a3ce8ff40e2ccaf1ad45db7774001b90d25810abd9040049be7bf4bb() } - abi_decode(4, calldatasize()) + abi_decode_tuple_(4, calldatasize()) let memPos := allocate_unbounded() - let memEnd := abi_encode_tuple(memPos) + let memEnd := abi_encode_tuple__to__fromStack(memPos) return(memPos, sub(memEnd, memPos)) } function revert_error_42b3090547df1d2001c96683413b8cf91c1b902ef5e3cb8d9f6f304cf7446f74() diff --git a/test/cmdlineTests/standard_optimizer_generatedSources/output.json b/test/cmdlineTests/standard_optimizer_generatedSources/output.json index e5b276b1b9b6..ed8c410c00db 100644 --- a/test/cmdlineTests/standard_optimizer_generatedSources/output.json +++ b/test/cmdlineTests/standard_optimizer_generatedSources/output.json @@ -11,9 +11,9 @@ "generatedSources": [ { "ast": { - "nativeSrc": "0:1505:1", + "nativeSrc": "0:1515:1", "nodeType": "YulBlock", - "src": "0:1505:1", + "src": "0:1515:1", "statements": [ { "nativeSrc": "6:3:1", @@ -1419,47 +1419,47 @@ }, { "body": { - "nativeSrc": "1427:76:1", + "nativeSrc": "1431:82:1", "nodeType": "YulBlock", - "src": "1427:76:1", + "src": "1431:82:1", "statements": [ { - "nativeSrc": "1437:26:1", + "nativeSrc": "1441:28:1", "nodeType": "YulAssignment", - "src": "1437:26:1", + "src": "1441:28:1", "value": { "arguments": [ { - "name": "headStart", - "nativeSrc": "1449:9:1", + "name": "headStart_1", + "nativeSrc": "1453:11:1", "nodeType": "YulIdentifier", - "src": "1449:9:1" + "src": "1453:11:1" }, { "kind": "number", - "nativeSrc": "1460:2:1", + "nativeSrc": "1466:2:1", "nodeType": "YulLiteral", - "src": "1460:2:1", + "src": "1466:2:1", "type": "", "value": "32" } ], "functionName": { "name": "add", - "nativeSrc": "1445:3:1", + "nativeSrc": "1449:3:1", "nodeType": "YulIdentifier", - "src": "1445:3:1" + "src": "1449:3:1" }, - "nativeSrc": "1445:18:1", + "nativeSrc": "1449:20:1", "nodeType": "YulFunctionCall", - "src": "1445:18:1" + "src": "1449:20:1" }, "variableNames": [ { "name": "tail", - "nativeSrc": "1437:4:1", + "nativeSrc": "1441:4:1", "nodeType": "YulIdentifier", - "src": "1437:4:1" + "src": "1441:4:1" } ] }, @@ -1467,63 +1467,63 @@ "expression": { "arguments": [ { - "name": "headStart", - "nativeSrc": "1479:9:1", + "name": "headStart_1", + "nativeSrc": "1485:11:1", "nodeType": "YulIdentifier", - "src": "1479:9:1" + "src": "1485:11:1" }, { - "name": "value0", - "nativeSrc": "1490:6:1", + "name": "value0_1", + "nativeSrc": "1498:8:1", "nodeType": "YulIdentifier", - "src": "1490:6:1" + "src": "1498:8:1" } ], "functionName": { "name": "mstore", - "nativeSrc": "1472:6:1", + "nativeSrc": "1478:6:1", "nodeType": "YulIdentifier", - "src": "1472:6:1" + "src": "1478:6:1" }, - "nativeSrc": "1472:25:1", + "nativeSrc": "1478:29:1", "nodeType": "YulFunctionCall", - "src": "1472:25:1" + "src": "1478:29:1" }, - "nativeSrc": "1472:25:1", + "nativeSrc": "1478:29:1", "nodeType": "YulExpressionStatement", - "src": "1472:25:1" + "src": "1478:29:1" } ] }, "name": "abi_encode_tuple_t_uint256__to_t_uint256__fromStack_reversed", - "nativeSrc": "1326:177:1", + "nativeSrc": "1326:187:1", "nodeType": "YulFunctionDefinition", "parameters": [ { - "name": "headStart", - "nativeSrc": "1396:9:1", + "name": "headStart_1", + "nativeSrc": "1396:11:1", "nodeType": "YulTypedName", - "src": "1396:9:1", + "src": "1396:11:1", "type": "" }, { - "name": "value0", - "nativeSrc": "1407:6:1", + "name": "value0_1", + "nativeSrc": "1409:8:1", "nodeType": "YulTypedName", - "src": "1407:6:1", + "src": "1409:8:1", "type": "" } ], "returnVariables": [ { "name": "tail", - "nativeSrc": "1418:4:1", + "nativeSrc": "1422:4:1", "nodeType": "YulTypedName", - "src": "1418:4:1", + "src": "1422:4:1", "type": "" } ], - "src": "1326:177:1" + "src": "1326:187:1" } ] }, @@ -1564,10 +1564,10 @@ } value0 := memPtr } - function abi_encode_tuple_t_uint256__to_t_uint256__fromStack_reversed(headStart, value0) -> tail + function abi_encode_tuple_t_uint256__to_t_uint256__fromStack_reversed(headStart_1, value0_1) -> tail { - tail := add(headStart, 32) - mstore(headStart, value0) + tail := add(headStart_1, 32) + mstore(headStart_1, value0_1) } }", "id": 1, diff --git a/test/cmdlineTests/standard_output_debuginfo_ethdebug_compatible/output.json b/test/cmdlineTests/standard_output_debuginfo_ethdebug_compatible/output.json index 8f198f1f3adb..3dde81e774f6 100644 --- a/test/cmdlineTests/standard_output_debuginfo_ethdebug_compatible/output.json +++ b/test/cmdlineTests/standard_output_debuginfo_ethdebug_compatible/output.json @@ -207,14 +207,14 @@ object \"A1_14\" { mstore(64, memoryguard(0x80)) if iszero(lt(calldatasize(), 4)) { - let selector := shift_right_unsigned(calldataload(0)) + let selector := shift_right_224_unsigned(calldataload(0)) switch selector - case 0xf0fdf834 { external_fun_a() } + case 0xf0fdf834 { external_fun_a_13() } default { } } revert_error_42b3090547df1d2001c96683413b8cf91c1b902ef5e3cb8d9f6f304cf7446f74() } - function shift_right_unsigned(value) -> newValue + function shift_right_224_unsigned(value) -> newValue { newValue := shr(224, value) } function allocate_unbounded() -> memPtr { memPtr := mload(64) } @@ -222,49 +222,49 @@ object \"A1_14\" { { revert(0, 0) } function revert_error_dbdddcbe895c83990c08b3492a0e83918d802a52331272ac6fdb6a7c4aea3b1b() { revert(0, 0) } - function cleanup_uint256(value) -> cleaned - { cleaned := value } - function validator_revert_uint256(value) + function cleanup_t_uint256(value_1) -> cleaned + { cleaned := value_1 } + function validator_revert_t_uint256(value_2) { - if iszero(eq(value, cleanup_uint256(value))) { revert(0, 0) } + if iszero(eq(value_2, cleanup_t_uint256(value_2))) { revert(0, 0) } } - function abi_decode_uint256(offset, end) -> value + function abi_decode_t_uint256(offset, end) -> value_3 { - value := calldataload(offset) - validator_revert_uint256(value) + value_3 := calldataload(offset) + validator_revert_t_uint256(value_3) } - function abi_decode_tuple_uint256(headStart, dataEnd) -> value0 + function abi_decode_tuple_t_uint256(headStart, dataEnd) -> value0 { if slt(sub(dataEnd, headStart), 32) { revert_error_dbdddcbe895c83990c08b3492a0e83918d802a52331272ac6fdb6a7c4aea3b1b() } - let offset := 0 - value0 := abi_decode_uint256(add(headStart, offset), dataEnd) + let offset_1 := 0 + value0 := abi_decode_t_uint256(add(headStart, offset_1), dataEnd) } - function abi_encode_tuple(headStart) -> tail - { tail := add(headStart, 0) } - function external_fun_a() + function abi_encode_tuple__to__fromStack(headStart_1) -> tail + { tail := add(headStart_1, 0) } + function external_fun_a_13() { if callvalue() { revert_error_ca66f745a3ce8ff40e2ccaf1ad45db7774001b90d25810abd9040049be7bf4bb() } - let param := abi_decode_tuple_uint256(4, calldatasize()) - fun_a(param) + let param_0 := abi_decode_tuple_t_uint256(4, calldatasize()) + fun_a_13(param_0) let memPos := allocate_unbounded() - let memEnd := abi_encode_tuple(memPos) + let memEnd := abi_encode_tuple__to__fromStack(memPos) return(memPos, sub(memEnd, memPos)) } function revert_error_42b3090547df1d2001c96683413b8cf91c1b902ef5e3cb8d9f6f304cf7446f74() { revert(0, 0) } - function cleanup_rational_by(value) -> cleaned - { cleaned := value } - function identity(value) -> ret - { ret := value } - function convert_rational_by_to_uint256(value) -> converted + function cleanup_t_rational_0_by_1(value_4) -> cleaned_1 + { cleaned_1 := value_4 } + function identity(value_5) -> ret + { ret := value_5 } + function convert_t_rational_0_by_1_to_t_uint256(value_6) -> converted { - converted := cleanup_uint256(identity(cleanup_rational_by(value))) + converted := cleanup_t_uint256(identity(cleanup_t_rational_0_by_1(value_6))) } function panic_error_0x01() { @@ -277,17 +277,17 @@ object \"A1_14\" { if iszero(condition) { panic_error_0x01() } } /// @src 0:72:121 - function fun_a(var_x) + function fun_a_13(var_x_3) { /// @src 0:112:113 - let _1 := var_x - let expr := _1 + let _1 := var_x_3 + let expr_7 := _1 /// @src 0:116:117 - let expr_1 := 0x00 + let expr_8 := 0x00 /// @src 0:112:117 - let expr_2 := gt(cleanup_uint256(expr), convert_rational_by_to_uint256(expr_1)) + let expr_9 := gt(cleanup_t_uint256(expr_7), convert_t_rational_0_by_1_to_t_uint256(expr_8)) /// @src 0:105:118 - assert_helper(expr_2) + assert_helper(expr_9) } } data \".metadata\" hex\"\" @@ -501,14 +501,14 @@ object \"A2_27\" { mstore(64, memoryguard(0x80)) if iszero(lt(calldatasize(), 4)) { - let selector := shift_right_unsigned(calldataload(0)) + let selector := shift_right_224_unsigned(calldataload(0)) switch selector - case 0xf0fdf834 { external_fun_a() } + case 0xf0fdf834 { external_fun_a_26() } default { } } revert_error_42b3090547df1d2001c96683413b8cf91c1b902ef5e3cb8d9f6f304cf7446f74() } - function shift_right_unsigned(value) -> newValue + function shift_right_224_unsigned(value) -> newValue { newValue := shr(224, value) } function allocate_unbounded() -> memPtr { memPtr := mload(64) } @@ -516,49 +516,49 @@ object \"A2_27\" { { revert(0, 0) } function revert_error_dbdddcbe895c83990c08b3492a0e83918d802a52331272ac6fdb6a7c4aea3b1b() { revert(0, 0) } - function cleanup_uint256(value) -> cleaned - { cleaned := value } - function validator_revert_uint256(value) + function cleanup_t_uint256(value_1) -> cleaned + { cleaned := value_1 } + function validator_revert_t_uint256(value_2) { - if iszero(eq(value, cleanup_uint256(value))) { revert(0, 0) } + if iszero(eq(value_2, cleanup_t_uint256(value_2))) { revert(0, 0) } } - function abi_decode_uint256(offset, end) -> value + function abi_decode_t_uint256(offset, end) -> value_3 { - value := calldataload(offset) - validator_revert_uint256(value) + value_3 := calldataload(offset) + validator_revert_t_uint256(value_3) } - function abi_decode_tuple_uint256(headStart, dataEnd) -> value0 + function abi_decode_tuple_t_uint256(headStart, dataEnd) -> value0 { if slt(sub(dataEnd, headStart), 32) { revert_error_dbdddcbe895c83990c08b3492a0e83918d802a52331272ac6fdb6a7c4aea3b1b() } - let offset := 0 - value0 := abi_decode_uint256(add(headStart, offset), dataEnd) + let offset_1 := 0 + value0 := abi_decode_t_uint256(add(headStart, offset_1), dataEnd) } - function abi_encode_tuple(headStart) -> tail - { tail := add(headStart, 0) } - function external_fun_a() + function abi_encode_tuple__to__fromStack(headStart_1) -> tail + { tail := add(headStart_1, 0) } + function external_fun_a_26() { if callvalue() { revert_error_ca66f745a3ce8ff40e2ccaf1ad45db7774001b90d25810abd9040049be7bf4bb() } - let param := abi_decode_tuple_uint256(4, calldatasize()) - fun_a(param) + let param_0 := abi_decode_tuple_t_uint256(4, calldatasize()) + fun_a_26(param_0) let memPos := allocate_unbounded() - let memEnd := abi_encode_tuple(memPos) + let memEnd := abi_encode_tuple__to__fromStack(memPos) return(memPos, sub(memEnd, memPos)) } function revert_error_42b3090547df1d2001c96683413b8cf91c1b902ef5e3cb8d9f6f304cf7446f74() { revert(0, 0) } - function cleanup_rational_by(value) -> cleaned - { cleaned := value } - function identity(value) -> ret - { ret := value } - function convert_rational_by_to_uint256(value) -> converted + function cleanup_t_rational_0_by_1(value_4) -> cleaned_1 + { cleaned_1 := value_4 } + function identity(value_5) -> ret + { ret := value_5 } + function convert_t_rational_0_by_1_to_t_uint256(value_6) -> converted { - converted := cleanup_uint256(identity(cleanup_rational_by(value))) + converted := cleanup_t_uint256(identity(cleanup_t_rational_0_by_1(value_6))) } function panic_error_0x01() { @@ -571,17 +571,17 @@ object \"A2_27\" { if iszero(condition) { panic_error_0x01() } } /// @src 0:138:187 - function fun_a(var_x) + function fun_a_26(var_x_16) { /// @src 0:178:179 - let _1 := var_x - let expr := _1 + let _1 := var_x_16 + let expr_20 := _1 /// @src 0:182:183 - let expr_1 := 0x00 + let expr_21 := 0x00 /// @src 0:178:183 - let expr_2 := gt(cleanup_uint256(expr), convert_rational_by_to_uint256(expr_1)) + let expr_22 := gt(cleanup_t_uint256(expr_20), convert_t_rational_0_by_1_to_t_uint256(expr_21)) /// @src 0:171:184 - assert_helper(expr_2) + assert_helper(expr_22) } } data \".metadata\" hex\"\" @@ -797,14 +797,14 @@ object \"A1_42\" { mstore(64, memoryguard(0x80)) if iszero(lt(calldatasize(), 4)) { - let selector := shift_right_unsigned(calldataload(0)) + let selector := shift_right_224_unsigned(calldataload(0)) switch selector - case 0xcd580ff3 { external_fun_b() } + case 0xcd580ff3 { external_fun_b_41() } default { } } revert_error_42b3090547df1d2001c96683413b8cf91c1b902ef5e3cb8d9f6f304cf7446f74() } - function shift_right_unsigned(value) -> newValue + function shift_right_224_unsigned(value) -> newValue { newValue := shr(224, value) } function allocate_unbounded() -> memPtr { memPtr := mload(64) } @@ -812,49 +812,49 @@ object \"A1_42\" { { revert(0, 0) } function revert_error_dbdddcbe895c83990c08b3492a0e83918d802a52331272ac6fdb6a7c4aea3b1b() { revert(0, 0) } - function cleanup_uint256(value) -> cleaned - { cleaned := value } - function validator_revert_uint256(value) + function cleanup_t_uint256(value_1) -> cleaned + { cleaned := value_1 } + function validator_revert_t_uint256(value_2) { - if iszero(eq(value, cleanup_uint256(value))) { revert(0, 0) } + if iszero(eq(value_2, cleanup_t_uint256(value_2))) { revert(0, 0) } } - function abi_decode_uint256(offset, end) -> value + function abi_decode_t_uint256(offset, end) -> value_3 { - value := calldataload(offset) - validator_revert_uint256(value) + value_3 := calldataload(offset) + validator_revert_t_uint256(value_3) } - function abi_decode_tuple_uint256(headStart, dataEnd) -> value0 + function abi_decode_tuple_t_uint256(headStart, dataEnd) -> value0 { if slt(sub(dataEnd, headStart), 32) { revert_error_dbdddcbe895c83990c08b3492a0e83918d802a52331272ac6fdb6a7c4aea3b1b() } - let offset := 0 - value0 := abi_decode_uint256(add(headStart, offset), dataEnd) + let offset_1 := 0 + value0 := abi_decode_t_uint256(add(headStart, offset_1), dataEnd) } - function abi_encode_tuple(headStart) -> tail - { tail := add(headStart, 0) } - function external_fun_b() + function abi_encode_tuple__to__fromStack(headStart_1) -> tail + { tail := add(headStart_1, 0) } + function external_fun_b_41() { if callvalue() { revert_error_ca66f745a3ce8ff40e2ccaf1ad45db7774001b90d25810abd9040049be7bf4bb() } - let param := abi_decode_tuple_uint256(4, calldatasize()) - fun_b(param) + let param_0 := abi_decode_tuple_t_uint256(4, calldatasize()) + fun_b_41(param_0) let memPos := allocate_unbounded() - let memEnd := abi_encode_tuple(memPos) + let memEnd := abi_encode_tuple__to__fromStack(memPos) return(memPos, sub(memEnd, memPos)) } function revert_error_42b3090547df1d2001c96683413b8cf91c1b902ef5e3cb8d9f6f304cf7446f74() { revert(0, 0) } - function cleanup_rational_by(value) -> cleaned - { cleaned := value } - function identity(value) -> ret - { ret := value } - function convert_rational_by_to_uint256(value) -> converted + function cleanup_t_rational_0_by_1(value_4) -> cleaned_1 + { cleaned_1 := value_4 } + function identity(value_5) -> ret + { ret := value_5 } + function convert_t_rational_0_by_1_to_t_uint256(value_6) -> converted { - converted := cleanup_uint256(identity(cleanup_rational_by(value))) + converted := cleanup_t_uint256(identity(cleanup_t_rational_0_by_1(value_6))) } function panic_error_0x01() { @@ -867,17 +867,17 @@ object \"A1_42\" { if iszero(condition) { panic_error_0x01() } } /// @src 1:72:121 - function fun_b(var_x) + function fun_b_41(var_x_31) { /// @src 1:112:113 - let _1 := var_x - let expr := _1 + let _1 := var_x_31 + let expr_35 := _1 /// @src 1:116:117 - let expr_1 := 0x00 + let expr_36 := 0x00 /// @src 1:112:117 - let expr_2 := gt(cleanup_uint256(expr), convert_rational_by_to_uint256(expr_1)) + let expr_37 := gt(cleanup_t_uint256(expr_35), convert_t_rational_0_by_1_to_t_uint256(expr_36)) /// @src 1:105:118 - assert_helper(expr_2) + assert_helper(expr_37) } } data \".metadata\" hex\"\" @@ -1091,14 +1091,14 @@ object \"B2_55\" { mstore(64, memoryguard(0x80)) if iszero(lt(calldatasize(), 4)) { - let selector := shift_right_unsigned(calldataload(0)) + let selector := shift_right_224_unsigned(calldataload(0)) switch selector - case 0xcd580ff3 { external_fun_b() } + case 0xcd580ff3 { external_fun_b_54() } default { } } revert_error_42b3090547df1d2001c96683413b8cf91c1b902ef5e3cb8d9f6f304cf7446f74() } - function shift_right_unsigned(value) -> newValue + function shift_right_224_unsigned(value) -> newValue { newValue := shr(224, value) } function allocate_unbounded() -> memPtr { memPtr := mload(64) } @@ -1106,49 +1106,49 @@ object \"B2_55\" { { revert(0, 0) } function revert_error_dbdddcbe895c83990c08b3492a0e83918d802a52331272ac6fdb6a7c4aea3b1b() { revert(0, 0) } - function cleanup_uint256(value) -> cleaned - { cleaned := value } - function validator_revert_uint256(value) + function cleanup_t_uint256(value_1) -> cleaned + { cleaned := value_1 } + function validator_revert_t_uint256(value_2) { - if iszero(eq(value, cleanup_uint256(value))) { revert(0, 0) } + if iszero(eq(value_2, cleanup_t_uint256(value_2))) { revert(0, 0) } } - function abi_decode_uint256(offset, end) -> value + function abi_decode_t_uint256(offset, end) -> value_3 { - value := calldataload(offset) - validator_revert_uint256(value) + value_3 := calldataload(offset) + validator_revert_t_uint256(value_3) } - function abi_decode_tuple_uint256(headStart, dataEnd) -> value0 + function abi_decode_tuple_t_uint256(headStart, dataEnd) -> value0 { if slt(sub(dataEnd, headStart), 32) { revert_error_dbdddcbe895c83990c08b3492a0e83918d802a52331272ac6fdb6a7c4aea3b1b() } - let offset := 0 - value0 := abi_decode_uint256(add(headStart, offset), dataEnd) + let offset_1 := 0 + value0 := abi_decode_t_uint256(add(headStart, offset_1), dataEnd) } - function abi_encode_tuple(headStart) -> tail - { tail := add(headStart, 0) } - function external_fun_b() + function abi_encode_tuple__to__fromStack(headStart_1) -> tail + { tail := add(headStart_1, 0) } + function external_fun_b_54() { if callvalue() { revert_error_ca66f745a3ce8ff40e2ccaf1ad45db7774001b90d25810abd9040049be7bf4bb() } - let param := abi_decode_tuple_uint256(4, calldatasize()) - fun_b(param) + let param_0 := abi_decode_tuple_t_uint256(4, calldatasize()) + fun_b_54(param_0) let memPos := allocate_unbounded() - let memEnd := abi_encode_tuple(memPos) + let memEnd := abi_encode_tuple__to__fromStack(memPos) return(memPos, sub(memEnd, memPos)) } function revert_error_42b3090547df1d2001c96683413b8cf91c1b902ef5e3cb8d9f6f304cf7446f74() { revert(0, 0) } - function cleanup_rational_by(value) -> cleaned - { cleaned := value } - function identity(value) -> ret - { ret := value } - function convert_rational_by_to_uint256(value) -> converted + function cleanup_t_rational_0_by_1(value_4) -> cleaned_1 + { cleaned_1 := value_4 } + function identity(value_5) -> ret + { ret := value_5 } + function convert_t_rational_0_by_1_to_t_uint256(value_6) -> converted { - converted := cleanup_uint256(identity(cleanup_rational_by(value))) + converted := cleanup_t_uint256(identity(cleanup_t_rational_0_by_1(value_6))) } function panic_error_0x01() { @@ -1161,17 +1161,17 @@ object \"B2_55\" { if iszero(condition) { panic_error_0x01() } } /// @src 1:138:187 - function fun_b(var_x) + function fun_b_54(var_x_44) { /// @src 1:178:179 - let _1 := var_x - let expr := _1 + let _1 := var_x_44 + let expr_48 := _1 /// @src 1:182:183 - let expr_1 := 0x00 + let expr_49 := 0x00 /// @src 1:178:183 - let expr_2 := gt(cleanup_uint256(expr), convert_rational_by_to_uint256(expr_1)) + let expr_50 := gt(cleanup_t_uint256(expr_48), convert_t_rational_0_by_1_to_t_uint256(expr_49)) /// @src 1:171:184 - assert_helper(expr_2) + assert_helper(expr_50) } } data \".metadata\" hex\"\" diff --git a/test/cmdlineTests/standard_output_selection_ethdebug_bytecode_and_deployedbytecode_iroptimized/output.json b/test/cmdlineTests/standard_output_selection_ethdebug_bytecode_and_deployedbytecode_iroptimized/output.json index b129a0c91b85..741758761403 100644 --- a/test/cmdlineTests/standard_output_selection_ethdebug_bytecode_and_deployedbytecode_iroptimized/output.json +++ b/test/cmdlineTests/standard_output_selection_ethdebug_bytecode_and_deployedbytecode_iroptimized/output.json @@ -38,14 +38,14 @@ object \"A1_14\" { mstore(64, memoryguard(0x80)) if iszero(lt(calldatasize(), 4)) { - let selector := shift_right_unsigned(calldataload(0)) + let selector := shift_right_224_unsigned(calldataload(0)) switch selector - case 0xf0fdf834 { external_fun_a() } + case 0xf0fdf834 { external_fun_a_13() } default { } } revert_error_42b3090547df1d2001c96683413b8cf91c1b902ef5e3cb8d9f6f304cf7446f74() } - function shift_right_unsigned(value) -> newValue + function shift_right_224_unsigned(value) -> newValue { newValue := shr(224, value) } function allocate_unbounded() -> memPtr { memPtr := mload(64) } @@ -53,49 +53,49 @@ object \"A1_14\" { { revert(0, 0) } function revert_error_dbdddcbe895c83990c08b3492a0e83918d802a52331272ac6fdb6a7c4aea3b1b() { revert(0, 0) } - function cleanup_uint256(value) -> cleaned - { cleaned := value } - function validator_revert_uint256(value) + function cleanup_t_uint256(value_1) -> cleaned + { cleaned := value_1 } + function validator_revert_t_uint256(value_2) { - if iszero(eq(value, cleanup_uint256(value))) { revert(0, 0) } + if iszero(eq(value_2, cleanup_t_uint256(value_2))) { revert(0, 0) } } - function abi_decode_uint256(offset, end) -> value + function abi_decode_t_uint256(offset, end) -> value_3 { - value := calldataload(offset) - validator_revert_uint256(value) + value_3 := calldataload(offset) + validator_revert_t_uint256(value_3) } - function abi_decode_tuple_uint256(headStart, dataEnd) -> value0 + function abi_decode_tuple_t_uint256(headStart, dataEnd) -> value0 { if slt(sub(dataEnd, headStart), 32) { revert_error_dbdddcbe895c83990c08b3492a0e83918d802a52331272ac6fdb6a7c4aea3b1b() } - let offset := 0 - value0 := abi_decode_uint256(add(headStart, offset), dataEnd) + let offset_1 := 0 + value0 := abi_decode_t_uint256(add(headStart, offset_1), dataEnd) } - function abi_encode_tuple(headStart) -> tail - { tail := add(headStart, 0) } - function external_fun_a() + function abi_encode_tuple__to__fromStack(headStart_1) -> tail + { tail := add(headStart_1, 0) } + function external_fun_a_13() { if callvalue() { revert_error_ca66f745a3ce8ff40e2ccaf1ad45db7774001b90d25810abd9040049be7bf4bb() } - let param := abi_decode_tuple_uint256(4, calldatasize()) - fun_a(param) + let param_0 := abi_decode_tuple_t_uint256(4, calldatasize()) + fun_a_13(param_0) let memPos := allocate_unbounded() - let memEnd := abi_encode_tuple(memPos) + let memEnd := abi_encode_tuple__to__fromStack(memPos) return(memPos, sub(memEnd, memPos)) } function revert_error_42b3090547df1d2001c96683413b8cf91c1b902ef5e3cb8d9f6f304cf7446f74() { revert(0, 0) } - function cleanup_rational_by(value) -> cleaned - { cleaned := value } - function identity(value) -> ret - { ret := value } - function convert_rational_by_to_uint256(value) -> converted + function cleanup_t_rational_0_by_1(value_4) -> cleaned_1 + { cleaned_1 := value_4 } + function identity(value_5) -> ret + { ret := value_5 } + function convert_t_rational_0_by_1_to_t_uint256(value_6) -> converted { - converted := cleanup_uint256(identity(cleanup_rational_by(value))) + converted := cleanup_t_uint256(identity(cleanup_t_rational_0_by_1(value_6))) } function panic_error_0x01() { @@ -108,17 +108,17 @@ object \"A1_14\" { if iszero(condition) { panic_error_0x01() } } /// @ast-id 13 @src 0:72:121 \"function a(uint x) public pure { assert(x > 0); }\" - function fun_a(var_x) + function fun_a_13(var_x_3) { /// @src 0:112:113 \"x\" - let _1 := var_x - let expr := _1 + let _1 := var_x_3 + let expr_7 := _1 /// @src 0:116:117 \"0\" - let expr_1 := 0x00 + let expr_8 := 0x00 /// @src 0:112:117 \"x > 0\" - let expr_2 := gt(cleanup_uint256(expr), convert_rational_by_to_uint256(expr_1)) + let expr_9 := gt(cleanup_t_uint256(expr_7), convert_t_rational_0_by_1_to_t_uint256(expr_8)) /// @src 0:105:118 \"assert(x > 0)\" - assert_helper(expr_2) + assert_helper(expr_9) } } data \".metadata\" hex\"\" @@ -163,14 +163,14 @@ object \"A2_27\" { mstore(64, memoryguard(0x80)) if iszero(lt(calldatasize(), 4)) { - let selector := shift_right_unsigned(calldataload(0)) + let selector := shift_right_224_unsigned(calldataload(0)) switch selector - case 0xf0fdf834 { external_fun_a() } + case 0xf0fdf834 { external_fun_a_26() } default { } } revert_error_42b3090547df1d2001c96683413b8cf91c1b902ef5e3cb8d9f6f304cf7446f74() } - function shift_right_unsigned(value) -> newValue + function shift_right_224_unsigned(value) -> newValue { newValue := shr(224, value) } function allocate_unbounded() -> memPtr { memPtr := mload(64) } @@ -178,49 +178,49 @@ object \"A2_27\" { { revert(0, 0) } function revert_error_dbdddcbe895c83990c08b3492a0e83918d802a52331272ac6fdb6a7c4aea3b1b() { revert(0, 0) } - function cleanup_uint256(value) -> cleaned - { cleaned := value } - function validator_revert_uint256(value) + function cleanup_t_uint256(value_1) -> cleaned + { cleaned := value_1 } + function validator_revert_t_uint256(value_2) { - if iszero(eq(value, cleanup_uint256(value))) { revert(0, 0) } + if iszero(eq(value_2, cleanup_t_uint256(value_2))) { revert(0, 0) } } - function abi_decode_uint256(offset, end) -> value + function abi_decode_t_uint256(offset, end) -> value_3 { - value := calldataload(offset) - validator_revert_uint256(value) + value_3 := calldataload(offset) + validator_revert_t_uint256(value_3) } - function abi_decode_tuple_uint256(headStart, dataEnd) -> value0 + function abi_decode_tuple_t_uint256(headStart, dataEnd) -> value0 { if slt(sub(dataEnd, headStart), 32) { revert_error_dbdddcbe895c83990c08b3492a0e83918d802a52331272ac6fdb6a7c4aea3b1b() } - let offset := 0 - value0 := abi_decode_uint256(add(headStart, offset), dataEnd) + let offset_1 := 0 + value0 := abi_decode_t_uint256(add(headStart, offset_1), dataEnd) } - function abi_encode_tuple(headStart) -> tail - { tail := add(headStart, 0) } - function external_fun_a() + function abi_encode_tuple__to__fromStack(headStart_1) -> tail + { tail := add(headStart_1, 0) } + function external_fun_a_26() { if callvalue() { revert_error_ca66f745a3ce8ff40e2ccaf1ad45db7774001b90d25810abd9040049be7bf4bb() } - let param := abi_decode_tuple_uint256(4, calldatasize()) - fun_a(param) + let param_0 := abi_decode_tuple_t_uint256(4, calldatasize()) + fun_a_26(param_0) let memPos := allocate_unbounded() - let memEnd := abi_encode_tuple(memPos) + let memEnd := abi_encode_tuple__to__fromStack(memPos) return(memPos, sub(memEnd, memPos)) } function revert_error_42b3090547df1d2001c96683413b8cf91c1b902ef5e3cb8d9f6f304cf7446f74() { revert(0, 0) } - function cleanup_rational_by(value) -> cleaned - { cleaned := value } - function identity(value) -> ret - { ret := value } - function convert_rational_by_to_uint256(value) -> converted + function cleanup_t_rational_0_by_1(value_4) -> cleaned_1 + { cleaned_1 := value_4 } + function identity(value_5) -> ret + { ret := value_5 } + function convert_t_rational_0_by_1_to_t_uint256(value_6) -> converted { - converted := cleanup_uint256(identity(cleanup_rational_by(value))) + converted := cleanup_t_uint256(identity(cleanup_t_rational_0_by_1(value_6))) } function panic_error_0x01() { @@ -233,17 +233,17 @@ object \"A2_27\" { if iszero(condition) { panic_error_0x01() } } /// @ast-id 26 @src 0:138:187 \"function a(uint x) public pure { assert(x > 0); }\" - function fun_a(var_x) + function fun_a_26(var_x_16) { /// @src 0:178:179 \"x\" - let _1 := var_x - let expr := _1 + let _1 := var_x_16 + let expr_20 := _1 /// @src 0:182:183 \"0\" - let expr_1 := 0x00 + let expr_21 := 0x00 /// @src 0:178:183 \"x > 0\" - let expr_2 := gt(cleanup_uint256(expr), convert_rational_by_to_uint256(expr_1)) + let expr_22 := gt(cleanup_t_uint256(expr_20), convert_t_rational_0_by_1_to_t_uint256(expr_21)) /// @src 0:171:184 \"assert(x > 0)\" - assert_helper(expr_2) + assert_helper(expr_22) } } data \".metadata\" hex\"\" @@ -290,14 +290,14 @@ object \"A1_42\" { mstore(64, memoryguard(0x80)) if iszero(lt(calldatasize(), 4)) { - let selector := shift_right_unsigned(calldataload(0)) + let selector := shift_right_224_unsigned(calldataload(0)) switch selector - case 0xcd580ff3 { external_fun_b() } + case 0xcd580ff3 { external_fun_b_41() } default { } } revert_error_42b3090547df1d2001c96683413b8cf91c1b902ef5e3cb8d9f6f304cf7446f74() } - function shift_right_unsigned(value) -> newValue + function shift_right_224_unsigned(value) -> newValue { newValue := shr(224, value) } function allocate_unbounded() -> memPtr { memPtr := mload(64) } @@ -305,49 +305,49 @@ object \"A1_42\" { { revert(0, 0) } function revert_error_dbdddcbe895c83990c08b3492a0e83918d802a52331272ac6fdb6a7c4aea3b1b() { revert(0, 0) } - function cleanup_uint256(value) -> cleaned - { cleaned := value } - function validator_revert_uint256(value) + function cleanup_t_uint256(value_1) -> cleaned + { cleaned := value_1 } + function validator_revert_t_uint256(value_2) { - if iszero(eq(value, cleanup_uint256(value))) { revert(0, 0) } + if iszero(eq(value_2, cleanup_t_uint256(value_2))) { revert(0, 0) } } - function abi_decode_uint256(offset, end) -> value + function abi_decode_t_uint256(offset, end) -> value_3 { - value := calldataload(offset) - validator_revert_uint256(value) + value_3 := calldataload(offset) + validator_revert_t_uint256(value_3) } - function abi_decode_tuple_uint256(headStart, dataEnd) -> value0 + function abi_decode_tuple_t_uint256(headStart, dataEnd) -> value0 { if slt(sub(dataEnd, headStart), 32) { revert_error_dbdddcbe895c83990c08b3492a0e83918d802a52331272ac6fdb6a7c4aea3b1b() } - let offset := 0 - value0 := abi_decode_uint256(add(headStart, offset), dataEnd) + let offset_1 := 0 + value0 := abi_decode_t_uint256(add(headStart, offset_1), dataEnd) } - function abi_encode_tuple(headStart) -> tail - { tail := add(headStart, 0) } - function external_fun_b() + function abi_encode_tuple__to__fromStack(headStart_1) -> tail + { tail := add(headStart_1, 0) } + function external_fun_b_41() { if callvalue() { revert_error_ca66f745a3ce8ff40e2ccaf1ad45db7774001b90d25810abd9040049be7bf4bb() } - let param := abi_decode_tuple_uint256(4, calldatasize()) - fun_b(param) + let param_0 := abi_decode_tuple_t_uint256(4, calldatasize()) + fun_b_41(param_0) let memPos := allocate_unbounded() - let memEnd := abi_encode_tuple(memPos) + let memEnd := abi_encode_tuple__to__fromStack(memPos) return(memPos, sub(memEnd, memPos)) } function revert_error_42b3090547df1d2001c96683413b8cf91c1b902ef5e3cb8d9f6f304cf7446f74() { revert(0, 0) } - function cleanup_rational_by(value) -> cleaned - { cleaned := value } - function identity(value) -> ret - { ret := value } - function convert_rational_by_to_uint256(value) -> converted + function cleanup_t_rational_0_by_1(value_4) -> cleaned_1 + { cleaned_1 := value_4 } + function identity(value_5) -> ret + { ret := value_5 } + function convert_t_rational_0_by_1_to_t_uint256(value_6) -> converted { - converted := cleanup_uint256(identity(cleanup_rational_by(value))) + converted := cleanup_t_uint256(identity(cleanup_t_rational_0_by_1(value_6))) } function panic_error_0x01() { @@ -360,17 +360,17 @@ object \"A1_42\" { if iszero(condition) { panic_error_0x01() } } /// @ast-id 41 @src 1:72:121 \"function b(uint x) public pure { assert(x > 0); }\" - function fun_b(var_x) + function fun_b_41(var_x_31) { /// @src 1:112:113 \"x\" - let _1 := var_x - let expr := _1 + let _1 := var_x_31 + let expr_35 := _1 /// @src 1:116:117 \"0\" - let expr_1 := 0x00 + let expr_36 := 0x00 /// @src 1:112:117 \"x > 0\" - let expr_2 := gt(cleanup_uint256(expr), convert_rational_by_to_uint256(expr_1)) + let expr_37 := gt(cleanup_t_uint256(expr_35), convert_t_rational_0_by_1_to_t_uint256(expr_36)) /// @src 1:105:118 \"assert(x > 0)\" - assert_helper(expr_2) + assert_helper(expr_37) } } data \".metadata\" hex\"\" @@ -415,14 +415,14 @@ object \"B2_55\" { mstore(64, memoryguard(0x80)) if iszero(lt(calldatasize(), 4)) { - let selector := shift_right_unsigned(calldataload(0)) + let selector := shift_right_224_unsigned(calldataload(0)) switch selector - case 0xcd580ff3 { external_fun_b() } + case 0xcd580ff3 { external_fun_b_54() } default { } } revert_error_42b3090547df1d2001c96683413b8cf91c1b902ef5e3cb8d9f6f304cf7446f74() } - function shift_right_unsigned(value) -> newValue + function shift_right_224_unsigned(value) -> newValue { newValue := shr(224, value) } function allocate_unbounded() -> memPtr { memPtr := mload(64) } @@ -430,49 +430,49 @@ object \"B2_55\" { { revert(0, 0) } function revert_error_dbdddcbe895c83990c08b3492a0e83918d802a52331272ac6fdb6a7c4aea3b1b() { revert(0, 0) } - function cleanup_uint256(value) -> cleaned - { cleaned := value } - function validator_revert_uint256(value) + function cleanup_t_uint256(value_1) -> cleaned + { cleaned := value_1 } + function validator_revert_t_uint256(value_2) { - if iszero(eq(value, cleanup_uint256(value))) { revert(0, 0) } + if iszero(eq(value_2, cleanup_t_uint256(value_2))) { revert(0, 0) } } - function abi_decode_uint256(offset, end) -> value + function abi_decode_t_uint256(offset, end) -> value_3 { - value := calldataload(offset) - validator_revert_uint256(value) + value_3 := calldataload(offset) + validator_revert_t_uint256(value_3) } - function abi_decode_tuple_uint256(headStart, dataEnd) -> value0 + function abi_decode_tuple_t_uint256(headStart, dataEnd) -> value0 { if slt(sub(dataEnd, headStart), 32) { revert_error_dbdddcbe895c83990c08b3492a0e83918d802a52331272ac6fdb6a7c4aea3b1b() } - let offset := 0 - value0 := abi_decode_uint256(add(headStart, offset), dataEnd) + let offset_1 := 0 + value0 := abi_decode_t_uint256(add(headStart, offset_1), dataEnd) } - function abi_encode_tuple(headStart) -> tail - { tail := add(headStart, 0) } - function external_fun_b() + function abi_encode_tuple__to__fromStack(headStart_1) -> tail + { tail := add(headStart_1, 0) } + function external_fun_b_54() { if callvalue() { revert_error_ca66f745a3ce8ff40e2ccaf1ad45db7774001b90d25810abd9040049be7bf4bb() } - let param := abi_decode_tuple_uint256(4, calldatasize()) - fun_b(param) + let param_0 := abi_decode_tuple_t_uint256(4, calldatasize()) + fun_b_54(param_0) let memPos := allocate_unbounded() - let memEnd := abi_encode_tuple(memPos) + let memEnd := abi_encode_tuple__to__fromStack(memPos) return(memPos, sub(memEnd, memPos)) } function revert_error_42b3090547df1d2001c96683413b8cf91c1b902ef5e3cb8d9f6f304cf7446f74() { revert(0, 0) } - function cleanup_rational_by(value) -> cleaned - { cleaned := value } - function identity(value) -> ret - { ret := value } - function convert_rational_by_to_uint256(value) -> converted + function cleanup_t_rational_0_by_1(value_4) -> cleaned_1 + { cleaned_1 := value_4 } + function identity(value_5) -> ret + { ret := value_5 } + function convert_t_rational_0_by_1_to_t_uint256(value_6) -> converted { - converted := cleanup_uint256(identity(cleanup_rational_by(value))) + converted := cleanup_t_uint256(identity(cleanup_t_rational_0_by_1(value_6))) } function panic_error_0x01() { @@ -485,17 +485,17 @@ object \"B2_55\" { if iszero(condition) { panic_error_0x01() } } /// @ast-id 54 @src 1:138:187 \"function b(uint x) public pure { assert(x > 0); }\" - function fun_b(var_x) + function fun_b_54(var_x_44) { /// @src 1:178:179 \"x\" - let _1 := var_x - let expr := _1 + let _1 := var_x_44 + let expr_48 := _1 /// @src 1:182:183 \"0\" - let expr_1 := 0x00 + let expr_49 := 0x00 /// @src 1:178:183 \"x > 0\" - let expr_2 := gt(cleanup_uint256(expr), convert_rational_by_to_uint256(expr_1)) + let expr_50 := gt(cleanup_t_uint256(expr_48), convert_t_rational_0_by_1_to_t_uint256(expr_49)) /// @src 1:171:184 \"assert(x > 0)\" - assert_helper(expr_2) + assert_helper(expr_50) } } data \".metadata\" hex\"\" diff --git a/test/cmdlineTests/standard_output_selection_ethdebug_bytecode_iroptimized/output.json b/test/cmdlineTests/standard_output_selection_ethdebug_bytecode_iroptimized/output.json index eab40879c4c5..0f277bbaaf86 100644 --- a/test/cmdlineTests/standard_output_selection_ethdebug_bytecode_iroptimized/output.json +++ b/test/cmdlineTests/standard_output_selection_ethdebug_bytecode_iroptimized/output.json @@ -35,14 +35,14 @@ object \"A1_14\" { mstore(64, memoryguard(0x80)) if iszero(lt(calldatasize(), 4)) { - let selector := shift_right_unsigned(calldataload(0)) + let selector := shift_right_224_unsigned(calldataload(0)) switch selector - case 0xf0fdf834 { external_fun_a() } + case 0xf0fdf834 { external_fun_a_13() } default { } } revert_error_42b3090547df1d2001c96683413b8cf91c1b902ef5e3cb8d9f6f304cf7446f74() } - function shift_right_unsigned(value) -> newValue + function shift_right_224_unsigned(value) -> newValue { newValue := shr(224, value) } function allocate_unbounded() -> memPtr { memPtr := mload(64) } @@ -50,49 +50,49 @@ object \"A1_14\" { { revert(0, 0) } function revert_error_dbdddcbe895c83990c08b3492a0e83918d802a52331272ac6fdb6a7c4aea3b1b() { revert(0, 0) } - function cleanup_uint256(value) -> cleaned - { cleaned := value } - function validator_revert_uint256(value) + function cleanup_t_uint256(value_1) -> cleaned + { cleaned := value_1 } + function validator_revert_t_uint256(value_2) { - if iszero(eq(value, cleanup_uint256(value))) { revert(0, 0) } + if iszero(eq(value_2, cleanup_t_uint256(value_2))) { revert(0, 0) } } - function abi_decode_uint256(offset, end) -> value + function abi_decode_t_uint256(offset, end) -> value_3 { - value := calldataload(offset) - validator_revert_uint256(value) + value_3 := calldataload(offset) + validator_revert_t_uint256(value_3) } - function abi_decode_tuple_uint256(headStart, dataEnd) -> value0 + function abi_decode_tuple_t_uint256(headStart, dataEnd) -> value0 { if slt(sub(dataEnd, headStart), 32) { revert_error_dbdddcbe895c83990c08b3492a0e83918d802a52331272ac6fdb6a7c4aea3b1b() } - let offset := 0 - value0 := abi_decode_uint256(add(headStart, offset), dataEnd) + let offset_1 := 0 + value0 := abi_decode_t_uint256(add(headStart, offset_1), dataEnd) } - function abi_encode_tuple(headStart) -> tail - { tail := add(headStart, 0) } - function external_fun_a() + function abi_encode_tuple__to__fromStack(headStart_1) -> tail + { tail := add(headStart_1, 0) } + function external_fun_a_13() { if callvalue() { revert_error_ca66f745a3ce8ff40e2ccaf1ad45db7774001b90d25810abd9040049be7bf4bb() } - let param := abi_decode_tuple_uint256(4, calldatasize()) - fun_a(param) + let param_0 := abi_decode_tuple_t_uint256(4, calldatasize()) + fun_a_13(param_0) let memPos := allocate_unbounded() - let memEnd := abi_encode_tuple(memPos) + let memEnd := abi_encode_tuple__to__fromStack(memPos) return(memPos, sub(memEnd, memPos)) } function revert_error_42b3090547df1d2001c96683413b8cf91c1b902ef5e3cb8d9f6f304cf7446f74() { revert(0, 0) } - function cleanup_rational_by(value) -> cleaned - { cleaned := value } - function identity(value) -> ret - { ret := value } - function convert_rational_by_to_uint256(value) -> converted + function cleanup_t_rational_0_by_1(value_4) -> cleaned_1 + { cleaned_1 := value_4 } + function identity(value_5) -> ret + { ret := value_5 } + function convert_t_rational_0_by_1_to_t_uint256(value_6) -> converted { - converted := cleanup_uint256(identity(cleanup_rational_by(value))) + converted := cleanup_t_uint256(identity(cleanup_t_rational_0_by_1(value_6))) } function panic_error_0x01() { @@ -105,17 +105,17 @@ object \"A1_14\" { if iszero(condition) { panic_error_0x01() } } /// @ast-id 13 @src 0:72:121 \"function a(uint x) public pure { assert(x > 0); }\" - function fun_a(var_x) + function fun_a_13(var_x_3) { /// @src 0:112:113 \"x\" - let _1 := var_x - let expr := _1 + let _1 := var_x_3 + let expr_7 := _1 /// @src 0:116:117 \"0\" - let expr_1 := 0x00 + let expr_8 := 0x00 /// @src 0:112:117 \"x > 0\" - let expr_2 := gt(cleanup_uint256(expr), convert_rational_by_to_uint256(expr_1)) + let expr_9 := gt(cleanup_t_uint256(expr_7), convert_t_rational_0_by_1_to_t_uint256(expr_8)) /// @src 0:105:118 \"assert(x > 0)\" - assert_helper(expr_2) + assert_helper(expr_9) } } data \".metadata\" hex\"\" @@ -157,14 +157,14 @@ object \"A2_27\" { mstore(64, memoryguard(0x80)) if iszero(lt(calldatasize(), 4)) { - let selector := shift_right_unsigned(calldataload(0)) + let selector := shift_right_224_unsigned(calldataload(0)) switch selector - case 0xf0fdf834 { external_fun_a() } + case 0xf0fdf834 { external_fun_a_26() } default { } } revert_error_42b3090547df1d2001c96683413b8cf91c1b902ef5e3cb8d9f6f304cf7446f74() } - function shift_right_unsigned(value) -> newValue + function shift_right_224_unsigned(value) -> newValue { newValue := shr(224, value) } function allocate_unbounded() -> memPtr { memPtr := mload(64) } @@ -172,49 +172,49 @@ object \"A2_27\" { { revert(0, 0) } function revert_error_dbdddcbe895c83990c08b3492a0e83918d802a52331272ac6fdb6a7c4aea3b1b() { revert(0, 0) } - function cleanup_uint256(value) -> cleaned - { cleaned := value } - function validator_revert_uint256(value) + function cleanup_t_uint256(value_1) -> cleaned + { cleaned := value_1 } + function validator_revert_t_uint256(value_2) { - if iszero(eq(value, cleanup_uint256(value))) { revert(0, 0) } + if iszero(eq(value_2, cleanup_t_uint256(value_2))) { revert(0, 0) } } - function abi_decode_uint256(offset, end) -> value + function abi_decode_t_uint256(offset, end) -> value_3 { - value := calldataload(offset) - validator_revert_uint256(value) + value_3 := calldataload(offset) + validator_revert_t_uint256(value_3) } - function abi_decode_tuple_uint256(headStart, dataEnd) -> value0 + function abi_decode_tuple_t_uint256(headStart, dataEnd) -> value0 { if slt(sub(dataEnd, headStart), 32) { revert_error_dbdddcbe895c83990c08b3492a0e83918d802a52331272ac6fdb6a7c4aea3b1b() } - let offset := 0 - value0 := abi_decode_uint256(add(headStart, offset), dataEnd) + let offset_1 := 0 + value0 := abi_decode_t_uint256(add(headStart, offset_1), dataEnd) } - function abi_encode_tuple(headStart) -> tail - { tail := add(headStart, 0) } - function external_fun_a() + function abi_encode_tuple__to__fromStack(headStart_1) -> tail + { tail := add(headStart_1, 0) } + function external_fun_a_26() { if callvalue() { revert_error_ca66f745a3ce8ff40e2ccaf1ad45db7774001b90d25810abd9040049be7bf4bb() } - let param := abi_decode_tuple_uint256(4, calldatasize()) - fun_a(param) + let param_0 := abi_decode_tuple_t_uint256(4, calldatasize()) + fun_a_26(param_0) let memPos := allocate_unbounded() - let memEnd := abi_encode_tuple(memPos) + let memEnd := abi_encode_tuple__to__fromStack(memPos) return(memPos, sub(memEnd, memPos)) } function revert_error_42b3090547df1d2001c96683413b8cf91c1b902ef5e3cb8d9f6f304cf7446f74() { revert(0, 0) } - function cleanup_rational_by(value) -> cleaned - { cleaned := value } - function identity(value) -> ret - { ret := value } - function convert_rational_by_to_uint256(value) -> converted + function cleanup_t_rational_0_by_1(value_4) -> cleaned_1 + { cleaned_1 := value_4 } + function identity(value_5) -> ret + { ret := value_5 } + function convert_t_rational_0_by_1_to_t_uint256(value_6) -> converted { - converted := cleanup_uint256(identity(cleanup_rational_by(value))) + converted := cleanup_t_uint256(identity(cleanup_t_rational_0_by_1(value_6))) } function panic_error_0x01() { @@ -227,17 +227,17 @@ object \"A2_27\" { if iszero(condition) { panic_error_0x01() } } /// @ast-id 26 @src 0:138:187 \"function a(uint x) public pure { assert(x > 0); }\" - function fun_a(var_x) + function fun_a_26(var_x_16) { /// @src 0:178:179 \"x\" - let _1 := var_x - let expr := _1 + let _1 := var_x_16 + let expr_20 := _1 /// @src 0:182:183 \"0\" - let expr_1 := 0x00 + let expr_21 := 0x00 /// @src 0:178:183 \"x > 0\" - let expr_2 := gt(cleanup_uint256(expr), convert_rational_by_to_uint256(expr_1)) + let expr_22 := gt(cleanup_t_uint256(expr_20), convert_t_rational_0_by_1_to_t_uint256(expr_21)) /// @src 0:171:184 \"assert(x > 0)\" - assert_helper(expr_2) + assert_helper(expr_22) } } data \".metadata\" hex\"\" @@ -281,14 +281,14 @@ object \"A1_42\" { mstore(64, memoryguard(0x80)) if iszero(lt(calldatasize(), 4)) { - let selector := shift_right_unsigned(calldataload(0)) + let selector := shift_right_224_unsigned(calldataload(0)) switch selector - case 0xcd580ff3 { external_fun_b() } + case 0xcd580ff3 { external_fun_b_41() } default { } } revert_error_42b3090547df1d2001c96683413b8cf91c1b902ef5e3cb8d9f6f304cf7446f74() } - function shift_right_unsigned(value) -> newValue + function shift_right_224_unsigned(value) -> newValue { newValue := shr(224, value) } function allocate_unbounded() -> memPtr { memPtr := mload(64) } @@ -296,49 +296,49 @@ object \"A1_42\" { { revert(0, 0) } function revert_error_dbdddcbe895c83990c08b3492a0e83918d802a52331272ac6fdb6a7c4aea3b1b() { revert(0, 0) } - function cleanup_uint256(value) -> cleaned - { cleaned := value } - function validator_revert_uint256(value) + function cleanup_t_uint256(value_1) -> cleaned + { cleaned := value_1 } + function validator_revert_t_uint256(value_2) { - if iszero(eq(value, cleanup_uint256(value))) { revert(0, 0) } + if iszero(eq(value_2, cleanup_t_uint256(value_2))) { revert(0, 0) } } - function abi_decode_uint256(offset, end) -> value + function abi_decode_t_uint256(offset, end) -> value_3 { - value := calldataload(offset) - validator_revert_uint256(value) + value_3 := calldataload(offset) + validator_revert_t_uint256(value_3) } - function abi_decode_tuple_uint256(headStart, dataEnd) -> value0 + function abi_decode_tuple_t_uint256(headStart, dataEnd) -> value0 { if slt(sub(dataEnd, headStart), 32) { revert_error_dbdddcbe895c83990c08b3492a0e83918d802a52331272ac6fdb6a7c4aea3b1b() } - let offset := 0 - value0 := abi_decode_uint256(add(headStart, offset), dataEnd) + let offset_1 := 0 + value0 := abi_decode_t_uint256(add(headStart, offset_1), dataEnd) } - function abi_encode_tuple(headStart) -> tail - { tail := add(headStart, 0) } - function external_fun_b() + function abi_encode_tuple__to__fromStack(headStart_1) -> tail + { tail := add(headStart_1, 0) } + function external_fun_b_41() { if callvalue() { revert_error_ca66f745a3ce8ff40e2ccaf1ad45db7774001b90d25810abd9040049be7bf4bb() } - let param := abi_decode_tuple_uint256(4, calldatasize()) - fun_b(param) + let param_0 := abi_decode_tuple_t_uint256(4, calldatasize()) + fun_b_41(param_0) let memPos := allocate_unbounded() - let memEnd := abi_encode_tuple(memPos) + let memEnd := abi_encode_tuple__to__fromStack(memPos) return(memPos, sub(memEnd, memPos)) } function revert_error_42b3090547df1d2001c96683413b8cf91c1b902ef5e3cb8d9f6f304cf7446f74() { revert(0, 0) } - function cleanup_rational_by(value) -> cleaned - { cleaned := value } - function identity(value) -> ret - { ret := value } - function convert_rational_by_to_uint256(value) -> converted + function cleanup_t_rational_0_by_1(value_4) -> cleaned_1 + { cleaned_1 := value_4 } + function identity(value_5) -> ret + { ret := value_5 } + function convert_t_rational_0_by_1_to_t_uint256(value_6) -> converted { - converted := cleanup_uint256(identity(cleanup_rational_by(value))) + converted := cleanup_t_uint256(identity(cleanup_t_rational_0_by_1(value_6))) } function panic_error_0x01() { @@ -351,17 +351,17 @@ object \"A1_42\" { if iszero(condition) { panic_error_0x01() } } /// @ast-id 41 @src 1:72:121 \"function b(uint x) public pure { assert(x > 0); }\" - function fun_b(var_x) + function fun_b_41(var_x_31) { /// @src 1:112:113 \"x\" - let _1 := var_x - let expr := _1 + let _1 := var_x_31 + let expr_35 := _1 /// @src 1:116:117 \"0\" - let expr_1 := 0x00 + let expr_36 := 0x00 /// @src 1:112:117 \"x > 0\" - let expr_2 := gt(cleanup_uint256(expr), convert_rational_by_to_uint256(expr_1)) + let expr_37 := gt(cleanup_t_uint256(expr_35), convert_t_rational_0_by_1_to_t_uint256(expr_36)) /// @src 1:105:118 \"assert(x > 0)\" - assert_helper(expr_2) + assert_helper(expr_37) } } data \".metadata\" hex\"\" @@ -403,14 +403,14 @@ object \"B2_55\" { mstore(64, memoryguard(0x80)) if iszero(lt(calldatasize(), 4)) { - let selector := shift_right_unsigned(calldataload(0)) + let selector := shift_right_224_unsigned(calldataload(0)) switch selector - case 0xcd580ff3 { external_fun_b() } + case 0xcd580ff3 { external_fun_b_54() } default { } } revert_error_42b3090547df1d2001c96683413b8cf91c1b902ef5e3cb8d9f6f304cf7446f74() } - function shift_right_unsigned(value) -> newValue + function shift_right_224_unsigned(value) -> newValue { newValue := shr(224, value) } function allocate_unbounded() -> memPtr { memPtr := mload(64) } @@ -418,49 +418,49 @@ object \"B2_55\" { { revert(0, 0) } function revert_error_dbdddcbe895c83990c08b3492a0e83918d802a52331272ac6fdb6a7c4aea3b1b() { revert(0, 0) } - function cleanup_uint256(value) -> cleaned - { cleaned := value } - function validator_revert_uint256(value) + function cleanup_t_uint256(value_1) -> cleaned + { cleaned := value_1 } + function validator_revert_t_uint256(value_2) { - if iszero(eq(value, cleanup_uint256(value))) { revert(0, 0) } + if iszero(eq(value_2, cleanup_t_uint256(value_2))) { revert(0, 0) } } - function abi_decode_uint256(offset, end) -> value + function abi_decode_t_uint256(offset, end) -> value_3 { - value := calldataload(offset) - validator_revert_uint256(value) + value_3 := calldataload(offset) + validator_revert_t_uint256(value_3) } - function abi_decode_tuple_uint256(headStart, dataEnd) -> value0 + function abi_decode_tuple_t_uint256(headStart, dataEnd) -> value0 { if slt(sub(dataEnd, headStart), 32) { revert_error_dbdddcbe895c83990c08b3492a0e83918d802a52331272ac6fdb6a7c4aea3b1b() } - let offset := 0 - value0 := abi_decode_uint256(add(headStart, offset), dataEnd) + let offset_1 := 0 + value0 := abi_decode_t_uint256(add(headStart, offset_1), dataEnd) } - function abi_encode_tuple(headStart) -> tail - { tail := add(headStart, 0) } - function external_fun_b() + function abi_encode_tuple__to__fromStack(headStart_1) -> tail + { tail := add(headStart_1, 0) } + function external_fun_b_54() { if callvalue() { revert_error_ca66f745a3ce8ff40e2ccaf1ad45db7774001b90d25810abd9040049be7bf4bb() } - let param := abi_decode_tuple_uint256(4, calldatasize()) - fun_b(param) + let param_0 := abi_decode_tuple_t_uint256(4, calldatasize()) + fun_b_54(param_0) let memPos := allocate_unbounded() - let memEnd := abi_encode_tuple(memPos) + let memEnd := abi_encode_tuple__to__fromStack(memPos) return(memPos, sub(memEnd, memPos)) } function revert_error_42b3090547df1d2001c96683413b8cf91c1b902ef5e3cb8d9f6f304cf7446f74() { revert(0, 0) } - function cleanup_rational_by(value) -> cleaned - { cleaned := value } - function identity(value) -> ret - { ret := value } - function convert_rational_by_to_uint256(value) -> converted + function cleanup_t_rational_0_by_1(value_4) -> cleaned_1 + { cleaned_1 := value_4 } + function identity(value_5) -> ret + { ret := value_5 } + function convert_t_rational_0_by_1_to_t_uint256(value_6) -> converted { - converted := cleanup_uint256(identity(cleanup_rational_by(value))) + converted := cleanup_t_uint256(identity(cleanup_t_rational_0_by_1(value_6))) } function panic_error_0x01() { @@ -473,17 +473,17 @@ object \"B2_55\" { if iszero(condition) { panic_error_0x01() } } /// @ast-id 54 @src 1:138:187 \"function b(uint x) public pure { assert(x > 0); }\" - function fun_b(var_x) + function fun_b_54(var_x_44) { /// @src 1:178:179 \"x\" - let _1 := var_x - let expr := _1 + let _1 := var_x_44 + let expr_48 := _1 /// @src 1:182:183 \"0\" - let expr_1 := 0x00 + let expr_49 := 0x00 /// @src 1:178:183 \"x > 0\" - let expr_2 := gt(cleanup_uint256(expr), convert_rational_by_to_uint256(expr_1)) + let expr_50 := gt(cleanup_t_uint256(expr_48), convert_t_rational_0_by_1_to_t_uint256(expr_49)) /// @src 1:171:184 \"assert(x > 0)\" - assert_helper(expr_2) + assert_helper(expr_50) } } data \".metadata\" hex\"\" diff --git a/test/cmdlineTests/standard_output_selection_ethdebug_deployedbytecode_iroptimized/output.json b/test/cmdlineTests/standard_output_selection_ethdebug_deployedbytecode_iroptimized/output.json index 4f3bd68eed09..0726116e82ad 100644 --- a/test/cmdlineTests/standard_output_selection_ethdebug_deployedbytecode_iroptimized/output.json +++ b/test/cmdlineTests/standard_output_selection_ethdebug_deployedbytecode_iroptimized/output.json @@ -35,14 +35,14 @@ object \"A1_14\" { mstore(64, memoryguard(0x80)) if iszero(lt(calldatasize(), 4)) { - let selector := shift_right_unsigned(calldataload(0)) + let selector := shift_right_224_unsigned(calldataload(0)) switch selector - case 0xf0fdf834 { external_fun_a() } + case 0xf0fdf834 { external_fun_a_13() } default { } } revert_error_42b3090547df1d2001c96683413b8cf91c1b902ef5e3cb8d9f6f304cf7446f74() } - function shift_right_unsigned(value) -> newValue + function shift_right_224_unsigned(value) -> newValue { newValue := shr(224, value) } function allocate_unbounded() -> memPtr { memPtr := mload(64) } @@ -50,49 +50,49 @@ object \"A1_14\" { { revert(0, 0) } function revert_error_dbdddcbe895c83990c08b3492a0e83918d802a52331272ac6fdb6a7c4aea3b1b() { revert(0, 0) } - function cleanup_uint256(value) -> cleaned - { cleaned := value } - function validator_revert_uint256(value) + function cleanup_t_uint256(value_1) -> cleaned + { cleaned := value_1 } + function validator_revert_t_uint256(value_2) { - if iszero(eq(value, cleanup_uint256(value))) { revert(0, 0) } + if iszero(eq(value_2, cleanup_t_uint256(value_2))) { revert(0, 0) } } - function abi_decode_uint256(offset, end) -> value + function abi_decode_t_uint256(offset, end) -> value_3 { - value := calldataload(offset) - validator_revert_uint256(value) + value_3 := calldataload(offset) + validator_revert_t_uint256(value_3) } - function abi_decode_tuple_uint256(headStart, dataEnd) -> value0 + function abi_decode_tuple_t_uint256(headStart, dataEnd) -> value0 { if slt(sub(dataEnd, headStart), 32) { revert_error_dbdddcbe895c83990c08b3492a0e83918d802a52331272ac6fdb6a7c4aea3b1b() } - let offset := 0 - value0 := abi_decode_uint256(add(headStart, offset), dataEnd) + let offset_1 := 0 + value0 := abi_decode_t_uint256(add(headStart, offset_1), dataEnd) } - function abi_encode_tuple(headStart) -> tail - { tail := add(headStart, 0) } - function external_fun_a() + function abi_encode_tuple__to__fromStack(headStart_1) -> tail + { tail := add(headStart_1, 0) } + function external_fun_a_13() { if callvalue() { revert_error_ca66f745a3ce8ff40e2ccaf1ad45db7774001b90d25810abd9040049be7bf4bb() } - let param := abi_decode_tuple_uint256(4, calldatasize()) - fun_a(param) + let param_0 := abi_decode_tuple_t_uint256(4, calldatasize()) + fun_a_13(param_0) let memPos := allocate_unbounded() - let memEnd := abi_encode_tuple(memPos) + let memEnd := abi_encode_tuple__to__fromStack(memPos) return(memPos, sub(memEnd, memPos)) } function revert_error_42b3090547df1d2001c96683413b8cf91c1b902ef5e3cb8d9f6f304cf7446f74() { revert(0, 0) } - function cleanup_rational_by(value) -> cleaned - { cleaned := value } - function identity(value) -> ret - { ret := value } - function convert_rational_by_to_uint256(value) -> converted + function cleanup_t_rational_0_by_1(value_4) -> cleaned_1 + { cleaned_1 := value_4 } + function identity(value_5) -> ret + { ret := value_5 } + function convert_t_rational_0_by_1_to_t_uint256(value_6) -> converted { - converted := cleanup_uint256(identity(cleanup_rational_by(value))) + converted := cleanup_t_uint256(identity(cleanup_t_rational_0_by_1(value_6))) } function panic_error_0x01() { @@ -105,17 +105,17 @@ object \"A1_14\" { if iszero(condition) { panic_error_0x01() } } /// @ast-id 13 @src 0:72:121 \"function a(uint x) public pure { assert(x > 0); }\" - function fun_a(var_x) + function fun_a_13(var_x_3) { /// @src 0:112:113 \"x\" - let _1 := var_x - let expr := _1 + let _1 := var_x_3 + let expr_7 := _1 /// @src 0:116:117 \"0\" - let expr_1 := 0x00 + let expr_8 := 0x00 /// @src 0:112:117 \"x > 0\" - let expr_2 := gt(cleanup_uint256(expr), convert_rational_by_to_uint256(expr_1)) + let expr_9 := gt(cleanup_t_uint256(expr_7), convert_t_rational_0_by_1_to_t_uint256(expr_8)) /// @src 0:105:118 \"assert(x > 0)\" - assert_helper(expr_2) + assert_helper(expr_9) } } data \".metadata\" hex\"\" @@ -157,14 +157,14 @@ object \"A2_27\" { mstore(64, memoryguard(0x80)) if iszero(lt(calldatasize(), 4)) { - let selector := shift_right_unsigned(calldataload(0)) + let selector := shift_right_224_unsigned(calldataload(0)) switch selector - case 0xf0fdf834 { external_fun_a() } + case 0xf0fdf834 { external_fun_a_26() } default { } } revert_error_42b3090547df1d2001c96683413b8cf91c1b902ef5e3cb8d9f6f304cf7446f74() } - function shift_right_unsigned(value) -> newValue + function shift_right_224_unsigned(value) -> newValue { newValue := shr(224, value) } function allocate_unbounded() -> memPtr { memPtr := mload(64) } @@ -172,49 +172,49 @@ object \"A2_27\" { { revert(0, 0) } function revert_error_dbdddcbe895c83990c08b3492a0e83918d802a52331272ac6fdb6a7c4aea3b1b() { revert(0, 0) } - function cleanup_uint256(value) -> cleaned - { cleaned := value } - function validator_revert_uint256(value) + function cleanup_t_uint256(value_1) -> cleaned + { cleaned := value_1 } + function validator_revert_t_uint256(value_2) { - if iszero(eq(value, cleanup_uint256(value))) { revert(0, 0) } + if iszero(eq(value_2, cleanup_t_uint256(value_2))) { revert(0, 0) } } - function abi_decode_uint256(offset, end) -> value + function abi_decode_t_uint256(offset, end) -> value_3 { - value := calldataload(offset) - validator_revert_uint256(value) + value_3 := calldataload(offset) + validator_revert_t_uint256(value_3) } - function abi_decode_tuple_uint256(headStart, dataEnd) -> value0 + function abi_decode_tuple_t_uint256(headStart, dataEnd) -> value0 { if slt(sub(dataEnd, headStart), 32) { revert_error_dbdddcbe895c83990c08b3492a0e83918d802a52331272ac6fdb6a7c4aea3b1b() } - let offset := 0 - value0 := abi_decode_uint256(add(headStart, offset), dataEnd) + let offset_1 := 0 + value0 := abi_decode_t_uint256(add(headStart, offset_1), dataEnd) } - function abi_encode_tuple(headStart) -> tail - { tail := add(headStart, 0) } - function external_fun_a() + function abi_encode_tuple__to__fromStack(headStart_1) -> tail + { tail := add(headStart_1, 0) } + function external_fun_a_26() { if callvalue() { revert_error_ca66f745a3ce8ff40e2ccaf1ad45db7774001b90d25810abd9040049be7bf4bb() } - let param := abi_decode_tuple_uint256(4, calldatasize()) - fun_a(param) + let param_0 := abi_decode_tuple_t_uint256(4, calldatasize()) + fun_a_26(param_0) let memPos := allocate_unbounded() - let memEnd := abi_encode_tuple(memPos) + let memEnd := abi_encode_tuple__to__fromStack(memPos) return(memPos, sub(memEnd, memPos)) } function revert_error_42b3090547df1d2001c96683413b8cf91c1b902ef5e3cb8d9f6f304cf7446f74() { revert(0, 0) } - function cleanup_rational_by(value) -> cleaned - { cleaned := value } - function identity(value) -> ret - { ret := value } - function convert_rational_by_to_uint256(value) -> converted + function cleanup_t_rational_0_by_1(value_4) -> cleaned_1 + { cleaned_1 := value_4 } + function identity(value_5) -> ret + { ret := value_5 } + function convert_t_rational_0_by_1_to_t_uint256(value_6) -> converted { - converted := cleanup_uint256(identity(cleanup_rational_by(value))) + converted := cleanup_t_uint256(identity(cleanup_t_rational_0_by_1(value_6))) } function panic_error_0x01() { @@ -227,17 +227,17 @@ object \"A2_27\" { if iszero(condition) { panic_error_0x01() } } /// @ast-id 26 @src 0:138:187 \"function a(uint x) public pure { assert(x > 0); }\" - function fun_a(var_x) + function fun_a_26(var_x_16) { /// @src 0:178:179 \"x\" - let _1 := var_x - let expr := _1 + let _1 := var_x_16 + let expr_20 := _1 /// @src 0:182:183 \"0\" - let expr_1 := 0x00 + let expr_21 := 0x00 /// @src 0:178:183 \"x > 0\" - let expr_2 := gt(cleanup_uint256(expr), convert_rational_by_to_uint256(expr_1)) + let expr_22 := gt(cleanup_t_uint256(expr_20), convert_t_rational_0_by_1_to_t_uint256(expr_21)) /// @src 0:171:184 \"assert(x > 0)\" - assert_helper(expr_2) + assert_helper(expr_22) } } data \".metadata\" hex\"\" @@ -281,14 +281,14 @@ object \"A1_42\" { mstore(64, memoryguard(0x80)) if iszero(lt(calldatasize(), 4)) { - let selector := shift_right_unsigned(calldataload(0)) + let selector := shift_right_224_unsigned(calldataload(0)) switch selector - case 0xcd580ff3 { external_fun_b() } + case 0xcd580ff3 { external_fun_b_41() } default { } } revert_error_42b3090547df1d2001c96683413b8cf91c1b902ef5e3cb8d9f6f304cf7446f74() } - function shift_right_unsigned(value) -> newValue + function shift_right_224_unsigned(value) -> newValue { newValue := shr(224, value) } function allocate_unbounded() -> memPtr { memPtr := mload(64) } @@ -296,49 +296,49 @@ object \"A1_42\" { { revert(0, 0) } function revert_error_dbdddcbe895c83990c08b3492a0e83918d802a52331272ac6fdb6a7c4aea3b1b() { revert(0, 0) } - function cleanup_uint256(value) -> cleaned - { cleaned := value } - function validator_revert_uint256(value) + function cleanup_t_uint256(value_1) -> cleaned + { cleaned := value_1 } + function validator_revert_t_uint256(value_2) { - if iszero(eq(value, cleanup_uint256(value))) { revert(0, 0) } + if iszero(eq(value_2, cleanup_t_uint256(value_2))) { revert(0, 0) } } - function abi_decode_uint256(offset, end) -> value + function abi_decode_t_uint256(offset, end) -> value_3 { - value := calldataload(offset) - validator_revert_uint256(value) + value_3 := calldataload(offset) + validator_revert_t_uint256(value_3) } - function abi_decode_tuple_uint256(headStart, dataEnd) -> value0 + function abi_decode_tuple_t_uint256(headStart, dataEnd) -> value0 { if slt(sub(dataEnd, headStart), 32) { revert_error_dbdddcbe895c83990c08b3492a0e83918d802a52331272ac6fdb6a7c4aea3b1b() } - let offset := 0 - value0 := abi_decode_uint256(add(headStart, offset), dataEnd) + let offset_1 := 0 + value0 := abi_decode_t_uint256(add(headStart, offset_1), dataEnd) } - function abi_encode_tuple(headStart) -> tail - { tail := add(headStart, 0) } - function external_fun_b() + function abi_encode_tuple__to__fromStack(headStart_1) -> tail + { tail := add(headStart_1, 0) } + function external_fun_b_41() { if callvalue() { revert_error_ca66f745a3ce8ff40e2ccaf1ad45db7774001b90d25810abd9040049be7bf4bb() } - let param := abi_decode_tuple_uint256(4, calldatasize()) - fun_b(param) + let param_0 := abi_decode_tuple_t_uint256(4, calldatasize()) + fun_b_41(param_0) let memPos := allocate_unbounded() - let memEnd := abi_encode_tuple(memPos) + let memEnd := abi_encode_tuple__to__fromStack(memPos) return(memPos, sub(memEnd, memPos)) } function revert_error_42b3090547df1d2001c96683413b8cf91c1b902ef5e3cb8d9f6f304cf7446f74() { revert(0, 0) } - function cleanup_rational_by(value) -> cleaned - { cleaned := value } - function identity(value) -> ret - { ret := value } - function convert_rational_by_to_uint256(value) -> converted + function cleanup_t_rational_0_by_1(value_4) -> cleaned_1 + { cleaned_1 := value_4 } + function identity(value_5) -> ret + { ret := value_5 } + function convert_t_rational_0_by_1_to_t_uint256(value_6) -> converted { - converted := cleanup_uint256(identity(cleanup_rational_by(value))) + converted := cleanup_t_uint256(identity(cleanup_t_rational_0_by_1(value_6))) } function panic_error_0x01() { @@ -351,17 +351,17 @@ object \"A1_42\" { if iszero(condition) { panic_error_0x01() } } /// @ast-id 41 @src 1:72:121 \"function b(uint x) public pure { assert(x > 0); }\" - function fun_b(var_x) + function fun_b_41(var_x_31) { /// @src 1:112:113 \"x\" - let _1 := var_x - let expr := _1 + let _1 := var_x_31 + let expr_35 := _1 /// @src 1:116:117 \"0\" - let expr_1 := 0x00 + let expr_36 := 0x00 /// @src 1:112:117 \"x > 0\" - let expr_2 := gt(cleanup_uint256(expr), convert_rational_by_to_uint256(expr_1)) + let expr_37 := gt(cleanup_t_uint256(expr_35), convert_t_rational_0_by_1_to_t_uint256(expr_36)) /// @src 1:105:118 \"assert(x > 0)\" - assert_helper(expr_2) + assert_helper(expr_37) } } data \".metadata\" hex\"\" @@ -403,14 +403,14 @@ object \"B2_55\" { mstore(64, memoryguard(0x80)) if iszero(lt(calldatasize(), 4)) { - let selector := shift_right_unsigned(calldataload(0)) + let selector := shift_right_224_unsigned(calldataload(0)) switch selector - case 0xcd580ff3 { external_fun_b() } + case 0xcd580ff3 { external_fun_b_54() } default { } } revert_error_42b3090547df1d2001c96683413b8cf91c1b902ef5e3cb8d9f6f304cf7446f74() } - function shift_right_unsigned(value) -> newValue + function shift_right_224_unsigned(value) -> newValue { newValue := shr(224, value) } function allocate_unbounded() -> memPtr { memPtr := mload(64) } @@ -418,49 +418,49 @@ object \"B2_55\" { { revert(0, 0) } function revert_error_dbdddcbe895c83990c08b3492a0e83918d802a52331272ac6fdb6a7c4aea3b1b() { revert(0, 0) } - function cleanup_uint256(value) -> cleaned - { cleaned := value } - function validator_revert_uint256(value) + function cleanup_t_uint256(value_1) -> cleaned + { cleaned := value_1 } + function validator_revert_t_uint256(value_2) { - if iszero(eq(value, cleanup_uint256(value))) { revert(0, 0) } + if iszero(eq(value_2, cleanup_t_uint256(value_2))) { revert(0, 0) } } - function abi_decode_uint256(offset, end) -> value + function abi_decode_t_uint256(offset, end) -> value_3 { - value := calldataload(offset) - validator_revert_uint256(value) + value_3 := calldataload(offset) + validator_revert_t_uint256(value_3) } - function abi_decode_tuple_uint256(headStart, dataEnd) -> value0 + function abi_decode_tuple_t_uint256(headStart, dataEnd) -> value0 { if slt(sub(dataEnd, headStart), 32) { revert_error_dbdddcbe895c83990c08b3492a0e83918d802a52331272ac6fdb6a7c4aea3b1b() } - let offset := 0 - value0 := abi_decode_uint256(add(headStart, offset), dataEnd) + let offset_1 := 0 + value0 := abi_decode_t_uint256(add(headStart, offset_1), dataEnd) } - function abi_encode_tuple(headStart) -> tail - { tail := add(headStart, 0) } - function external_fun_b() + function abi_encode_tuple__to__fromStack(headStart_1) -> tail + { tail := add(headStart_1, 0) } + function external_fun_b_54() { if callvalue() { revert_error_ca66f745a3ce8ff40e2ccaf1ad45db7774001b90d25810abd9040049be7bf4bb() } - let param := abi_decode_tuple_uint256(4, calldatasize()) - fun_b(param) + let param_0 := abi_decode_tuple_t_uint256(4, calldatasize()) + fun_b_54(param_0) let memPos := allocate_unbounded() - let memEnd := abi_encode_tuple(memPos) + let memEnd := abi_encode_tuple__to__fromStack(memPos) return(memPos, sub(memEnd, memPos)) } function revert_error_42b3090547df1d2001c96683413b8cf91c1b902ef5e3cb8d9f6f304cf7446f74() { revert(0, 0) } - function cleanup_rational_by(value) -> cleaned - { cleaned := value } - function identity(value) -> ret - { ret := value } - function convert_rational_by_to_uint256(value) -> converted + function cleanup_t_rational_0_by_1(value_4) -> cleaned_1 + { cleaned_1 := value_4 } + function identity(value_5) -> ret + { ret := value_5 } + function convert_t_rational_0_by_1_to_t_uint256(value_6) -> converted { - converted := cleanup_uint256(identity(cleanup_rational_by(value))) + converted := cleanup_t_uint256(identity(cleanup_t_rational_0_by_1(value_6))) } function panic_error_0x01() { @@ -473,17 +473,17 @@ object \"B2_55\" { if iszero(condition) { panic_error_0x01() } } /// @ast-id 54 @src 1:138:187 \"function b(uint x) public pure { assert(x > 0); }\" - function fun_b(var_x) + function fun_b_54(var_x_44) { /// @src 1:178:179 \"x\" - let _1 := var_x - let expr := _1 + let _1 := var_x_44 + let expr_48 := _1 /// @src 1:182:183 \"0\" - let expr_1 := 0x00 + let expr_49 := 0x00 /// @src 1:178:183 \"x > 0\" - let expr_2 := gt(cleanup_uint256(expr), convert_rational_by_to_uint256(expr_1)) + let expr_50 := gt(cleanup_t_uint256(expr_48), convert_t_rational_0_by_1_to_t_uint256(expr_49)) /// @src 1:171:184 \"assert(x > 0)\" - assert_helper(expr_2) + assert_helper(expr_50) } } data \".metadata\" hex\"\" diff --git a/test/cmdlineTests/standard_output_selection_ethdebug_iroptimized/output.json b/test/cmdlineTests/standard_output_selection_ethdebug_iroptimized/output.json index eab40879c4c5..0f277bbaaf86 100644 --- a/test/cmdlineTests/standard_output_selection_ethdebug_iroptimized/output.json +++ b/test/cmdlineTests/standard_output_selection_ethdebug_iroptimized/output.json @@ -35,14 +35,14 @@ object \"A1_14\" { mstore(64, memoryguard(0x80)) if iszero(lt(calldatasize(), 4)) { - let selector := shift_right_unsigned(calldataload(0)) + let selector := shift_right_224_unsigned(calldataload(0)) switch selector - case 0xf0fdf834 { external_fun_a() } + case 0xf0fdf834 { external_fun_a_13() } default { } } revert_error_42b3090547df1d2001c96683413b8cf91c1b902ef5e3cb8d9f6f304cf7446f74() } - function shift_right_unsigned(value) -> newValue + function shift_right_224_unsigned(value) -> newValue { newValue := shr(224, value) } function allocate_unbounded() -> memPtr { memPtr := mload(64) } @@ -50,49 +50,49 @@ object \"A1_14\" { { revert(0, 0) } function revert_error_dbdddcbe895c83990c08b3492a0e83918d802a52331272ac6fdb6a7c4aea3b1b() { revert(0, 0) } - function cleanup_uint256(value) -> cleaned - { cleaned := value } - function validator_revert_uint256(value) + function cleanup_t_uint256(value_1) -> cleaned + { cleaned := value_1 } + function validator_revert_t_uint256(value_2) { - if iszero(eq(value, cleanup_uint256(value))) { revert(0, 0) } + if iszero(eq(value_2, cleanup_t_uint256(value_2))) { revert(0, 0) } } - function abi_decode_uint256(offset, end) -> value + function abi_decode_t_uint256(offset, end) -> value_3 { - value := calldataload(offset) - validator_revert_uint256(value) + value_3 := calldataload(offset) + validator_revert_t_uint256(value_3) } - function abi_decode_tuple_uint256(headStart, dataEnd) -> value0 + function abi_decode_tuple_t_uint256(headStart, dataEnd) -> value0 { if slt(sub(dataEnd, headStart), 32) { revert_error_dbdddcbe895c83990c08b3492a0e83918d802a52331272ac6fdb6a7c4aea3b1b() } - let offset := 0 - value0 := abi_decode_uint256(add(headStart, offset), dataEnd) + let offset_1 := 0 + value0 := abi_decode_t_uint256(add(headStart, offset_1), dataEnd) } - function abi_encode_tuple(headStart) -> tail - { tail := add(headStart, 0) } - function external_fun_a() + function abi_encode_tuple__to__fromStack(headStart_1) -> tail + { tail := add(headStart_1, 0) } + function external_fun_a_13() { if callvalue() { revert_error_ca66f745a3ce8ff40e2ccaf1ad45db7774001b90d25810abd9040049be7bf4bb() } - let param := abi_decode_tuple_uint256(4, calldatasize()) - fun_a(param) + let param_0 := abi_decode_tuple_t_uint256(4, calldatasize()) + fun_a_13(param_0) let memPos := allocate_unbounded() - let memEnd := abi_encode_tuple(memPos) + let memEnd := abi_encode_tuple__to__fromStack(memPos) return(memPos, sub(memEnd, memPos)) } function revert_error_42b3090547df1d2001c96683413b8cf91c1b902ef5e3cb8d9f6f304cf7446f74() { revert(0, 0) } - function cleanup_rational_by(value) -> cleaned - { cleaned := value } - function identity(value) -> ret - { ret := value } - function convert_rational_by_to_uint256(value) -> converted + function cleanup_t_rational_0_by_1(value_4) -> cleaned_1 + { cleaned_1 := value_4 } + function identity(value_5) -> ret + { ret := value_5 } + function convert_t_rational_0_by_1_to_t_uint256(value_6) -> converted { - converted := cleanup_uint256(identity(cleanup_rational_by(value))) + converted := cleanup_t_uint256(identity(cleanup_t_rational_0_by_1(value_6))) } function panic_error_0x01() { @@ -105,17 +105,17 @@ object \"A1_14\" { if iszero(condition) { panic_error_0x01() } } /// @ast-id 13 @src 0:72:121 \"function a(uint x) public pure { assert(x > 0); }\" - function fun_a(var_x) + function fun_a_13(var_x_3) { /// @src 0:112:113 \"x\" - let _1 := var_x - let expr := _1 + let _1 := var_x_3 + let expr_7 := _1 /// @src 0:116:117 \"0\" - let expr_1 := 0x00 + let expr_8 := 0x00 /// @src 0:112:117 \"x > 0\" - let expr_2 := gt(cleanup_uint256(expr), convert_rational_by_to_uint256(expr_1)) + let expr_9 := gt(cleanup_t_uint256(expr_7), convert_t_rational_0_by_1_to_t_uint256(expr_8)) /// @src 0:105:118 \"assert(x > 0)\" - assert_helper(expr_2) + assert_helper(expr_9) } } data \".metadata\" hex\"\" @@ -157,14 +157,14 @@ object \"A2_27\" { mstore(64, memoryguard(0x80)) if iszero(lt(calldatasize(), 4)) { - let selector := shift_right_unsigned(calldataload(0)) + let selector := shift_right_224_unsigned(calldataload(0)) switch selector - case 0xf0fdf834 { external_fun_a() } + case 0xf0fdf834 { external_fun_a_26() } default { } } revert_error_42b3090547df1d2001c96683413b8cf91c1b902ef5e3cb8d9f6f304cf7446f74() } - function shift_right_unsigned(value) -> newValue + function shift_right_224_unsigned(value) -> newValue { newValue := shr(224, value) } function allocate_unbounded() -> memPtr { memPtr := mload(64) } @@ -172,49 +172,49 @@ object \"A2_27\" { { revert(0, 0) } function revert_error_dbdddcbe895c83990c08b3492a0e83918d802a52331272ac6fdb6a7c4aea3b1b() { revert(0, 0) } - function cleanup_uint256(value) -> cleaned - { cleaned := value } - function validator_revert_uint256(value) + function cleanup_t_uint256(value_1) -> cleaned + { cleaned := value_1 } + function validator_revert_t_uint256(value_2) { - if iszero(eq(value, cleanup_uint256(value))) { revert(0, 0) } + if iszero(eq(value_2, cleanup_t_uint256(value_2))) { revert(0, 0) } } - function abi_decode_uint256(offset, end) -> value + function abi_decode_t_uint256(offset, end) -> value_3 { - value := calldataload(offset) - validator_revert_uint256(value) + value_3 := calldataload(offset) + validator_revert_t_uint256(value_3) } - function abi_decode_tuple_uint256(headStart, dataEnd) -> value0 + function abi_decode_tuple_t_uint256(headStart, dataEnd) -> value0 { if slt(sub(dataEnd, headStart), 32) { revert_error_dbdddcbe895c83990c08b3492a0e83918d802a52331272ac6fdb6a7c4aea3b1b() } - let offset := 0 - value0 := abi_decode_uint256(add(headStart, offset), dataEnd) + let offset_1 := 0 + value0 := abi_decode_t_uint256(add(headStart, offset_1), dataEnd) } - function abi_encode_tuple(headStart) -> tail - { tail := add(headStart, 0) } - function external_fun_a() + function abi_encode_tuple__to__fromStack(headStart_1) -> tail + { tail := add(headStart_1, 0) } + function external_fun_a_26() { if callvalue() { revert_error_ca66f745a3ce8ff40e2ccaf1ad45db7774001b90d25810abd9040049be7bf4bb() } - let param := abi_decode_tuple_uint256(4, calldatasize()) - fun_a(param) + let param_0 := abi_decode_tuple_t_uint256(4, calldatasize()) + fun_a_26(param_0) let memPos := allocate_unbounded() - let memEnd := abi_encode_tuple(memPos) + let memEnd := abi_encode_tuple__to__fromStack(memPos) return(memPos, sub(memEnd, memPos)) } function revert_error_42b3090547df1d2001c96683413b8cf91c1b902ef5e3cb8d9f6f304cf7446f74() { revert(0, 0) } - function cleanup_rational_by(value) -> cleaned - { cleaned := value } - function identity(value) -> ret - { ret := value } - function convert_rational_by_to_uint256(value) -> converted + function cleanup_t_rational_0_by_1(value_4) -> cleaned_1 + { cleaned_1 := value_4 } + function identity(value_5) -> ret + { ret := value_5 } + function convert_t_rational_0_by_1_to_t_uint256(value_6) -> converted { - converted := cleanup_uint256(identity(cleanup_rational_by(value))) + converted := cleanup_t_uint256(identity(cleanup_t_rational_0_by_1(value_6))) } function panic_error_0x01() { @@ -227,17 +227,17 @@ object \"A2_27\" { if iszero(condition) { panic_error_0x01() } } /// @ast-id 26 @src 0:138:187 \"function a(uint x) public pure { assert(x > 0); }\" - function fun_a(var_x) + function fun_a_26(var_x_16) { /// @src 0:178:179 \"x\" - let _1 := var_x - let expr := _1 + let _1 := var_x_16 + let expr_20 := _1 /// @src 0:182:183 \"0\" - let expr_1 := 0x00 + let expr_21 := 0x00 /// @src 0:178:183 \"x > 0\" - let expr_2 := gt(cleanup_uint256(expr), convert_rational_by_to_uint256(expr_1)) + let expr_22 := gt(cleanup_t_uint256(expr_20), convert_t_rational_0_by_1_to_t_uint256(expr_21)) /// @src 0:171:184 \"assert(x > 0)\" - assert_helper(expr_2) + assert_helper(expr_22) } } data \".metadata\" hex\"\" @@ -281,14 +281,14 @@ object \"A1_42\" { mstore(64, memoryguard(0x80)) if iszero(lt(calldatasize(), 4)) { - let selector := shift_right_unsigned(calldataload(0)) + let selector := shift_right_224_unsigned(calldataload(0)) switch selector - case 0xcd580ff3 { external_fun_b() } + case 0xcd580ff3 { external_fun_b_41() } default { } } revert_error_42b3090547df1d2001c96683413b8cf91c1b902ef5e3cb8d9f6f304cf7446f74() } - function shift_right_unsigned(value) -> newValue + function shift_right_224_unsigned(value) -> newValue { newValue := shr(224, value) } function allocate_unbounded() -> memPtr { memPtr := mload(64) } @@ -296,49 +296,49 @@ object \"A1_42\" { { revert(0, 0) } function revert_error_dbdddcbe895c83990c08b3492a0e83918d802a52331272ac6fdb6a7c4aea3b1b() { revert(0, 0) } - function cleanup_uint256(value) -> cleaned - { cleaned := value } - function validator_revert_uint256(value) + function cleanup_t_uint256(value_1) -> cleaned + { cleaned := value_1 } + function validator_revert_t_uint256(value_2) { - if iszero(eq(value, cleanup_uint256(value))) { revert(0, 0) } + if iszero(eq(value_2, cleanup_t_uint256(value_2))) { revert(0, 0) } } - function abi_decode_uint256(offset, end) -> value + function abi_decode_t_uint256(offset, end) -> value_3 { - value := calldataload(offset) - validator_revert_uint256(value) + value_3 := calldataload(offset) + validator_revert_t_uint256(value_3) } - function abi_decode_tuple_uint256(headStart, dataEnd) -> value0 + function abi_decode_tuple_t_uint256(headStart, dataEnd) -> value0 { if slt(sub(dataEnd, headStart), 32) { revert_error_dbdddcbe895c83990c08b3492a0e83918d802a52331272ac6fdb6a7c4aea3b1b() } - let offset := 0 - value0 := abi_decode_uint256(add(headStart, offset), dataEnd) + let offset_1 := 0 + value0 := abi_decode_t_uint256(add(headStart, offset_1), dataEnd) } - function abi_encode_tuple(headStart) -> tail - { tail := add(headStart, 0) } - function external_fun_b() + function abi_encode_tuple__to__fromStack(headStart_1) -> tail + { tail := add(headStart_1, 0) } + function external_fun_b_41() { if callvalue() { revert_error_ca66f745a3ce8ff40e2ccaf1ad45db7774001b90d25810abd9040049be7bf4bb() } - let param := abi_decode_tuple_uint256(4, calldatasize()) - fun_b(param) + let param_0 := abi_decode_tuple_t_uint256(4, calldatasize()) + fun_b_41(param_0) let memPos := allocate_unbounded() - let memEnd := abi_encode_tuple(memPos) + let memEnd := abi_encode_tuple__to__fromStack(memPos) return(memPos, sub(memEnd, memPos)) } function revert_error_42b3090547df1d2001c96683413b8cf91c1b902ef5e3cb8d9f6f304cf7446f74() { revert(0, 0) } - function cleanup_rational_by(value) -> cleaned - { cleaned := value } - function identity(value) -> ret - { ret := value } - function convert_rational_by_to_uint256(value) -> converted + function cleanup_t_rational_0_by_1(value_4) -> cleaned_1 + { cleaned_1 := value_4 } + function identity(value_5) -> ret + { ret := value_5 } + function convert_t_rational_0_by_1_to_t_uint256(value_6) -> converted { - converted := cleanup_uint256(identity(cleanup_rational_by(value))) + converted := cleanup_t_uint256(identity(cleanup_t_rational_0_by_1(value_6))) } function panic_error_0x01() { @@ -351,17 +351,17 @@ object \"A1_42\" { if iszero(condition) { panic_error_0x01() } } /// @ast-id 41 @src 1:72:121 \"function b(uint x) public pure { assert(x > 0); }\" - function fun_b(var_x) + function fun_b_41(var_x_31) { /// @src 1:112:113 \"x\" - let _1 := var_x - let expr := _1 + let _1 := var_x_31 + let expr_35 := _1 /// @src 1:116:117 \"0\" - let expr_1 := 0x00 + let expr_36 := 0x00 /// @src 1:112:117 \"x > 0\" - let expr_2 := gt(cleanup_uint256(expr), convert_rational_by_to_uint256(expr_1)) + let expr_37 := gt(cleanup_t_uint256(expr_35), convert_t_rational_0_by_1_to_t_uint256(expr_36)) /// @src 1:105:118 \"assert(x > 0)\" - assert_helper(expr_2) + assert_helper(expr_37) } } data \".metadata\" hex\"\" @@ -403,14 +403,14 @@ object \"B2_55\" { mstore(64, memoryguard(0x80)) if iszero(lt(calldatasize(), 4)) { - let selector := shift_right_unsigned(calldataload(0)) + let selector := shift_right_224_unsigned(calldataload(0)) switch selector - case 0xcd580ff3 { external_fun_b() } + case 0xcd580ff3 { external_fun_b_54() } default { } } revert_error_42b3090547df1d2001c96683413b8cf91c1b902ef5e3cb8d9f6f304cf7446f74() } - function shift_right_unsigned(value) -> newValue + function shift_right_224_unsigned(value) -> newValue { newValue := shr(224, value) } function allocate_unbounded() -> memPtr { memPtr := mload(64) } @@ -418,49 +418,49 @@ object \"B2_55\" { { revert(0, 0) } function revert_error_dbdddcbe895c83990c08b3492a0e83918d802a52331272ac6fdb6a7c4aea3b1b() { revert(0, 0) } - function cleanup_uint256(value) -> cleaned - { cleaned := value } - function validator_revert_uint256(value) + function cleanup_t_uint256(value_1) -> cleaned + { cleaned := value_1 } + function validator_revert_t_uint256(value_2) { - if iszero(eq(value, cleanup_uint256(value))) { revert(0, 0) } + if iszero(eq(value_2, cleanup_t_uint256(value_2))) { revert(0, 0) } } - function abi_decode_uint256(offset, end) -> value + function abi_decode_t_uint256(offset, end) -> value_3 { - value := calldataload(offset) - validator_revert_uint256(value) + value_3 := calldataload(offset) + validator_revert_t_uint256(value_3) } - function abi_decode_tuple_uint256(headStart, dataEnd) -> value0 + function abi_decode_tuple_t_uint256(headStart, dataEnd) -> value0 { if slt(sub(dataEnd, headStart), 32) { revert_error_dbdddcbe895c83990c08b3492a0e83918d802a52331272ac6fdb6a7c4aea3b1b() } - let offset := 0 - value0 := abi_decode_uint256(add(headStart, offset), dataEnd) + let offset_1 := 0 + value0 := abi_decode_t_uint256(add(headStart, offset_1), dataEnd) } - function abi_encode_tuple(headStart) -> tail - { tail := add(headStart, 0) } - function external_fun_b() + function abi_encode_tuple__to__fromStack(headStart_1) -> tail + { tail := add(headStart_1, 0) } + function external_fun_b_54() { if callvalue() { revert_error_ca66f745a3ce8ff40e2ccaf1ad45db7774001b90d25810abd9040049be7bf4bb() } - let param := abi_decode_tuple_uint256(4, calldatasize()) - fun_b(param) + let param_0 := abi_decode_tuple_t_uint256(4, calldatasize()) + fun_b_54(param_0) let memPos := allocate_unbounded() - let memEnd := abi_encode_tuple(memPos) + let memEnd := abi_encode_tuple__to__fromStack(memPos) return(memPos, sub(memEnd, memPos)) } function revert_error_42b3090547df1d2001c96683413b8cf91c1b902ef5e3cb8d9f6f304cf7446f74() { revert(0, 0) } - function cleanup_rational_by(value) -> cleaned - { cleaned := value } - function identity(value) -> ret - { ret := value } - function convert_rational_by_to_uint256(value) -> converted + function cleanup_t_rational_0_by_1(value_4) -> cleaned_1 + { cleaned_1 := value_4 } + function identity(value_5) -> ret + { ret := value_5 } + function convert_t_rational_0_by_1_to_t_uint256(value_6) -> converted { - converted := cleanup_uint256(identity(cleanup_rational_by(value))) + converted := cleanup_t_uint256(identity(cleanup_t_rational_0_by_1(value_6))) } function panic_error_0x01() { @@ -473,17 +473,17 @@ object \"B2_55\" { if iszero(condition) { panic_error_0x01() } } /// @ast-id 54 @src 1:138:187 \"function b(uint x) public pure { assert(x > 0); }\" - function fun_b(var_x) + function fun_b_54(var_x_44) { /// @src 1:178:179 \"x\" - let _1 := var_x - let expr := _1 + let _1 := var_x_44 + let expr_48 := _1 /// @src 1:182:183 \"0\" - let expr_1 := 0x00 + let expr_49 := 0x00 /// @src 1:178:183 \"x > 0\" - let expr_2 := gt(cleanup_uint256(expr), convert_rational_by_to_uint256(expr_1)) + let expr_50 := gt(cleanup_t_uint256(expr_48), convert_t_rational_0_by_1_to_t_uint256(expr_49)) /// @src 1:171:184 \"assert(x > 0)\" - assert_helper(expr_2) + assert_helper(expr_50) } } data \".metadata\" hex\"\" diff --git a/test/cmdlineTests/standard_output_selection_multiple_matching_source_and_contract_selectors_full_pipeline/output.json b/test/cmdlineTests/standard_output_selection_multiple_matching_source_and_contract_selectors_full_pipeline/output.json index 3ff2b451e23d..f0c2053939de 100644 --- a/test/cmdlineTests/standard_output_selection_multiple_matching_source_and_contract_selectors_full_pipeline/output.json +++ b/test/cmdlineTests/standard_output_selection_multiple_matching_source_and_contract_selectors_full_pipeline/output.json @@ -70,12 +70,12 @@ object \"A_1\" { object \"A_1\" { code { { - let _1 := memoryguard(0x80) - mstore(64, _1) + let _2 := memoryguard(0x80) + mstore(64, _2) if callvalue() { revert(0, 0) } - let _2 := datasize(\"A_1_deployed\") - codecopy(_1, dataoffset(\"A_1_deployed\"), _2) - return(_1, _2) + let _1 := datasize(\"A_1_deployed\") + codecopy(_2, dataoffset(\"A_1_deployed\"), _1) + return(_2, _1) } } /// @use-src 0:\"C\" @@ -105,12 +105,12 @@ object \"A_1\" { object \"A_5\" { code { { - let _1 := memoryguard(0x80) - mstore(64, _1) + let _2 := memoryguard(0x80) + mstore(64, _2) if callvalue() { revert(0, 0) } - let _2 := datasize(\"A_5_deployed\") - codecopy(_1, dataoffset(\"A_5_deployed\"), _2) - return(_1, _2) + let _1 := datasize(\"A_5_deployed\") + codecopy(_2, dataoffset(\"A_5_deployed\"), _1) + return(_2, _1) } } /// @use-src 1:\"D\" diff --git a/test/cmdlineTests/standard_stack_too_deep_from_code_transform/output.json b/test/cmdlineTests/standard_stack_too_deep_from_code_transform/output.json index b4b0139fee69..d1005f9237cb 100644 --- a/test/cmdlineTests/standard_stack_too_deep_from_code_transform/output.json +++ b/test/cmdlineTests/standard_stack_too_deep_from_code_transform/output.json @@ -2,7 +2,7 @@ "errors": [ { "component": "general", - "formattedMessage": "YulException: Cannot swap Variable value23 with Slot 0x20: too deep in the stack by 9 slots in [ RET value23 value22 value21 value20 value19 value18 value17 value16 value15 value14 value13 value12 value11 value10 value9 value8 value7 value6 value5 value4 value3 value2 value1 value0 pos 0x20 ] + "formattedMessage": "YulException: Cannot swap Variable value23 with Slot 0x20: too deep in the stack by 9 slots in [ RET value23 value22 value21 value20 value19 value18 value17 value16 value15 value14 value13 value12 value11 value10 value9 value8 value7 value6 value5 value4 value3 value2 value1 value0 pos_1 0x20 ] memoryguard was present. --> in.sol:1:1: | @@ -10,7 +10,7 @@ memoryguard was present. | ^ (Relevant source part starts here and spans across multiple lines). ", - "message": "Cannot swap Variable value23 with Slot 0x20: too deep in the stack by 9 slots in [ RET value23 value22 value21 value20 value19 value18 value17 value16 value15 value14 value13 value12 value11 value10 value9 value8 value7 value6 value5 value4 value3 value2 value1 value0 pos 0x20 ] + "message": "Cannot swap Variable value23 with Slot 0x20: too deep in the stack by 9 slots in [ RET value23 value22 value21 value20 value19 value18 value17 value16 value15 value14 value13 value12 value11 value10 value9 value8 value7 value6 value5 value4 value3 value2 value1 value0 pos_1 0x20 ] memoryguard was present.", "severity": "error", "sourceLocation": { diff --git a/test/cmdlineTests/standard_yul_debug_info_ethdebug_compatible_output/output.json b/test/cmdlineTests/standard_yul_debug_info_ethdebug_compatible_output/output.json index 2b2f395fadd4..2a7dfabab4d8 100644 --- a/test/cmdlineTests/standard_yul_debug_info_ethdebug_compatible_output/output.json +++ b/test/cmdlineTests/standard_yul_debug_info_ethdebug_compatible_output/output.json @@ -27,10 +27,10 @@ object \"C_6_deployed\" { { /// @src 0:60:101 mstore(64, 128) - fun_f() + fun_f_5() } /// @src 0:77:99 - function fun_f() + function fun_f_5() { sstore(0, 42) } } } diff --git a/test/cmdlineTests/standard_yul_ethdebug_bytecode_iroptimized/output.json b/test/cmdlineTests/standard_yul_ethdebug_bytecode_iroptimized/output.json index 2f1d22b4df0f..e4ab9c018883 100644 --- a/test/cmdlineTests/standard_yul_ethdebug_bytecode_iroptimized/output.json +++ b/test/cmdlineTests/standard_yul_ethdebug_bytecode_iroptimized/output.json @@ -14,10 +14,10 @@ object \"C_6_deployed\" { { /// @src 0:60:101 mstore(64, 128) - fun_f() + fun_f_5() } /// @src 0:77:99 - function fun_f() + function fun_f_5() { sstore(0, 42) } } } diff --git a/test/cmdlineTests/storage_layout_specifier_smoke_ir_codegen/output b/test/cmdlineTests/storage_layout_specifier_smoke_ir_codegen/output index de5fd53748d4..b8bef7620f0c 100644 --- a/test/cmdlineTests/storage_layout_specifier_smoke_ir_codegen/output +++ b/test/cmdlineTests/storage_layout_specifier_smoke_ir_codegen/output @@ -3,13 +3,13 @@ Optimized IR: object "C_7" { code { { - let _1 := memoryguard(0x80) - mstore(64, _1) + let _2 := memoryguard(0x80) + mstore(64, _2) if callvalue() { revert(0, 0) } sstore(0x2a, 0x0a) - let _2 := datasize("C_7_deployed") - codecopy(_1, dataoffset("C_7_deployed"), _2) - return(_1, _2) + let _1 := datasize("C_7_deployed") + codecopy(_2, dataoffset("C_7_deployed"), _1) + return(_2, _1) } } /// @use-src 0:"" diff --git a/test/cmdlineTests/strict_asm_debug_info_print_all/output b/test/cmdlineTests/strict_asm_debug_info_print_all/output index ea8afb6a2f06..0137cbf8dea1 100644 --- a/test/cmdlineTests/strict_asm_debug_info_print_all/output +++ b/test/cmdlineTests/strict_asm_debug_info_print_all/output @@ -8,10 +8,10 @@ object "C_6_deployed" { { /// @src 0:60:101 mstore(64, 128) - fun_f() + fun_f_5() } /// @src 0:77:99 - function fun_f() + function fun_f_5() { sstore(0, 42) } } } diff --git a/test/cmdlineTests/strict_asm_debug_info_print_location_only/output b/test/cmdlineTests/strict_asm_debug_info_print_location_only/output index 06448d25ab42..4cb77be25cf7 100644 --- a/test/cmdlineTests/strict_asm_debug_info_print_location_only/output +++ b/test/cmdlineTests/strict_asm_debug_info_print_location_only/output @@ -8,10 +8,10 @@ object "C_6_deployed" { { /// @src 0:60:101 mstore(64, 128) - fun_f() + fun_f_5() } /// @src 0:77:99 - function fun_f() + function fun_f_5() { sstore(0, 42) } } } diff --git a/test/cmdlineTests/strict_asm_debug_info_print_none/output b/test/cmdlineTests/strict_asm_debug_info_print_none/output index 93fc5c73e53b..156b6694d3bc 100644 --- a/test/cmdlineTests/strict_asm_debug_info_print_none/output +++ b/test/cmdlineTests/strict_asm_debug_info_print_none/output @@ -7,9 +7,9 @@ object "C_6_deployed" { code { { mstore(64, 128) - fun_f() + fun_f_5() } - function fun_f() + function fun_f_5() { sstore(0, 42) } } } diff --git a/test/cmdlineTests/viair_subobjects/output b/test/cmdlineTests/viair_subobjects/output index 783756e67681..bc314f6df13e 100644 --- a/test/cmdlineTests/viair_subobjects/output +++ b/test/cmdlineTests/viair_subobjects/output @@ -10,12 +10,12 @@ object "C_3" { code { { /// @src 0:82:95 "contract C {}" - let _1 := memoryguard(0x80) - mstore(64, _1) + let _2 := memoryguard(0x80) + mstore(64, _2) if callvalue() { revert(0, 0) } - let _2 := datasize("C_3_deployed") - codecopy(_1, dataoffset("C_3_deployed"), _2) - return(_1, _2) + let _1 := datasize("C_3_deployed") + codecopy(_2, dataoffset("C_3_deployed"), _1) + return(_2, _1) } } /// @use-src 0:"input.sol" @@ -42,12 +42,12 @@ object "D_16" { code { { /// @src 0:96:165 "contract D {..." - let _1 := memoryguard(0x80) - mstore(64, _1) + let _2 := memoryguard(0x80) + mstore(64, _2) if callvalue() { revert(0, 0) } - let _2 := datasize("D_16_deployed") - codecopy(_1, dataoffset("D_16_deployed"), _2) - return(_1, _2) + let _1 := datasize("D_16_deployed") + codecopy(_2, dataoffset("D_16_deployed"), _1) + return(_2, _1) } } /// @use-src 0:"input.sol" @@ -64,9 +64,9 @@ object "D_16" { if callvalue() { revert(0, 0) } if slt(add(calldatasize(), not(3)), 0) { revert(0, 0) } /// @src 0:149:156 "new C()" - let _2 := datasize("C_3") - let _3 := add(_1, _2) - if or(gt(_3, 0xffffffffffffffff), lt(_3, _1)) + let _3 := datasize("C_3") + let _2 := add(_1, _3) + if or(gt(_2, 0xffffffffffffffff), lt(_2, _1)) { /// @src 0:96:165 "contract D {..." mstore(0, shl(224, 0x4e487b71)) @@ -74,8 +74,8 @@ object "D_16" { revert(0, 0x24) } /// @src 0:149:156 "new C()" - datacopy(_1, dataoffset("C_3"), _2) - if iszero(create(/** @src 0:96:165 "contract D {..." */ 0, /** @src 0:149:156 "new C()" */ _1, sub(_3, _1))) + datacopy(_1, dataoffset("C_3"), _3) + if iszero(create(/** @src 0:96:165 "contract D {..." */ 0, /** @src 0:149:156 "new C()" */ _1, sub(_2, _1))) { /// @src 0:96:165 "contract D {..." let pos := mload(64) @@ -93,12 +93,12 @@ object "D_16" { code { { /// @src 0:82:95 "contract C {}" - let _1 := memoryguard(0x80) - mstore(64, _1) + let _2 := memoryguard(0x80) + mstore(64, _2) if callvalue() { revert(0, 0) } - let _2 := datasize("C_3_deployed") - codecopy(_1, dataoffset("C_3_deployed"), _2) - return(_1, _2) + let _1 := datasize("C_3_deployed") + codecopy(_2, dataoffset("C_3_deployed"), _1) + return(_2, _1) } } /// @use-src 0:"input.sol" diff --git a/test/cmdlineTests/yul_function_name_clashes/output b/test/cmdlineTests/yul_function_name_clashes/output index 1d319d284e5b..61c1cfa1c99a 100644 --- a/test/cmdlineTests/yul_function_name_clashes/output +++ b/test/cmdlineTests/yul_function_name_clashes/output @@ -13,8 +13,8 @@ object "object" { } function z() -> y { y := calldataload(0) } - function z_1() -> y - { y := calldataload(0x20) } + function z_1() -> y_1 + { y_1 := calldataload(0x20) } } } diff --git a/test/cmdlineTests/yul_function_name_clashes_different_params/output b/test/cmdlineTests/yul_function_name_clashes_different_params/output index fdffb0c31270..416107475fc3 100644 --- a/test/cmdlineTests/yul_function_name_clashes_different_params/output +++ b/test/cmdlineTests/yul_function_name_clashes_different_params/output @@ -13,8 +13,8 @@ object "object" { } function z() -> y { y := calldataload(0) } - function z_1(r) -> y - { y := calldataload(r) } + function z_1(r) -> y_1 + { y_1 := calldataload(r) } } } @@ -39,7 +39,7 @@ tag_4: /* "input.yul":135:147 */ swap1 sstore - /* "input.yul":27:284 */ + /* "input.yul":27:288 */ stop /* "input.yul":166:216 */ tag_1: @@ -50,10 +50,10 @@ tag_1: /* "input.yul":166:216 */ swap1 jump // out - /* "input.yul":225:278 */ + /* "input.yul":225:282 */ tag_2: - /* "input.yul":261:276 */ + /* "input.yul":265:280 */ calldataload - /* "input.yul":225:278 */ + /* "input.yul":225:282 */ swap1 jump // out diff --git a/test/cmdlineTests/yul_optimizer_steps_nested_brackets/output b/test/cmdlineTests/yul_optimizer_steps_nested_brackets/output index 26be9469862a..f53d44836dc4 100644 --- a/test/cmdlineTests/yul_optimizer_steps_nested_brackets/output +++ b/test/cmdlineTests/yul_optimizer_steps_nested_brackets/output @@ -29,12 +29,12 @@ object "C_6" { mstore(64, memoryguard(0x80)) if iszero(lt(calldatasize(), 4)) { - let selector := shift_right_unsigned(calldataload(0)) - if eq(0x26121ff0, selector) { external_fun_f() } + let selector := shift_right_224_unsigned(calldataload(0)) + if eq(0x26121ff0, selector) { external_fun_f_5() } } revert_error_42b3090547df1d2001c96683413b8cf91c1b902ef5e3cb8d9f6f304cf7446f74() } - function shift_right_unsigned(value) -> newValue + function shift_right_224_unsigned(value) -> newValue { let newValue_1 := shr(224, value) newValue := newValue_1 @@ -48,27 +48,27 @@ object "C_6" { { revert(0, 0) } function revert_error_dbdddcbe895c83990c08b3492a0e83918d802a52331272ac6fdb6a7c4aea3b1b() { revert(0, 0) } - function abi_decode(headStart, dataEnd) + function abi_decode_tuple_(headStart, dataEnd) { if slt(sub(dataEnd, headStart), 0) { revert_error_dbdddcbe895c83990c08b3492a0e83918d802a52331272ac6fdb6a7c4aea3b1b() } } - function abi_encode_tuple(headStart) -> tail + function abi_encode_tuple__to__fromStack(headStart_1) -> tail { - let tail_1 := add(headStart, 0) + let tail_1 := add(headStart_1, 0) tail := tail_1 } - function external_fun_f() + function external_fun_f_5() { if callvalue() { revert_error_ca66f745a3ce8ff40e2ccaf1ad45db7774001b90d25810abd9040049be7bf4bb() } - abi_decode(4, calldatasize()) + abi_decode_tuple_(4, calldatasize()) let memPos := allocate_unbounded() - let memEnd := abi_encode_tuple(memPos) + let memEnd := abi_encode_tuple__to__fromStack(memPos) return(memPos, sub(memEnd, memPos)) } function revert_error_42b3090547df1d2001c96683413b8cf91c1b902ef5e3cb8d9f6f304cf7446f74() diff --git a/test/cmdlineTests/yul_optimizer_steps_without_optimize_empty_sequence/output b/test/cmdlineTests/yul_optimizer_steps_without_optimize_empty_sequence/output index a7b037775f2c..8a3b9eace993 100644 --- a/test/cmdlineTests/yul_optimizer_steps_without_optimize_empty_sequence/output +++ b/test/cmdlineTests/yul_optimizer_steps_without_optimize_empty_sequence/output @@ -11,7 +11,7 @@ object "C_28" { { revert_error_ca66f745a3ce8ff40e2ccaf1ad45db7774001b90d25810abd9040049be7bf4bb() } - constructor_C() + constructor_C_28() let _1 := allocate_unbounded() codecopy(_1, dataoffset("C_28_deployed"), datasize("C_28_deployed")) return(_1, datasize("C_28_deployed")) @@ -21,7 +21,7 @@ object "C_28" { function revert_error_ca66f745a3ce8ff40e2ccaf1ad45db7774001b90d25810abd9040049be7bf4bb() { revert(0, 0) } /// @ast-id 5 @src 0:77:93 "constructor() {}" - function constructor_C() + function constructor_C_28() { } } /// @use-src 0:"input.sol" @@ -32,14 +32,14 @@ object "C_28" { mstore(64, memoryguard(0x80)) if iszero(lt(calldatasize(), 4)) { - let selector := shift_right_unsigned(calldataload(0)) + let selector := shift_right_224_unsigned(calldataload(0)) switch selector - case 0xc2985578 { external_fun_foo() } + case 0xc2985578 { external_fun_foo_27() } default { } } revert_error_42b3090547df1d2001c96683413b8cf91c1b902ef5e3cb8d9f6f304cf7446f74() } - function shift_right_unsigned(value) -> newValue + function shift_right_224_unsigned(value) -> newValue { newValue := shr(224, value) } function allocate_unbounded() -> memPtr { memPtr := mload(64) } @@ -47,81 +47,81 @@ object "C_28" { { revert(0, 0) } function revert_error_dbdddcbe895c83990c08b3492a0e83918d802a52331272ac6fdb6a7c4aea3b1b() { revert(0, 0) } - function abi_decode(headStart, dataEnd) + function abi_decode_tuple_(headStart, dataEnd) { if slt(sub(dataEnd, headStart), 0) { revert_error_dbdddcbe895c83990c08b3492a0e83918d802a52331272ac6fdb6a7c4aea3b1b() } } - function cleanup_bool(value) -> cleaned + function cleanup_t_bool(value_1) -> cleaned { - cleaned := iszero(iszero(value)) + cleaned := iszero(iszero(value_1)) } - function abi_encode_bool_to_bool(value, pos) + function abi_encode_t_bool_to_t_bool_fromStack(value_2, pos) { - mstore(pos, cleanup_bool(value)) + mstore(pos, cleanup_t_bool(value_2)) } - function abi_encode_bool(headStart, value0) -> tail + function abi_encode_tuple_t_bool__to_t_bool__fromStack(headStart_1, value0) -> tail { - tail := add(headStart, 32) - abi_encode_bool_to_bool(value0, add(headStart, 0)) + tail := add(headStart_1, 32) + abi_encode_t_bool_to_t_bool_fromStack(value0, add(headStart_1, 0)) } - function external_fun_foo() + function external_fun_foo_27() { if callvalue() { revert_error_ca66f745a3ce8ff40e2ccaf1ad45db7774001b90d25810abd9040049be7bf4bb() } - abi_decode(4, calldatasize()) - let ret := fun_foo() + abi_decode_tuple_(4, calldatasize()) + let ret_0 := fun_foo_27() let memPos := allocate_unbounded() - let memEnd := abi_encode_bool(memPos, ret) + let memEnd := abi_encode_tuple_t_bool__to_t_bool__fromStack(memPos, ret_0) return(memPos, sub(memEnd, memPos)) } function revert_error_42b3090547df1d2001c96683413b8cf91c1b902ef5e3cb8d9f6f304cf7446f74() { revert(0, 0) } - function zero_value_for_split_bool() -> ret + function zero_value_for_split_t_bool() -> ret { ret := 0 } - function cleanup_rational_by(value) -> cleaned - { cleaned := value } - function cleanup_uint256(value) -> cleaned - { cleaned := value } - function identity(value) -> ret - { ret := value } - function convert_rational_by_to_uint256(value) -> converted + function cleanup_t_rational_100_by_1(value_3) -> cleaned_1 + { cleaned_1 := value_3 } + function cleanup_t_uint256(value_4) -> cleaned_2 + { cleaned_2 := value_4 } + function identity(value_5) -> ret_1 + { ret_1 := value_5 } + function convert_t_rational_100_by_1_to_t_uint256(value_6) -> converted { - converted := cleanup_uint256(identity(cleanup_rational_by(value))) + converted := cleanup_t_uint256(identity(cleanup_t_rational_100_by_1(value_6))) } /// @ast-id 27 @src 0:99:408 "function foo() public pure returns (bool)..." - function fun_foo() -> var + function fun_foo_27() -> var__8 { /// @src 0:135:139 "bool" - let zero_bool := zero_value_for_split_bool() - var := zero_bool + let zero_t_bool_1 := zero_value_for_split_t_bool() + var__8 := zero_t_bool_1 /// @src 0:332:335 "100" - let expr := 0x64 + let expr_12 := 0x64 /// @src 0:323:335 "uint a = 100" - let var_a := convert_rational_by_to_uint256(expr) + let var_a_11 := convert_t_rational_100_by_1_to_t_uint256(expr_12) /// @src 0:354:355 "a" - let _1 := var_a - let expr_1 := _1 + let _2 := var_a_11 + let expr_16 := _2 /// @src 0:345:355 "uint b = a" - let var_b := expr_1 + let var_b_15 := expr_16 /// @src 0:374:375 "a" - let _2 := var_a - let expr_2 := _2 + let _3 := var_a_11 + let expr_20 := _3 /// @src 0:365:375 "uint c = a" - let var_c := expr_2 + let var_c_19 := expr_20 /// @src 0:393:394 "a" - let _3 := var_a - let expr_3 := _3 + let _4 := var_a_11 + let expr_22 := _4 /// @src 0:398:401 "100" - let expr_4 := 0x64 + let expr_23 := 0x64 /// @src 0:393:401 "a == 100" - let expr_5 := eq(cleanup_uint256(expr_3), convert_rational_by_to_uint256(expr_4)) + let expr_24 := eq(cleanup_t_uint256(expr_22), convert_t_rational_100_by_1_to_t_uint256(expr_23)) /// @src 0:386:401 "return a == 100" - var := expr_5 + var__8 := expr_24 leave } } diff --git a/test/libsolidity/semanticTests/array/copying/array_of_function_external_storage_to_storage_dynamic.sol b/test/libsolidity/semanticTests/array/copying/array_of_function_external_storage_to_storage_dynamic.sol index ab3c172d3399..10f7ec17922f 100644 --- a/test/libsolidity/semanticTests/array/copying/array_of_function_external_storage_to_storage_dynamic.sol +++ b/test/libsolidity/semanticTests/array/copying/array_of_function_external_storage_to_storage_dynamic.sol @@ -45,7 +45,7 @@ contract C { } // ---- // copyExternalStorageArrayOfFunctionType() -> true -// gas irOptimized: 104566 +// gas irOptimized: 104629 // gas legacy: 108554 // gas legacyOptimized: 102405 // copyInternalArrayOfFunctionType() -> true diff --git a/test/libyul/yulControlFlowGraph/complex.yul b/test/libyul/yulControlFlowGraph/complex.yul index 718ea6770979..d5a7bdf67057 100644 --- a/test/libyul/yulControlFlowGraph/complex.yul +++ b/test/libyul/yulControlFlowGraph/complex.yul @@ -84,8 +84,8 @@ // // Block4 [label="\ // mload: [ x ] => [ TMP[mload, 0] ]\l\ -// Assignment(GHOST[0]): [ TMP[mload, 0] ] => [ GHOST[0] ]\l\ -// eq: [ GHOST[0] 0x00 ] => [ TMP[eq, 0] ]\l\ +// Assignment(GHOST[7]): [ TMP[mload, 0] ] => [ GHOST[7] ]\l\ +// eq: [ GHOST[7] 0x00 ] => [ TMP[eq, 0] ]\l\ // "]; // Block4 -> Block4Exit; // Block4Exit [label="{ TMP[eq, 0]| { <0> Zero | <1> NonZero }}" shape=Mrecord]; @@ -93,7 +93,7 @@ // Block4Exit:1 -> Block6; // // Block5 [label="\ -// eq: [ GHOST[0] 0x01 ] => [ TMP[eq, 0] ]\l\ +// eq: [ GHOST[7] 0x01 ] => [ TMP[eq, 0] ]\l\ // "]; // Block5 -> Block5Exit; // Block5Exit [label="{ TMP[eq, 0]| { <0> Zero | <1> NonZero }}" shape=Mrecord]; @@ -108,7 +108,7 @@ // Block6Exit -> Block3; // // Block7 [label="\ -// eq: [ GHOST[0] 0x02 ] => [ TMP[eq, 0] ]\l\ +// eq: [ GHOST[7] 0x02 ] => [ TMP[eq, 0] ]\l\ // "]; // Block7 -> Block7Exit; // Block7Exit [label="{ TMP[eq, 0]| { <0> Zero | <1> NonZero }}" shape=Mrecord]; @@ -122,7 +122,7 @@ // Block8 -> Block8Exit; // // Block9 [label="\ -// eq: [ GHOST[0] 0x03 ] => [ TMP[eq, 0] ]\l\ +// eq: [ GHOST[7] 0x03 ] => [ TMP[eq, 0] ]\l\ // "]; // Block9 -> Block9Exit; // Block9Exit [label="{ TMP[eq, 0]| { <0> Zero | <1> NonZero }}" shape=Mrecord]; diff --git a/test/libyul/yulControlFlowGraph/switch.yul b/test/libyul/yulControlFlowGraph/switch.yul index 2d6751d8a890..0448b899d511 100644 --- a/test/libyul/yulControlFlowGraph/switch.yul +++ b/test/libyul/yulControlFlowGraph/switch.yul @@ -22,8 +22,8 @@ // Block0 [label="\ // sstore: [ 0x00 0x00 ] => [ ]\l\ // sload: [ 0x00 ] => [ TMP[sload, 0] ]\l\ -// Assignment(GHOST[0]): [ TMP[sload, 0] ] => [ GHOST[0] ]\l\ -// eq: [ GHOST[0] 0x00 ] => [ TMP[eq, 0] ]\l\ +// Assignment(GHOST[2]): [ TMP[sload, 0] ] => [ GHOST[2] ]\l\ +// eq: [ GHOST[2] 0x00 ] => [ TMP[eq, 0] ]\l\ // "]; // Block0 -> Block0Exit; // Block0Exit [label="{ TMP[eq, 0]| { <0> Zero | <1> NonZero }}" shape=Mrecord]; @@ -31,7 +31,7 @@ // Block0Exit:1 -> Block2; // // Block1 [label="\ -// eq: [ GHOST[0] 0x01 ] => [ TMP[eq, 0] ]\l\ +// eq: [ GHOST[2] 0x01 ] => [ TMP[eq, 0] ]\l\ // "]; // Block1 -> Block1Exit; // Block1Exit [label="{ TMP[eq, 0]| { <0> Zero | <1> NonZero }}" shape=Mrecord]; diff --git a/test/libyul/yulOptimizerTests/commonSubexpressionEliminator/movable_functions.yul b/test/libyul/yulOptimizerTests/commonSubexpressionEliminator/movable_functions.yul index d6041eb5e244..a5fa77b07b37 100644 --- a/test/libyul/yulOptimizerTests/commonSubexpressionEliminator/movable_functions.yul +++ b/test/libyul/yulOptimizerTests/commonSubexpressionEliminator/movable_functions.yul @@ -18,9 +18,9 @@ // let d := double_with_se(i) // function double(x) -> y // { y := add(x, x) } -// function double_with_se(x_1) -> y_2 +// function double_with_se(x_1) -> y_1 // { -// y_2 := add(x_1, x_1) +// y_1 := add(x_1, x_1) // mstore(40, 4) // } // } diff --git a/test/libyul/yulOptimizerTests/disambiguator/for_statement.yul b/test/libyul/yulOptimizerTests/disambiguator/for_statement.yul index 3a01e1ea5c24..1d7bce078c04 100644 --- a/test/libyul/yulOptimizerTests/disambiguator/for_statement.yul +++ b/test/libyul/yulOptimizerTests/disambiguator/for_statement.yul @@ -16,6 +16,6 @@ // function eq_function(x, y) -> z // { } // for { let a_1 } eq_function(a_1, a_1) { a_1 := a_1 } -// { let b_2 := a_1 } +// { let b_1 := a_1 } // } // } diff --git a/test/libyul/yulOptimizerTests/disambiguator/function_call.yul b/test/libyul/yulOptimizerTests/disambiguator/function_call.yul index 0c25f3ee5c87..43c3ed11e28b 100644 --- a/test/libyul/yulOptimizerTests/disambiguator/function_call.yul +++ b/test/libyul/yulOptimizerTests/disambiguator/function_call.yul @@ -12,7 +12,7 @@ // { // { let a, b, c, d, f } // { -// function f_1(a_2) -> c_3, d_4 -// { let b_5, c_1 := f_1(a_2) } +// function f_1(a_1) -> c_2, d_1 +// { let b_1, c_1 := f_1(a_1) } // } // } diff --git a/test/libyul/yulOptimizerTests/disambiguator/if_statement.yul b/test/libyul/yulOptimizerTests/disambiguator/if_statement.yul index e68d9b581b3d..f37481f0a1c9 100644 --- a/test/libyul/yulOptimizerTests/disambiguator/if_statement.yul +++ b/test/libyul/yulOptimizerTests/disambiguator/if_statement.yul @@ -12,6 +12,6 @@ // { let a, b, c } // { // let a_1 -// if a_1 { let b_2 := a_1 } +// if a_1 { let b_1 := a_1 } // } // } diff --git a/test/libyul/yulOptimizerTests/disambiguator/switch_statement.yul b/test/libyul/yulOptimizerTests/disambiguator/switch_statement.yul index d70a805c3f25..aebdac2e5640 100644 --- a/test/libyul/yulOptimizerTests/disambiguator/switch_statement.yul +++ b/test/libyul/yulOptimizerTests/disambiguator/switch_statement.yul @@ -15,7 +15,7 @@ // { // let a_1 // switch a_1 -// case 0 { let b_2 := a_1 } -// default { let c_3 := a_1 } +// case 0 { let b_1 := a_1 } +// default { let c_1 := a_1 } // } // } diff --git a/test/libyul/yulOptimizerTests/disambiguator/variables_inside_functions.yul b/test/libyul/yulOptimizerTests/disambiguator/variables_inside_functions.yul index f26aaced2ef7..0eeb6ea3d0b2 100644 --- a/test/libyul/yulOptimizerTests/disambiguator/variables_inside_functions.yul +++ b/test/libyul/yulOptimizerTests/disambiguator/variables_inside_functions.yul @@ -13,10 +13,10 @@ // let c // let b // } -// function f(a, c_1) -> b_2 +// function f(a, c_1) -> b_1 // { let x } // { -// let a_3 -// let x_4 +// let a_1 +// let x_1 // } // } diff --git a/test/libyul/yulOptimizerTests/equivalentFunctionCombiner/simple_different_vars.yul b/test/libyul/yulOptimizerTests/equivalentFunctionCombiner/simple_different_vars.yul index 5967adc0e13c..e03da0f351f4 100644 --- a/test/libyul/yulOptimizerTests/equivalentFunctionCombiner/simple_different_vars.yul +++ b/test/libyul/yulOptimizerTests/equivalentFunctionCombiner/simple_different_vars.yul @@ -17,7 +17,7 @@ // } // function g() -> a_1 // { -// let b_2 := mload(0) -// a_1 := b_2 +// let b_1 := mload(0) +// a_1 := b_1 // } // } diff --git a/test/libyul/yulOptimizerTests/expressionInliner/argument_duplication_heuristic.yul b/test/libyul/yulOptimizerTests/expressionInliner/argument_duplication_heuristic.yul index 12228009ab83..c37cf6a5327f 100644 --- a/test/libyul/yulOptimizerTests/expressionInliner/argument_duplication_heuristic.yul +++ b/test/libyul/yulOptimizerTests/expressionInliner/argument_duplication_heuristic.yul @@ -22,9 +22,9 @@ // { // function ref1(a) -> x // { x := add(a, 1) } -// function ref3(a_1) -> x_2 +// function ref3(a_1) -> x_1 // { -// x_2 := add(a_1, mul(a_1, a_1)) +// x_1 := add(a_1, mul(a_1, a_1)) // } // let y1 := add(calldatasize(), 1) // let y2 := add(calldatasize(), mul(calldatasize(), calldatasize())) diff --git a/test/libyul/yulOptimizerTests/expressionSimplifier/combine_add_and_mod_constant.yul b/test/libyul/yulOptimizerTests/expressionSimplifier/combine_add_and_mod_constant.yul index f462486ea196..dcf7e0006255 100644 --- a/test/libyul/yulOptimizerTests/expressionSimplifier/combine_add_and_mod_constant.yul +++ b/test/libyul/yulOptimizerTests/expressionSimplifier/combine_add_and_mod_constant.yul @@ -6,8 +6,8 @@ // // { // { -// let _3 := mload(1) -// let _4 := 0 -// mstore(_4, addmod(mload(_4), _3, 32)) +// let _1 := mload(1) +// let _2 := 0 +// mstore(_2, addmod(mload(_2), _1, 32)) // } // } diff --git a/test/libyul/yulOptimizerTests/expressionSimplifier/combine_mul_and_mod_constant.yul b/test/libyul/yulOptimizerTests/expressionSimplifier/combine_mul_and_mod_constant.yul index 93edb5319658..b0e7c1be89b3 100644 --- a/test/libyul/yulOptimizerTests/expressionSimplifier/combine_mul_and_mod_constant.yul +++ b/test/libyul/yulOptimizerTests/expressionSimplifier/combine_mul_and_mod_constant.yul @@ -6,8 +6,8 @@ // // { // { -// let _3 := mload(1) -// let _4 := 0 -// mstore(_4, mulmod(mload(_4), _3, 32)) +// let _1 := mload(1) +// let _2 := 0 +// mstore(_2, mulmod(mload(_2), _1, 32)) // } // } diff --git a/test/libyul/yulOptimizerTests/expressionSimplifier/combine_shift_and_and_2.yul b/test/libyul/yulOptimizerTests/expressionSimplifier/combine_shift_and_and_2.yul index 6e39f2a1dc36..c0dea8b3ebdc 100644 --- a/test/libyul/yulOptimizerTests/expressionSimplifier/combine_shift_and_and_2.yul +++ b/test/libyul/yulOptimizerTests/expressionSimplifier/combine_shift_and_and_2.yul @@ -26,25 +26,25 @@ // { // { // let x := calldataload(0) -// let _2 := 0xf -// let _5 := and(shr(248, x), 0) -// let _10 := 0xff -// let a := and(_5, 255) -// let _14 := and(shr(4, x), 3855) -// let _15 := 12 -// let b := shl(_15, _14) -// let _19 := and(shr(4, x), 3855) -// let c := shl(_15, _19) -// let d := shl(_15, and(shr(255, x), 0)) -// let e := shl(_10, _19) +// let _1 := 0xf +// let _2 := and(shr(248, x), 0) +// let _3 := 0xff +// let a := and(_2, 255) +// let _4 := and(shr(4, x), 3855) +// let _5 := 12 +// let b := shl(_5, _4) +// let _6 := and(shr(4, x), 3855) +// let c := shl(_5, _6) +// let d := shl(_5, and(shr(255, x), 0)) +// let e := shl(_3, _6) // let f := 0 // let g := 0 // sstore(10, a) // sstore(11, b) -// sstore(_15, c) +// sstore(_5, c) // sstore(13, d) // sstore(14, e) -// sstore(_2, f) +// sstore(_1, f) // sstore(16, g) // } // } diff --git a/test/libyul/yulOptimizerTests/expressionSimplifier/combine_shift_and_and_3.yul b/test/libyul/yulOptimizerTests/expressionSimplifier/combine_shift_and_and_3.yul index 9df15b4e9c6f..1c2609e15386 100644 --- a/test/libyul/yulOptimizerTests/expressionSimplifier/combine_shift_and_and_3.yul +++ b/test/libyul/yulOptimizerTests/expressionSimplifier/combine_shift_and_and_3.yul @@ -27,8 +27,8 @@ // let b := and(shr(8, x), 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0) // let c := and(shr(8, x), 0x0fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) // let d := and(shl(8, x), 0x0fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00) -// let _14 := 150 -// let e := shl(_14, and(shl(148, x), 0x3ffffffffffffffffffffffffff0000000000000000000000000000000000000)) +// let _1 := 150 +// let e := shl(_1, and(shl(148, x), 0x3ffffffffffffffffffffffffff0000000000000000000000000000000000000)) // sstore(15, x) // sstore(16, a) // sstore(17, b) diff --git a/test/libyul/yulOptimizerTests/expressionSimplifier/create_and_mask.yul b/test/libyul/yulOptimizerTests/expressionSimplifier/create_and_mask.yul index 1f10c90adb7c..68f63a9614c1 100644 --- a/test/libyul/yulOptimizerTests/expressionSimplifier/create_and_mask.yul +++ b/test/libyul/yulOptimizerTests/expressionSimplifier/create_and_mask.yul @@ -17,8 +17,8 @@ // let _1 := 0x20 // let _2 := 0 // let c := create(_2, _2, _1) -// let _4 := 0xffffffffffffffffffffffffffffffffffffffff -// let a := and(c, _4) -// sstore(a, and(_4, create(_2, _2, _1))) +// let _3 := 0xffffffffffffffffffffffffffffffffffffffff +// let a := and(c, _3) +// sstore(a, and(_3, create(_2, _2, _1))) // } // } diff --git a/test/libyul/yulOptimizerTests/expressionSimplifier/exp_simplifications.yul b/test/libyul/yulOptimizerTests/expressionSimplifier/exp_simplifications.yul index 4a5d218053c0..ac1cbf9de5e6 100644 --- a/test/libyul/yulOptimizerTests/expressionSimplifier/exp_simplifications.yul +++ b/test/libyul/yulOptimizerTests/expressionSimplifier/exp_simplifications.yul @@ -18,8 +18,8 @@ // let t := calldataload(_1) // sstore(_1, iszero(t)) // sstore(1, 1) -// let _8 := 2 -// sstore(_8, shl(t, 1)) +// let _2 := 2 +// sstore(_2, shl(t, 1)) // sstore(3, exp(8, t)) // sstore(4, sub(iszero(and(t, 1)), and(t, 1))) // } diff --git a/test/libyul/yulOptimizerTests/expressionSimplifier/mcopy_non_zero_size.yul b/test/libyul/yulOptimizerTests/expressionSimplifier/mcopy_non_zero_size.yul index 410b7df536b3..b9f46f1d3454 100644 --- a/test/libyul/yulOptimizerTests/expressionSimplifier/mcopy_non_zero_size.yul +++ b/test/libyul/yulOptimizerTests/expressionSimplifier/mcopy_non_zero_size.yul @@ -15,8 +15,8 @@ // let _1 := 0x60 // let _2 := 0 // calldatacopy(_2, _2, _1) -// let _4 := 0x20 -// mcopy(_4, 0x40, _4) +// let _3 := 0x20 +// mcopy(_3, 0x40, _3) // return(_2, _1) // } // } diff --git a/test/libyul/yulOptimizerTests/expressionSimplifier/mod_and_1.yul b/test/libyul/yulOptimizerTests/expressionSimplifier/mod_and_1.yul index 88ed926b18f7..669b799e898f 100644 --- a/test/libyul/yulOptimizerTests/expressionSimplifier/mod_and_1.yul +++ b/test/libyul/yulOptimizerTests/expressionSimplifier/mod_and_1.yul @@ -6,7 +6,7 @@ // // { // { -// let _4 := 0 -// mstore(_4, and(calldataload(_4), 255)) +// let _1 := 0 +// mstore(_1, and(calldataload(_1), 255)) // } // } diff --git a/test/libyul/yulOptimizerTests/expressionSimplifier/mod_and_2.yul b/test/libyul/yulOptimizerTests/expressionSimplifier/mod_and_2.yul index a62c5904cfd5..c08f0b2ce5ae 100644 --- a/test/libyul/yulOptimizerTests/expressionSimplifier/mod_and_2.yul +++ b/test/libyul/yulOptimizerTests/expressionSimplifier/mod_and_2.yul @@ -6,7 +6,7 @@ // // { // { -// let _4 := 0 -// mstore(_4, and(calldataload(_4), 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)) +// let _1 := 0 +// mstore(_1, and(calldataload(_1), 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)) // } // } diff --git a/test/libyul/yulOptimizerTests/expressionSimplifier/not_applied_function_call_different_arguments.yul b/test/libyul/yulOptimizerTests/expressionSimplifier/not_applied_function_call_different_arguments.yul index c4269352191c..e62392c9e1bb 100644 --- a/test/libyul/yulOptimizerTests/expressionSimplifier/not_applied_function_call_different_arguments.yul +++ b/test/libyul/yulOptimizerTests/expressionSimplifier/not_applied_function_call_different_arguments.yul @@ -8,9 +8,9 @@ // // { // { -// let _2 := f(1) -// let _3 := 0 -// sstore(_3, sub(f(_3), _2)) +// let _1 := f(1) +// let _2 := 0 +// sstore(_2, sub(f(_2), _1)) // } // function f(a) -> b // { } diff --git a/test/libyul/yulOptimizerTests/expressionSimplifier/remove_redundant_shift_masking.yul b/test/libyul/yulOptimizerTests/expressionSimplifier/remove_redundant_shift_masking.yul index a4d3012c33b1..fdad31caae72 100644 --- a/test/libyul/yulOptimizerTests/expressionSimplifier/remove_redundant_shift_masking.yul +++ b/test/libyul/yulOptimizerTests/expressionSimplifier/remove_redundant_shift_masking.yul @@ -13,12 +13,12 @@ // // { // { -// let _2 := calldataload(0) -// let _5 := 0xff -// let a := shr(248, _2) -// let b := shr(248, _2) -// let c := and(shr(249, _2), 0xfa) -// let d := and(shr(247, _2), _5) +// let _1 := calldataload(0) +// let _2 := 0xff +// let a := shr(248, _1) +// let b := shr(248, _1) +// let c := and(shr(249, _1), 0xfa) +// let d := and(shr(247, _1), _2) // sstore(a, b) // sstore(c, d) // } diff --git a/test/libyul/yulOptimizerTests/expressionSimplifier/replace_too_large_shift.yul b/test/libyul/yulOptimizerTests/expressionSimplifier/replace_too_large_shift.yul index 85c86f0e4b99..448edbb5a48f 100644 --- a/test/libyul/yulOptimizerTests/expressionSimplifier/replace_too_large_shift.yul +++ b/test/libyul/yulOptimizerTests/expressionSimplifier/replace_too_large_shift.yul @@ -15,10 +15,10 @@ // { // let a := 0 // let b := 0 -// let _8 := calldataload(2) -// let _9 := 255 -// let c := shl(_9, _8) -// let d := shr(_9, calldataload(3)) +// let _1 := calldataload(2) +// let _2 := 255 +// let c := shl(_2, _1) +// let d := shr(_2, calldataload(3)) // sstore(a, b) // sstore(c, d) // } diff --git a/test/libyul/yulOptimizerTests/expressionSimplifier/unassigend_vars_multi.yul b/test/libyul/yulOptimizerTests/expressionSimplifier/unassigend_vars_multi.yul index a15cca231d42..e2a63ba28698 100644 --- a/test/libyul/yulOptimizerTests/expressionSimplifier/unassigend_vars_multi.yul +++ b/test/libyul/yulOptimizerTests/expressionSimplifier/unassigend_vars_multi.yul @@ -10,6 +10,6 @@ // { // { // let c, d -// sstore(d, 7) +// sstore(c, 7) // } // } diff --git a/test/libyul/yulOptimizerTests/fakeStackLimitEvader/connected.yul b/test/libyul/yulOptimizerTests/fakeStackLimitEvader/connected.yul index cc2cae6f652e..ffdd6afea909 100644 --- a/test/libyul/yulOptimizerTests/fakeStackLimitEvader/connected.yul +++ b/test/libyul/yulOptimizerTests/fakeStackLimitEvader/connected.yul @@ -31,34 +31,34 @@ // { // a := 21 // mstore(0x60, 1) -// let b_1, a_2, $c_3 := z() -// mstore(0x60, $c_3) -// a := a_2 -// b := b_1 +// let b_2, a_3, $c := z() +// mstore(0x60, $c) +// a := a_3 +// b := b_2 // } // function f() -> x // { // mstore(0x40, 0) // mstore(0x40, 42) -// let $x3_4, $x4_5 := g() -// mstore(0x00, $x4_5) -// mstore(0x20, $x3_4) +// let $x3, $x4 := g() +// mstore(0x00, $x4) +// mstore(0x20, $x3) // x := mul(add(mload(0x40), mload(0x20)), h(mload(0x00))) // sstore(mload(0x20), mload(0x00)) // } // function h(v) -> a_1 // { -// let x_2_6, $z_7, y_8 := z() -// mstore(0x60, $z_7) -// let y := y_8 -// let x_2 := x_2_6 -// let a_1_9, $z_10, v_11 := z() -// mstore(0x60, $z_10) -// v := v_11 -// a_1 := a_1_9 +// let x_3, $z, y_2 := z() +// mstore(0x60, $z) +// let y := y_2 +// let x_1 := x_3 +// let a_4, $z_1, v_1 := z() +// mstore(0x60, $z_1) +// v := v_1 +// a_1 := a_4 // } -// function z() -> a_3, b_4, c +// function z() -> a_2, b_1, c // { mstore(0x80, 0) } // sstore(0, f()) -// let x_5, y_6 := g() +// let x_2, y_1 := g() // } diff --git a/test/libyul/yulOptimizerTests/fakeStackLimitEvader/multi_variable_declaration_without_value.yul b/test/libyul/yulOptimizerTests/fakeStackLimitEvader/multi_variable_declaration_without_value.yul index 02a974784140..61828a044276 100644 --- a/test/libyul/yulOptimizerTests/fakeStackLimitEvader/multi_variable_declaration_without_value.yul +++ b/test/libyul/yulOptimizerTests/fakeStackLimitEvader/multi_variable_declaration_without_value.yul @@ -16,8 +16,8 @@ // mstore(0x40, memoryguard(0x80)) // { let x, y } // { -// let z_1, $w_2 -// mstore(0x60, $w_2) +// let z_1, $w +// mstore(0x60, $w) // let z := z_1 // } // } diff --git a/test/libyul/yulOptimizerTests/fakeStackLimitEvader/return_leave.yul b/test/libyul/yulOptimizerTests/fakeStackLimitEvader/return_leave.yul index a510c65e96b1..180eeb058cbe 100644 --- a/test/libyul/yulOptimizerTests/fakeStackLimitEvader/return_leave.yul +++ b/test/libyul/yulOptimizerTests/fakeStackLimitEvader/return_leave.yul @@ -38,13 +38,13 @@ // mstore(0x80, 0) // if calldataload(0) // { -// let $b1_1, $b2_2 := g(1) -// mstore(0x80, $b2_2) -// mstore(0xa0, $b1_1) +// let $b1, $b2 := g(1) +// mstore(0x80, $b2) +// mstore(0xa0, $b1) // leave // } -// let $b1_3, $b2_4 := g(2) -// mstore(0x80, $b2_4) -// mstore(0xa0, $b1_3) +// let $b1_1, $b2_1 := g(2) +// mstore(0x80, $b2_1) +// mstore(0xa0, $b1_1) // } // } diff --git a/test/libyul/yulOptimizerTests/fakeStackLimitEvader/return_one_with_args.yul b/test/libyul/yulOptimizerTests/fakeStackLimitEvader/return_one_with_args.yul index 42084c16efc4..e652b940e8ea 100644 --- a/test/libyul/yulOptimizerTests/fakeStackLimitEvader/return_one_with_args.yul +++ b/test/libyul/yulOptimizerTests/fakeStackLimitEvader/return_one_with_args.yul @@ -22,10 +22,10 @@ // mstore(0x40, memoryguard(0xa0)) // sstore(0, f(1, 2, 3)) // } -// function f(a_2, b_3, c_4) -> $b1 +// function f(a_1, b_1, c_1) -> $b1 // { // mstore(0x80, 0) -// f_1(a_2, b_3, c_4) +// f_1(a_1, b_1, c_1) // $b1 := mload(0x80) // } // function f_1(a, b, c) diff --git a/test/libyul/yulOptimizerTests/fakeStackLimitEvader/stub.yul b/test/libyul/yulOptimizerTests/fakeStackLimitEvader/stub.yul index 39db59956535..3d4ec86aa1c1 100644 --- a/test/libyul/yulOptimizerTests/fakeStackLimitEvader/stub.yul +++ b/test/libyul/yulOptimizerTests/fakeStackLimitEvader/stub.yul @@ -39,50 +39,50 @@ // } // function g(gx) // { -// let $gx_1, $gy_2 := tuple2() -// mstore(0x40, $gy_2) -// mstore(0x60, $gx_1) +// let $gx, $gy := tuple2() +// mstore(0x40, $gy) +// mstore(0x60, $gx) // { -// let $gx_3, $gy_4 := tuple2() -// mstore(0x40, $gy_4) -// mstore(0x60, $gx_3) +// let $gx_1, $gy_1 := tuple2() +// mstore(0x40, $gy_1) +// mstore(0x60, $gx_1) // } // { -// let $gx_5, gx_6 := tuple2() -// mstore(0x60, $gx_5) -// gx := gx_6 +// let $gx_2, gx_1 := tuple2() +// mstore(0x60, $gx_2) +// gx := gx_1 // } // { -// let gx_7, $gy_8 := tuple2() -// mstore(0x40, $gy_8) -// gx := gx_7 +// let gx_2, $gy_2 := tuple2() +// mstore(0x40, $gy_2) +// gx := gx_2 // } // } // function h(hx, hy, hz, hw) // { -// let $hx_9, $hy_10, $hz_11, $hw_12 := tuple4() -// mstore(0x00, $hw_12) -// mstore(0x20, $hz_11) -// mstore(0x40, $hy_10) -// mstore(0x60, $hx_9) +// let $hx, $hy, $hz, $hw := tuple4() +// mstore(0x00, $hw) +// mstore(0x20, $hz) +// mstore(0x40, $hy) +// mstore(0x60, $hx) // { -// let hx_13, $hy_14, hz_15, $hw_16 := tuple4() -// mstore(0x00, $hw_16) -// mstore(0x40, $hy_14) -// hz := hz_15 -// hx := hx_13 +// let hx_1, $hy_1, hz_1, $hw_1 := tuple4() +// mstore(0x00, $hw_1) +// mstore(0x40, $hy_1) +// hz := hz_1 +// hx := hx_1 // } // { -// let $hx_17, $hy_18, hz_19, hw_20 := tuple4() -// mstore(0x40, $hy_18) -// mstore(0x60, $hx_17) -// hw := hw_20 -// hz := hz_19 +// let $hx_1, $hy_2, hz_2, hw_1 := tuple4() +// mstore(0x40, $hy_2) +// mstore(0x60, $hx_1) +// hw := hw_1 +// hz := hz_2 // } // } // function tuple2() -> a, b // { } -// function tuple4() -> a_1, b_2, c, d +// function tuple4() -> a_1, b_1, c, d // { } // f() // g(0) diff --git a/test/libyul/yulOptimizerTests/fullInliner/call_arguments_with_side_effects.yul b/test/libyul/yulOptimizerTests/fullInliner/call_arguments_with_side_effects.yul index 94b0c72d2934..ac6e50f15189 100644 --- a/test/libyul/yulOptimizerTests/fullInliner/call_arguments_with_side_effects.yul +++ b/test/libyul/yulOptimizerTests/fullInliner/call_arguments_with_side_effects.yul @@ -11,14 +11,14 @@ // // { // { -// let ret_7 := 0 +// let ret_2 := 0 // revert(0, 0) -// let _1 := ret_7 -// let ret_1_10 := 0 +// let _1 := ret_2 +// let ret_3 := 0 // return(0, 0) -// let _2 := ret_1_10 -// let b_13 := _1 -// let a_14 := _2 +// let _2 := ret_3 +// let b_1 := _1 +// let a_1 := _2 // } // function fun_revert() -> ret // { revert(0, 0) } diff --git a/test/libyul/yulOptimizerTests/fullInliner/call_arguments_without_side_effects.yul b/test/libyul/yulOptimizerTests/fullInliner/call_arguments_without_side_effects.yul index 747ac8084912..416f41b265c5 100644 --- a/test/libyul/yulOptimizerTests/fullInliner/call_arguments_without_side_effects.yul +++ b/test/libyul/yulOptimizerTests/fullInliner/call_arguments_without_side_effects.yul @@ -25,26 +25,26 @@ // let _1 := 333 // let _2 := 222 // let _3 := 111 -// let c_13 := _1 -// let b_14 := _2 -// let a_15 := _3 +// let c_1 := _1 +// let b_1 := _2 +// let a_2 := _3 // let x := 111 // let y := 222 -// let c_16 := 333 -// let b_17 := y -// let a_18 := x -// let _5 := calldataload(333) -// let _7 := sload(222) -// let _9 := mload(111) -// let c_19 := _5 -// let b_20 := _7 -// let a_21 := _9 +// let c_2 := 333 +// let b_2 := y +// let a_3 := x +// let _4 := calldataload(333) +// let _5 := sload(222) +// let _6 := mload(111) +// let c_3 := _4 +// let b_3 := _5 +// let a_4 := _6 // let a_1 := 222 -// let _11 := mload(333) -// let _12 := 111 -// let c_22 := _11 -// let b_23 := a_1 -// let a_24 := _12 +// let _7 := mload(333) +// let _8 := 111 +// let c_4 := _7 +// let b_4 := a_1 +// let a_5 := _8 // } // function empty(a, b, c) // { } diff --git a/test/libyul/yulOptimizerTests/fullInliner/double_inline.yul b/test/libyul/yulOptimizerTests/fullInliner/double_inline.yul index 259e4aeda4c6..37f0b530bf3b 100644 --- a/test/libyul/yulOptimizerTests/fullInliner/double_inline.yul +++ b/test/libyul/yulOptimizerTests/fullInliner/double_inline.yul @@ -9,19 +9,19 @@ // // { // { -// let a_2 := calldataload(0) -// let b_3 := 0 -// let c_4 := 0 -// b_3 := sload(mload(a_2)) -// c_4 := 3 -// let b3 := b_3 -// let a_6 := c_4 -// let b_7 := 0 -// let c_8 := 0 -// b_7 := sload(mload(a_6)) -// c_8 := 3 -// let b4 := b_7 -// let c4 := c_8 +// let a_1 := calldataload(0) +// let b_1 := 0 +// let c_1 := 0 +// b_1 := sload(mload(a_1)) +// c_1 := 3 +// let b3 := b_1 +// let a_2 := c_1 +// let b_2 := 0 +// let c_2 := 0 +// b_2 := sload(mload(a_2)) +// c_2 := 3 +// let b4 := b_2 +// let c4 := c_2 // } // function f(a) -> b, c // { diff --git a/test/libyul/yulOptimizerTests/fullInliner/inside_condition.yul b/test/libyul/yulOptimizerTests/fullInliner/inside_condition.yul index 39c3bb2950c7..ff0b5a476767 100644 --- a/test/libyul/yulOptimizerTests/fullInliner/inside_condition.yul +++ b/test/libyul/yulOptimizerTests/fullInliner/inside_condition.yul @@ -13,12 +13,12 @@ // // { // { -// let _2 := mload(0) -// let a_10 := mload(1) -// let r_11 := 0 -// a_10 := mload(a_10) -// r_11 := add(a_10, calldatasize()) -// if gt(r_11, _2) { sstore(0, 2) } +// let _1 := mload(0) +// let a_1 := mload(1) +// let r_1 := 0 +// a_1 := mload(a_1) +// r_1 := add(a_1, calldatasize()) +// if gt(r_1, _1) { sstore(0, 2) } // } // function f(a) -> r // { diff --git a/test/libyul/yulOptimizerTests/fullInliner/large_function_multi_use.yul b/test/libyul/yulOptimizerTests/fullInliner/large_function_multi_use.yul index 151b7596ca43..44f59ae56414 100644 --- a/test/libyul/yulOptimizerTests/fullInliner/large_function_multi_use.yul +++ b/test/libyul/yulOptimizerTests/fullInliner/large_function_multi_use.yul @@ -22,28 +22,28 @@ // { // let a_1 := mload(2) // let a2 := 2 -// let a_3 := a_1 -// let b_4 := 0 -// let x_5 := mload(a_3) -// b_4 := sload(x_5) -// let y_6 := add(a_3, x_5) -// sstore(y_6, 10) -// let r := b_4 -// let a_8 := a2 -// let b_9 := 0 -// let x_10 := mload(a_8) -// b_9 := sload(x_10) -// let y_11 := add(a_8, x_10) -// sstore(y_11, 10) -// let t := b_9 +// let a_2 := a_1 +// let b_1 := 0 +// let x_1 := mload(a_2) +// b_1 := sload(x_1) +// let y_1 := add(a_2, x_1) +// sstore(y_1, 10) +// let r := b_1 +// let a_3 := a2 +// let b_2 := 0 +// let x_2 := mload(a_3) +// b_2 := sload(x_2) +// let y_2 := add(a_3, x_2) +// sstore(y_2, 10) +// let t := b_2 // let a3 -// let a_13 := a3 -// let b_14 := 0 -// let x_15 := mload(a_13) -// b_14 := sload(x_15) -// let y_16 := add(a_13, x_15) -// sstore(y_16, 10) -// let s := b_14 +// let a_4 := a3 +// let b_3 := 0 +// let x_3 := mload(a_4) +// b_3 := sload(x_3) +// let y_3 := add(a_4, x_3) +// sstore(y_3, 10) +// let s := b_3 // } // function f(a) -> b // { diff --git a/test/libyul/yulOptimizerTests/fullInliner/large_function_single_use.yul b/test/libyul/yulOptimizerTests/fullInliner/large_function_single_use.yul index 4bcfe6f19465..bc0a85a0e2d3 100644 --- a/test/libyul/yulOptimizerTests/fullInliner/large_function_single_use.yul +++ b/test/libyul/yulOptimizerTests/fullInliner/large_function_single_use.yul @@ -15,15 +15,15 @@ // // { // { -// let a_6 := mload(1) -// let b_7 := 0 -// let x_8 := mload(a_6) -// b_7 := sload(x_8) -// let c_9 := 3 -// mstore(mul(a_6, b_7), mload(x_8)) -// let y_12 := add(a_6, x_8) -// sstore(y_12, 10) -// let r := b_7 +// let a_1 := mload(1) +// let b_1 := 0 +// let x_1 := mload(a_1) +// b_1 := sload(x_1) +// let c_1 := 3 +// mstore(mul(a_1, b_1), mload(x_1)) +// let y_1 := add(a_1, x_1) +// sstore(y_1, 10) +// let r := b_1 // } // function f(a) -> b // { diff --git a/test/libyul/yulOptimizerTests/fullInliner/long_names.yul b/test/libyul/yulOptimizerTests/fullInliner/long_names.yul index b2162c520ec9..d5765452a123 100644 --- a/test/libyul/yulOptimizerTests/fullInliner/long_names.yul +++ b/test/libyul/yulOptimizerTests/fullInliner/long_names.yul @@ -13,10 +13,10 @@ // { // { // let verylongvariablename2_1 := 3 -// let verylongvariablename_4 := verylongvariablename2_1 -// let verylongvariablename2_5 := 0 -// verylongvariablename2_5 := add(verylongvariablename_4, verylongvariablename_4) -// mstore(0, verylongvariablename2_5) +// let verylongvariablename_1 := verylongvariablename2_1 +// let verylongvariablename2_2 := 0 +// verylongvariablename2_2 := add(verylongvariablename_1, verylongvariablename_1) +// mstore(0, verylongvariablename2_2) // mstore(1, verylongvariablename2_1) // } // function verylongfunctionname(verylongvariablename) -> verylongvariablename2 diff --git a/test/libyul/yulOptimizerTests/fullInliner/move_up_rightwards_argument.yul b/test/libyul/yulOptimizerTests/fullInliner/move_up_rightwards_argument.yul index 1f777237ac82..8168804c3b5c 100644 --- a/test/libyul/yulOptimizerTests/fullInliner/move_up_rightwards_argument.yul +++ b/test/libyul/yulOptimizerTests/fullInliner/move_up_rightwards_argument.yul @@ -10,18 +10,18 @@ // // { // { -// let _2 := mload(5) -// let _4 := mload(4) -// let _6 := mload(3) -// let _8 := mload(2) -// let c_13 := _4 -// let b_14 := _6 -// let a_15 := _8 -// let x_16 := 0 -// x_16 := add(a_15, b_14) -// x_16 := mul(x_16, c_13) -// let _10 := add(x_16, _2) -// let y := add(mload(1), _10) +// let _1 := mload(5) +// let _2 := mload(4) +// let _3 := mload(3) +// let _4 := mload(2) +// let c_1 := _2 +// let b_1 := _3 +// let a_1 := _4 +// let x_1 := 0 +// x_1 := add(a_1, b_1) +// x_1 := mul(x_1, c_1) +// let _5 := add(x_1, _1) +// let y := add(mload(1), _5) // } // function f(a, b, c) -> x // { diff --git a/test/libyul/yulOptimizerTests/fullInliner/multi_fun.yul b/test/libyul/yulOptimizerTests/fullInliner/multi_fun.yul index b30078cb61f4..f7cd70e883d2 100644 --- a/test/libyul/yulOptimizerTests/fullInliner/multi_fun.yul +++ b/test/libyul/yulOptimizerTests/fullInliner/multi_fun.yul @@ -9,26 +9,26 @@ // { // { // let _1 := 7 -// let a_8 := 3 -// let x_9 := 0 -// x_9 := add(a_8, a_8) -// let _3 := x_9 -// let c_10 := _1 -// let b_11 := _3 -// let y_12 := 0 -// let a_6_13 := b_11 -// let x_7_14 := 0 -// x_7_14 := add(a_6_13, a_6_13) -// y_12 := mul(mload(c_10), x_7_14) -// let y_1 := y_12 +// let a_2 := 3 +// let x_2 := 0 +// x_2 := add(a_2, a_2) +// let _2 := x_2 +// let c_1 := _1 +// let b_1 := _2 +// let y_2 := 0 +// let a_3 := b_1 +// let x_3 := 0 +// x_3 := add(a_3, a_3) +// y_2 := mul(mload(c_1), x_3) +// let y_1 := y_2 // } // function f(a) -> x // { x := add(a, a) } // function g(b, c) -> y // { -// let a_6 := b -// let x_7 := 0 -// x_7 := add(a_6, a_6) -// y := mul(mload(c), x_7) +// let a_1 := b +// let x_1 := 0 +// x_1 := add(a_1, a_1) +// y := mul(mload(c), x_1) // } // } diff --git a/test/libyul/yulOptimizerTests/fullInliner/multi_fun_callback.yul b/test/libyul/yulOptimizerTests/fullInliner/multi_fun_callback.yul index 14e977dd3a67..c24ce6c7708b 100644 --- a/test/libyul/yulOptimizerTests/fullInliner/multi_fun_callback.yul +++ b/test/libyul/yulOptimizerTests/fullInliner/multi_fun_callback.yul @@ -30,10 +30,10 @@ // function f(x) // { // mstore(0, x) -// let t_8 := 0 -// t_8 := 2 -// mstore(7, t_8) -// let x_1_9 := 10 +// let t_1 := 0 +// t_1 := 2 +// mstore(7, t_1) +// let x_2 := 10 // f(1) // mstore(1, x) // } diff --git a/test/libyul/yulOptimizerTests/fullInliner/multi_return.yul b/test/libyul/yulOptimizerTests/fullInliner/multi_return.yul index 21369f10b683..9458f90ec02e 100644 --- a/test/libyul/yulOptimizerTests/fullInliner/multi_return.yul +++ b/test/libyul/yulOptimizerTests/fullInliner/multi_return.yul @@ -11,13 +11,13 @@ // // { // { -// let a_3 := mload(0) -// let x_4 := 0 -// let y_5 := 0 -// x_4 := mul(a_3, a_3) -// y_5 := add(a_3, x_4) -// let r := x_4 -// mstore(r, y_5) +// let a_1 := mload(0) +// let x_1 := 0 +// let y_1 := 0 +// x_1 := mul(a_1, a_1) +// y_1 := add(a_1, x_1) +// let r := x_1 +// mstore(r, y_1) // } // function f(a) -> x, y // { diff --git a/test/libyul/yulOptimizerTests/fullInliner/no_inline_into_big_function.yul b/test/libyul/yulOptimizerTests/fullInliner/no_inline_into_big_function.yul index d120d0152947..966ff54cc7df 100644 --- a/test/libyul/yulOptimizerTests/fullInliner/no_inline_into_big_function.yul +++ b/test/libyul/yulOptimizerTests/fullInliner/no_inline_into_big_function.yul @@ -18,47 +18,47 @@ // { } // function f(a) -> b // { b := sload(mload(a)) } -// function g() -> x_1 +// function g() -> x // { -// let a_20 := 2 -// let b_21 := 0 -// b_21 := sload(mload(a_20)) -// let a_23 := b_21 -// let b_24 := 0 -// b_24 := sload(mload(a_23)) -// let a_26 := b_24 -// let b_27 := 0 -// b_27 := sload(mload(a_26)) -// let a_29 := b_27 -// let b_30 := 0 -// b_30 := sload(mload(a_29)) -// let a_32 := b_30 -// let b_33 := 0 -// b_33 := sload(mload(a_32)) -// let a_35 := b_33 -// let b_36 := 0 -// b_36 := sload(mload(a_35)) -// let a_38 := b_36 -// let b_39 := 0 -// b_39 := sload(mload(a_38)) -// let a_41 := b_39 -// let b_42 := 0 -// b_42 := sload(mload(a_41)) -// let a_44 := b_42 -// let b_45 := 0 -// b_45 := sload(mload(a_44)) -// let a_47 := b_45 -// let b_48 := 0 -// b_48 := sload(mload(a_47)) -// let a_50 := b_48 -// let b_51 := 0 -// b_51 := sload(mload(a_50)) -// let a_53 := b_51 -// let b_54 := 0 -// b_54 := sload(mload(a_53)) -// let a_56 := b_54 -// let b_57 := 0 -// b_57 := sload(mload(a_56)) -// x_1 := f(f(f(f(f(f(b_57)))))) +// let a_1 := 2 +// let b_1 := 0 +// b_1 := sload(mload(a_1)) +// let a_2 := b_1 +// let b_2 := 0 +// b_2 := sload(mload(a_2)) +// let a_3 := b_2 +// let b_3 := 0 +// b_3 := sload(mload(a_3)) +// let a_4 := b_3 +// let b_4 := 0 +// b_4 := sload(mload(a_4)) +// let a_5 := b_4 +// let b_5 := 0 +// b_5 := sload(mload(a_5)) +// let a_6 := b_5 +// let b_6 := 0 +// b_6 := sload(mload(a_6)) +// let a_7 := b_6 +// let b_7 := 0 +// b_7 := sload(mload(a_7)) +// let a_8 := b_7 +// let b_8 := 0 +// b_8 := sload(mload(a_8)) +// let a_9 := b_8 +// let b_9 := 0 +// b_9 := sload(mload(a_9)) +// let a_10 := b_9 +// let b_10 := 0 +// b_10 := sload(mload(a_10)) +// let a_11 := b_10 +// let b_11 := 0 +// b_11 := sload(mload(a_11)) +// let a_12 := b_11 +// let b_12 := 0 +// b_12 := sload(mload(a_12)) +// let a_13 := b_12 +// let b_13 := 0 +// b_13 := sload(mload(a_13)) +// x := f(f(f(f(f(f(b_13)))))) // } // } diff --git a/test/libyul/yulOptimizerTests/fullInliner/no_inline_into_big_global_context.yul b/test/libyul/yulOptimizerTests/fullInliner/no_inline_into_big_global_context.yul index 875d715c5cb0..34d03d94ec58 100644 --- a/test/libyul/yulOptimizerTests/fullInliner/no_inline_into_big_global_context.yul +++ b/test/libyul/yulOptimizerTests/fullInliner/no_inline_into_big_global_context.yul @@ -14,46 +14,46 @@ // // { // { -// let a_20 := 2 -// let b_21 := 0 -// b_21 := sload(mload(a_20)) -// let a_23 := b_21 -// let b_24 := 0 -// b_24 := sload(mload(a_23)) -// let a_26 := b_24 -// let b_27 := 0 -// b_27 := sload(mload(a_26)) -// let a_29 := b_27 -// let b_30 := 0 -// b_30 := sload(mload(a_29)) -// let a_32 := b_30 -// let b_33 := 0 -// b_33 := sload(mload(a_32)) -// let a_35 := b_33 -// let b_36 := 0 -// b_36 := sload(mload(a_35)) -// let a_38 := b_36 -// let b_39 := 0 -// b_39 := sload(mload(a_38)) -// let a_41 := b_39 -// let b_42 := 0 -// b_42 := sload(mload(a_41)) -// let a_44 := b_42 -// let b_45 := 0 -// b_45 := sload(mload(a_44)) -// let a_47 := b_45 -// let b_48 := 0 -// b_48 := sload(mload(a_47)) -// let a_50 := b_48 -// let b_51 := 0 -// b_51 := sload(mload(a_50)) -// let a_53 := b_51 -// let b_54 := 0 -// b_54 := sload(mload(a_53)) -// let a_56 := b_54 -// let b_57 := 0 -// b_57 := sload(mload(a_56)) -// let x_1 := f(f(f(f(f(f(b_57)))))) +// let a_1 := 2 +// let b_1 := 0 +// b_1 := sload(mload(a_1)) +// let a_2 := b_1 +// let b_2 := 0 +// b_2 := sload(mload(a_2)) +// let a_3 := b_2 +// let b_3 := 0 +// b_3 := sload(mload(a_3)) +// let a_4 := b_3 +// let b_4 := 0 +// b_4 := sload(mload(a_4)) +// let a_5 := b_4 +// let b_5 := 0 +// b_5 := sload(mload(a_5)) +// let a_6 := b_5 +// let b_6 := 0 +// b_6 := sload(mload(a_6)) +// let a_7 := b_6 +// let b_7 := 0 +// b_7 := sload(mload(a_7)) +// let a_8 := b_7 +// let b_8 := 0 +// b_8 := sload(mload(a_8)) +// let a_9 := b_8 +// let b_9 := 0 +// b_9 := sload(mload(a_9)) +// let a_10 := b_9 +// let b_10 := 0 +// b_10 := sload(mload(a_10)) +// let a_11 := b_10 +// let b_11 := 0 +// b_11 := sload(mload(a_11)) +// let a_12 := b_11 +// let b_12 := 0 +// b_12 := sload(mload(a_12)) +// let a_13 := b_12 +// let b_13 := 0 +// b_13 := sload(mload(a_13)) +// let x := f(f(f(f(f(f(b_13)))))) // } // function f(a) -> b // { b := sload(mload(a)) } diff --git a/test/libyul/yulOptimizerTests/fullInliner/no_inline_leave.yul b/test/libyul/yulOptimizerTests/fullInliner/no_inline_leave.yul index a22025c4b385..58431428c4b6 100644 --- a/test/libyul/yulOptimizerTests/fullInliner/no_inline_leave.yul +++ b/test/libyul/yulOptimizerTests/fullInliner/no_inline_leave.yul @@ -9,8 +9,8 @@ // // { // { -// let a_2 := calldataload(0) -// a_2 := g() +// let a_1 := calldataload(0) +// a_1 := g() // } // function g() -> x // { diff --git a/test/libyul/yulOptimizerTests/fullInliner/no_return.yul b/test/libyul/yulOptimizerTests/fullInliner/no_return.yul index 2897b5151d08..4e4f00a3a731 100644 --- a/test/libyul/yulOptimizerTests/fullInliner/no_return.yul +++ b/test/libyul/yulOptimizerTests/fullInliner/no_return.yul @@ -9,8 +9,8 @@ // // { // { -// let a_3 := mload(0) -// sstore(a_3, a_3) +// let a_1 := mload(0) +// sstore(a_1, a_1) // } // function f(a) // { sstore(a, a) } diff --git a/test/libyul/yulOptimizerTests/fullInliner/not_inside_for.yul b/test/libyul/yulOptimizerTests/fullInliner/not_inside_for.yul index 5678a13fd9a1..5d6fa3a34219 100644 --- a/test/libyul/yulOptimizerTests/fullInliner/not_inside_for.yul +++ b/test/libyul/yulOptimizerTests/fullInliner/not_inside_for.yul @@ -14,26 +14,26 @@ // // { // { -// let a_3 := 0 -// let r_4 := 0 -// sstore(a_3, 0) -// r_4 := a_3 -// let x := r_4 +// let a_1 := 0 +// let r_1 := 0 +// sstore(a_1, 0) +// r_1 := a_1 +// let x := r_1 // for { } // f(x) // { -// let a_6 := x -// let r_7 := 0 -// sstore(a_6, 0) -// r_7 := a_6 -// x := r_7 +// let a_2 := x +// let r_2 := 0 +// sstore(a_2, 0) +// r_2 := a_2 +// x := r_2 // } // { -// let a_9 := x -// let r_10 := 0 -// sstore(a_9, 0) -// r_10 := a_9 -// let t := r_10 +// let a_3 := x +// let r_3 := 0 +// sstore(a_3, 0) +// r_3 := a_3 +// let t := r_3 // } // } // function f(a) -> r diff --git a/test/libyul/yulOptimizerTests/fullInliner/pop_result.yul b/test/libyul/yulOptimizerTests/fullInliner/pop_result.yul index c46505c79a17..15c6dc2ad632 100644 --- a/test/libyul/yulOptimizerTests/fullInliner/pop_result.yul +++ b/test/libyul/yulOptimizerTests/fullInliner/pop_result.yul @@ -14,11 +14,11 @@ // { // { // let _1 := 2 -// let a_5 := 7 -// let x_6 := 0 -// let r_7 := mul(a_5, a_5) -// x_6 := add(r_7, r_7) -// pop(add(x_6, _1)) +// let a_1 := 7 +// let x_1 := 0 +// let r_1 := mul(a_1, a_1) +// x_1 := add(r_1, r_1) +// pop(add(x_1, _1)) // } // function f(a) -> x // { diff --git a/test/libyul/yulOptimizerTests/fullInliner/simple.yul b/test/libyul/yulOptimizerTests/fullInliner/simple.yul index 2c9d979b5832..e12a61dc6fcc 100644 --- a/test/libyul/yulOptimizerTests/fullInliner/simple.yul +++ b/test/libyul/yulOptimizerTests/fullInliner/simple.yul @@ -10,12 +10,12 @@ // // { // { -// let _2 := mload(7) -// let a_7 := sload(mload(2)) -// let x_8 := 0 -// let r_9 := mul(a_7, a_7) -// x_8 := add(r_9, r_9) -// let y := add(x_8, _2) +// let _1 := mload(7) +// let a_1 := sload(mload(2)) +// let x_1 := 0 +// let r_1 := mul(a_1, a_1) +// x_1 := add(r_1, r_1) +// let y := add(x_1, _1) // } // function f(a) -> x // { diff --git a/test/libyul/yulOptimizerTests/fullInlinerWithoutSplitter/call_arguments_without_side_effects.yul b/test/libyul/yulOptimizerTests/fullInlinerWithoutSplitter/call_arguments_without_side_effects.yul index 8f903b48445d..9292960d3865 100644 --- a/test/libyul/yulOptimizerTests/fullInlinerWithoutSplitter/call_arguments_without_side_effects.yul +++ b/test/libyul/yulOptimizerTests/fullInlinerWithoutSplitter/call_arguments_without_side_effects.yul @@ -23,14 +23,14 @@ // { // { // let c_1 := 333 -// let b_2 := 222 -// let a_3 := 111 +// let b_1 := 222 +// let a_2 := 111 // let x := 111 // let y := 222 // let z := 333 -// let c_4 := z -// let b_5 := y -// let a_6 := x +// let c_2 := z +// let b_2 := y +// let a_3 := x // empty(mload(111), sload(222), calldataload(333)) // let a_1 := 222 // empty(111, a_1, mload(333)) diff --git a/test/libyul/yulOptimizerTests/fullInlinerWithoutSplitter/simple.yul b/test/libyul/yulOptimizerTests/fullInlinerWithoutSplitter/simple.yul index 80b975903ca7..64935ee1ab25 100644 --- a/test/libyul/yulOptimizerTests/fullInlinerWithoutSplitter/simple.yul +++ b/test/libyul/yulOptimizerTests/fullInlinerWithoutSplitter/simple.yul @@ -10,9 +10,9 @@ // { // { // let a_1 := 2 -// let x_2 := 0 -// x_2 := add(a_1, a_1) -// let y := x_2 +// let x_1 := 0 +// x_1 := add(a_1, a_1) +// let y := x_1 // } // function f(a) -> x // { x := add(a, a) } diff --git a/test/libyul/yulOptimizerTests/fullSimplify/constant_propagation.yul b/test/libyul/yulOptimizerTests/fullSimplify/constant_propagation.yul index a13ad9395314..f899bd109bc2 100644 --- a/test/libyul/yulOptimizerTests/fullSimplify/constant_propagation.yul +++ b/test/libyul/yulOptimizerTests/fullSimplify/constant_propagation.yul @@ -7,7 +7,7 @@ // // { // { -// let _2 := 0 -// mstore(mload(_2), _2) +// let _1 := 0 +// mstore(mload(_1), _1) // } // } diff --git a/test/libyul/yulOptimizerTests/fullSimplify/invariant.yul b/test/libyul/yulOptimizerTests/fullSimplify/invariant.yul index 0ab5cc6ed88f..07edc381d37d 100644 --- a/test/libyul/yulOptimizerTests/fullSimplify/invariant.yul +++ b/test/libyul/yulOptimizerTests/fullSimplify/invariant.yul @@ -13,8 +13,8 @@ // { // { // let a := calldataload(0) -// let _4 := 0 +// let _1 := 0 // let b := a -// mstore(b, eq(calldataload(_4), a)) +// mstore(b, eq(calldataload(_1), a)) // } // } diff --git a/test/libyul/yulOptimizerTests/fullSimplify/mod_and_1.yul b/test/libyul/yulOptimizerTests/fullSimplify/mod_and_1.yul index c10345e4ee56..f02797730fcf 100644 --- a/test/libyul/yulOptimizerTests/fullSimplify/mod_and_1.yul +++ b/test/libyul/yulOptimizerTests/fullSimplify/mod_and_1.yul @@ -6,7 +6,7 @@ // // { // { -// let _4 := 0 -// mstore(_4, and(calldataload(_4), 255)) +// let _1 := 0 +// mstore(_1, and(calldataload(_1), 255)) // } // } diff --git a/test/libyul/yulOptimizerTests/fullSimplify/mod_and_2.yul b/test/libyul/yulOptimizerTests/fullSimplify/mod_and_2.yul index fc171337f9b1..d05f3db3cadd 100644 --- a/test/libyul/yulOptimizerTests/fullSimplify/mod_and_2.yul +++ b/test/libyul/yulOptimizerTests/fullSimplify/mod_and_2.yul @@ -6,7 +6,7 @@ // // { // { -// let _4 := 0 -// mstore(_4, and(calldataload(_4), 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)) +// let _1 := 0 +// mstore(_1, and(calldataload(_1), 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)) // } // } diff --git a/test/libyul/yulOptimizerTests/fullSimplify/not_applied_function_call_different_arguments.yul b/test/libyul/yulOptimizerTests/fullSimplify/not_applied_function_call_different_arguments.yul index e42b6c098600..c168ddb5094f 100644 --- a/test/libyul/yulOptimizerTests/fullSimplify/not_applied_function_call_different_arguments.yul +++ b/test/libyul/yulOptimizerTests/fullSimplify/not_applied_function_call_different_arguments.yul @@ -7,9 +7,9 @@ // // { // { -// let _2 := f(1) -// let _3 := 0 -// mstore(_3, sub(f(_3), _2)) +// let _1 := f(1) +// let _2 := 0 +// mstore(_2, sub(f(_2), _1)) // } // function f(a) -> b // { } diff --git a/test/libyul/yulOptimizerTests/fullSimplify/scoped_var_ref_in_function_call.yul b/test/libyul/yulOptimizerTests/fullSimplify/scoped_var_ref_in_function_call.yul index 1820f363c52f..5a8e2fc2e41d 100644 --- a/test/libyul/yulOptimizerTests/fullSimplify/scoped_var_ref_in_function_call.yul +++ b/test/libyul/yulOptimizerTests/fullSimplify/scoped_var_ref_in_function_call.yul @@ -13,10 +13,10 @@ // // { // { -// let x_1 -// let _2 := calldataload(x_1) -// let _3 := 1 -// x_1 := add(_3, _2) -// pop(call(2, 0, _3, addmod(_3, _2, 8), _3, _3, _3)) +// let x +// let _1 := calldataload(x) +// let _2 := 1 +// x := add(_2, _1) +// pop(call(2, 0, _2, addmod(_2, _1, 8), _2, _2, _2)) // } // } diff --git a/test/libyul/yulOptimizerTests/fullSuite/abi2.yul b/test/libyul/yulOptimizerTests/fullSuite/abi2.yul index 2f2e060be089..e04e81d04db8 100644 --- a/test/libyul/yulOptimizerTests/fullSuite/abi2.yul +++ b/test/libyul/yulOptimizerTests/fullSuite/abi2.yul @@ -1081,47 +1081,47 @@ // let _2 := mload(0) // if slt(sub(_1, _2), 64) { revert(0, 0) } // sstore(0, and(calldataload(_2), sub(shl(160, 1), 1))) -// let x0, x1, x2, x3, x4 := abi_decode_addresst_uint256t_bytes_calldatat_enum_Operation(mload(7), mload(8)) +// let x0, x1, x2, x3, x4 := abi_decode_tuple_t_addresst_uint256t_bytes_calldata_ptrt_enum$_Operation_$1949(mload(7), mload(8)) // sstore(x1, x0) // sstore(x3, x2) // sstore(1, x4) -// pop(abi_encode_bytes32_address_uint256_bytes32_enum_Operation_uint256_uint256_uint256_address_address_uint256(mload(30), mload(31), mload(32), mload(33), mload(34), mload(35), mload(36), mload(37), mload(38), mload(39), mload(40), mload(41))) +// pop(abi_encode_tuple_t_bytes32_t_address_t_uint256_t_bytes32_t_enum$_Operation_$1949_t_uint256_t_uint256_t_uint256_t_address_t_address_t_uint256__to_t_bytes32_t_address_t_uint256_t_bytes32_t_uint8_t_uint256_t_uint256_t_uint256_t_address_t_address_t_uint256_(mload(30), mload(31), mload(32), mload(33), mload(34), mload(35), mload(36), mload(37), mload(38), mload(39), mload(40), mload(41))) // } -// function abi_decode_addresst_uint256t_bytes_calldatat_enum_Operation(headStart, dataEnd) -> value0, value1, value2, value3, value4 +// function abi_decode_tuple_t_addresst_uint256t_bytes_calldata_ptrt_enum$_Operation_$1949(headStart_55, dataEnd_56) -> value0_57, value1_58, value2_59, value3, value4 // { -// if slt(sub(dataEnd, headStart), 128) { revert(0, 0) } -// value0 := and(calldataload(headStart), sub(shl(160, 1), 1)) -// value1 := calldataload(add(headStart, 32)) -// let offset := calldataload(add(headStart, 64)) -// if gt(offset, 0xffffffffffffffff) { revert(0, 0) } -// let _1 := add(headStart, offset) -// if iszero(slt(add(_1, 0x1f), dataEnd)) { revert(0, 0) } -// let length := calldataload(_1) -// if gt(length, 0xffffffffffffffff) { revert(0, 0) } -// if gt(add(add(_1, length), 32), dataEnd) { revert(0, 0) } -// value2 := add(_1, 32) -// value3 := length -// value4 := cleanup_revert_enum_Operation(calldataload(add(headStart, 96))) +// if slt(sub(dataEnd_56, headStart_55), 128) { revert(0, 0) } +// value0_57 := and(calldataload(headStart_55), sub(shl(160, 1), 1)) +// value1_58 := calldataload(add(headStart_55, 32)) +// let offset_62 := calldataload(add(headStart_55, 64)) +// if gt(offset_62, 0xffffffffffffffff) { revert(0, 0) } +// let _3 := add(headStart_55, offset_62) +// if iszero(slt(add(_3, 0x1f), dataEnd_56)) { revert(0, 0) } +// let length_15 := calldataload(_3) +// if gt(length_15, 0xffffffffffffffff) { revert(0, 0) } +// if gt(add(add(_3, length_15), 32), dataEnd_56) { revert(0, 0) } +// value2_59 := add(_3, 32) +// value3 := length_15 +// value4 := cleanup_revert_t_enum$_Operation_$1949(calldataload(add(headStart_55, 96))) // } -// function abi_encode_bytes32_address_uint256_bytes32_enum_Operation_uint256_uint256_uint256_address_address_uint256(headStart, value10, value9, value8, value7, value6, value5, value4, value3, value2, value1, value0) -> tail +// function abi_encode_tuple_t_bytes32_t_address_t_uint256_t_bytes32_t_enum$_Operation_$1949_t_uint256_t_uint256_t_uint256_t_address_t_address_t_uint256__to_t_bytes32_t_address_t_uint256_t_bytes32_t_uint8_t_uint256_t_uint256_t_uint256_t_address_t_address_t_uint256_(headStart_252, value10_253, value9_254, value8_255, value7_256, value6_257, value5_258, value4_259, value3_260, value2_261, value1_262, value0_263) -> tail_264 // { -// tail := add(headStart, 352) -// mstore(headStart, value0) -// mstore(add(headStart, 32), and(value1, sub(shl(160, 1), 1))) -// mstore(add(headStart, 64), value2) -// mstore(add(headStart, 96), value3) -// if iszero(lt(value4, 3)) { invalid() } -// mstore(add(headStart, 128), value4) -// mstore(add(headStart, 160), value5) -// mstore(add(headStart, 192), value6) -// mstore(add(headStart, 224), value7) -// mstore(add(headStart, 256), and(value8, sub(shl(160, 1), 1))) -// mstore(add(headStart, 288), and(value9, sub(shl(160, 1), 1))) -// mstore(add(headStart, 320), value10) +// tail_264 := add(headStart_252, 352) +// mstore(headStart_252, value0_263) +// mstore(add(headStart_252, 32), and(value1_262, sub(shl(160, 1), 1))) +// mstore(add(headStart_252, 64), value2_261) +// mstore(add(headStart_252, 96), value3_260) +// if iszero(lt(value4_259, 3)) { invalid() } +// mstore(add(headStart_252, 128), value4_259) +// mstore(add(headStart_252, 160), value5_258) +// mstore(add(headStart_252, 192), value6_257) +// mstore(add(headStart_252, 224), value7_256) +// mstore(add(headStart_252, 256), and(value8_255, sub(shl(160, 1), 1))) +// mstore(add(headStart_252, 288), and(value9_254, sub(shl(160, 1), 1))) +// mstore(add(headStart_252, 320), value10_253) // } -// function cleanup_revert_enum_Operation(value) -> cleaned +// function cleanup_revert_t_enum$_Operation_$1949(value_369) -> cleaned_370 // { -// if iszero(lt(value, 3)) { revert(0, 0) } -// cleaned := value +// if iszero(lt(value_369, 3)) { revert(0, 0) } +// cleaned_370 := value_369 // } // } diff --git a/test/libyul/yulOptimizerTests/fullSuite/abi_example1.yul b/test/libyul/yulOptimizerTests/fullSuite/abi_example1.yul index dbb87439f637..fd345142f351 100644 --- a/test/libyul/yulOptimizerTests/fullSuite/abi_example1.yul +++ b/test/libyul/yulOptimizerTests/fullSuite/abi_example1.yul @@ -465,18 +465,18 @@ // { // let _1 := mload(0) // let pos := 0x20 -// let length := mload(_1) -// mstore(pos, length) +// let length_3 := mload(_1) +// mstore(pos, length_3) // pos := 64 // let srcPtr := add(_1, 0x20) -// let i := 0 -// for { } lt(i, length) { i := add(i, 1) } +// let i_3 := 0 +// for { } lt(i_3, length_3) { i_3 := add(i_3, 1) } // { -// let _2 := mload(srcPtr) +// let _4 := mload(srcPtr) // let pos_1 := pos -// let srcPtr_1 := _2 -// let i_1 := 0 -// for { } lt(i_1, 0x3) { i_1 := add(i_1, 1) } +// let srcPtr_1 := _4 +// let i_4 := 0 +// for { } lt(i_4, 0x3) { i_4 := add(i_4, 1) } // { // mstore(pos_1, and(mload(srcPtr_1), sub(shl(160, 1), 1))) // srcPtr_1 := add(srcPtr_1, 0x20) @@ -485,16 +485,16 @@ // srcPtr := add(srcPtr, 0x20) // pos := add(pos, 0x60) // } -// let a, b, c, d := abi_decode_uint256t_uint256t_array_uint256_dynt_array_array_uint256_memory_dyn(mload(0x20), mload(64)) +// let a, b, c, d := abi_decode_tuple_t_uint256t_uint256t_array$_t_uint256_$dyn_memory_ptrt_array$_t_array$_t_uint256_$2_memory_$dyn_memory_ptr(mload(0x20), mload(64)) // sstore(a, b) // sstore(c, d) // sstore(0, pos) // } -// function abi_decode_array_array_uint256_memory_dyn(offset, end) -> array +// function abi_decode_t_array$_t_array$_t_uint256_$2_memory_$dyn_memory_ptr(offset, end) -> array // { // if iszero(slt(add(offset, 0x1f), end)) { revert(0, 0) } // let length := calldataload(offset) -// array := allocateMemory(array_allocation_size_array_address_dyn_memory(length)) +// array := allocateMemory(array_allocation_size_t_array$_t_address_$dyn_memory(length)) // let dst := array // mstore(array, length) // dst := add(array, 0x20) @@ -504,11 +504,11 @@ // for { } lt(i, length) { i := add(i, 1) } // { // if iszero(slt(add(src, 0x1f), end)) { revert(0, 0) } -// let dst_1 := allocateMemory_823() +// let dst_1 := allocateMemory_1() // let array_1 := dst_1 // let src_1 := src -// let _1 := add(src, 64) -// if gt(_1, end) { revert(0, 0) } +// let _3 := add(src, 64) +// if gt(_3, end) { revert(0, 0) } // let i_1 := 0 // for { } lt(i_1, 0x2) { i_1 := add(i_1, 1) } // { @@ -518,43 +518,43 @@ // } // mstore(dst, array_1) // dst := add(dst, 0x20) -// src := _1 +// src := _3 // } // } -// function abi_decode_uint256t_uint256t_array_uint256_dynt_array_array_uint256_memory_dyn(headStart, dataEnd) -> value0, value1, value2, value3 +// function abi_decode_tuple_t_uint256t_uint256t_array$_t_uint256_$dyn_memory_ptrt_array$_t_array$_t_uint256_$2_memory_$dyn_memory_ptr(headStart, dataEnd) -> value0, value1, value2, value3 // { // if slt(sub(dataEnd, headStart), 128) { revert(0, 0) } // value0 := calldataload(headStart) // value1 := calldataload(add(headStart, 32)) -// let offset := calldataload(add(headStart, 64)) -// if gt(offset, 0xffffffffffffffff) { revert(0, 0) } -// let _1 := add(headStart, offset) -// if iszero(slt(add(_1, 0x1f), dataEnd)) { revert(0, 0) } -// let length := calldataload(_1) -// let dst := allocateMemory(array_allocation_size_array_address_dyn_memory(length)) -// let array := dst -// mstore(dst, length) -// dst := add(dst, 32) -// let src := add(_1, 32) -// if gt(add(add(_1, shl(5, length)), 32), dataEnd) { revert(0, 0) } -// let i := 0 -// for { } lt(i, length) { i := add(i, 1) } +// let offset_1 := calldataload(add(headStart, 64)) +// if gt(offset_1, 0xffffffffffffffff) { revert(0, 0) } +// let _2 := add(headStart, offset_1) +// if iszero(slt(add(_2, 0x1f), dataEnd)) { revert(0, 0) } +// let length_2 := calldataload(_2) +// let dst_2 := allocateMemory(array_allocation_size_t_array$_t_address_$dyn_memory(length_2)) +// let array_2 := dst_2 +// mstore(dst_2, length_2) +// dst_2 := add(dst_2, 32) +// let src_2 := add(_2, 32) +// if gt(add(add(_2, shl(5, length_2)), 32), dataEnd) { revert(0, 0) } +// let i_2 := 0 +// for { } lt(i_2, length_2) { i_2 := add(i_2, 1) } // { -// mstore(dst, calldataload(src)) -// dst := add(dst, 32) -// src := add(src, 32) +// mstore(dst_2, calldataload(src_2)) +// dst_2 := add(dst_2, 32) +// src_2 := add(src_2, 32) // } -// value2 := array -// let offset_1 := calldataload(add(headStart, 96)) -// if gt(offset_1, 0xffffffffffffffff) { revert(0, 0) } -// value3 := abi_decode_array_array_uint256_memory_dyn(add(headStart, offset_1), dataEnd) +// value2 := array_2 +// let offset_2 := calldataload(add(headStart, 96)) +// if gt(offset_2, 0xffffffffffffffff) { revert(0, 0) } +// value3 := abi_decode_t_array$_t_array$_t_uint256_$2_memory_$dyn_memory_ptr(add(headStart, offset_2), dataEnd) // } -// function allocateMemory_823() -> memPtr +// function allocateMemory_1() -> memPtr_1 // { -// memPtr := mload(64) -// let newFreePtr := add(memPtr, 64) -// if or(gt(newFreePtr, 0xffffffffffffffff), lt(newFreePtr, memPtr)) { revert(0, 0) } -// mstore(64, newFreePtr) +// memPtr_1 := mload(64) +// let newFreePtr_1 := add(memPtr_1, 64) +// if or(gt(newFreePtr_1, 0xffffffffffffffff), lt(newFreePtr_1, memPtr_1)) { revert(0, 0) } +// mstore(64, newFreePtr_1) // } // function allocateMemory(size) -> memPtr // { @@ -563,9 +563,9 @@ // if or(gt(newFreePtr, 0xffffffffffffffff), lt(newFreePtr, memPtr)) { revert(0, 0) } // mstore(64, newFreePtr) // } -// function array_allocation_size_array_address_dyn_memory(length) -> size +// function array_allocation_size_t_array$_t_address_$dyn_memory(length_1) -> size_1 // { -// if gt(length, 0xffffffffffffffff) { revert(0, 0) } -// size := add(shl(5, length), 0x20) +// if gt(length_1, 0xffffffffffffffff) { revert(0, 0) } +// size_1 := add(shl(5, length_1), 0x20) // } // } diff --git a/test/libyul/yulOptimizerTests/fullSuite/aztec.yul b/test/libyul/yulOptimizerTests/fullSuite/aztec.yul index 94d4b14fffcf..ac391003d0f5 100644 --- a/test/libyul/yulOptimizerTests/fullSuite/aztec.yul +++ b/test/libyul/yulOptimizerTests/fullSuite/aztec.yul @@ -240,11 +240,11 @@ // mstore(0x80, 7673901602397024137095011250362199966051872585513276903826533215767972925880) // mstore(0xa0, 8489654445897228341090914135473290831551238522473825886865492707826370766375) // let _1 := calldataload(0x04) -// let notes := add(0x04, _1) +// let notes_1 := add(0x04, _1) // let m := calldataload(0x24) -// let n := calldataload(notes) +// let n_1 := calldataload(notes_1) // let challenge := mod(calldataload(0x44), 0x30644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000001) -// if gt(m, n) +// if gt(m, n_1) // { // mstore(0x00, 404) // revert(0x00, 0x20) @@ -254,57 +254,59 @@ // mstore(0x2c0, kn) // mstore(0x2e0, m) // kn := mulmod(sub(0x30644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000001, kn), challenge, 0x30644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000001) -// hashCommitments(notes, n) -// let b := add(0x300, shl(7, n)) -// let i := 0 -// for { } lt(i, n) { i := add(i, 0x01) } +// hashCommitments(notes_1, n_1) +// let b := add(0x300, shl(7, n_1)) +// let i_1 := 0 +// for { } lt(i_1, n_1) { i_1 := add(i_1, 0x01) } // { -// let _2 := add(_1, mul(i, 0xc0)) +// let _2 := add(_1, mul(i_1, 0xc0)) // let noteIndex := add(_2, 0x24) -// let k := 0 -// let a := calldataload(add(_2, 0x44)) +// let k_1 := 0 +// let a_1 := calldataload(add(_2, 0x44)) // let c := challenge -// let _3 := add(i, 0x01) -// switch eq(_3, n) +// let _3 := add(i_1, 0x01) +// switch eq(_3, n_1) // case 1 { -// k := kn -// if eq(m, n) +// k_1 := kn +// if eq(m, n_1) // { -// k := sub(0x30644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000001, kn) +// k_1 := sub(0x30644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000001, kn) // } // } -// case 0 { k := calldataload(noteIndex) } -// validateCommitment(noteIndex, k, a) +// case 0 { +// k_1 := calldataload(noteIndex) +// } +// validateCommitment(noteIndex, k_1, a_1) // switch gt(_3, m) // case 1 { -// kn := addmod(kn, sub(0x30644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000001, k), 0x30644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000001) +// kn := addmod(kn, sub(0x30644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000001, k_1), 0x30644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000001) // let x := mod(mload(0), 0x30644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000001) -// k := mulmod(k, x, 0x30644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000001) -// a := mulmod(a, x, 0x30644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000001) +// k_1 := mulmod(k_1, x, 0x30644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000001) +// a_1 := mulmod(a_1, x, 0x30644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000001) // c := mulmod(challenge, x, 0x30644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000001) // mstore(0, keccak256(0, 0x20)) // } // case 0 { -// kn := addmod(kn, k, 0x30644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000001) +// kn := addmod(kn, k_1, 0x30644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000001) // } // calldatacopy(0xe0, add(_2, 164), 0x40) // calldatacopy(0x20, add(_2, 100), 0x40) // mstore(0x120, sub(0x30644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000001, c)) -// mstore(0x60, k) -// mstore(0xc0, a) +// mstore(0x60, k_1) +// mstore(0xc0, a_1) // let result := call(gas(), 7, 0, 0xe0, 0x60, 0x1a0, 0x40) // let result_1 := and(result, call(gas(), 7, 0, 0x20, 0x60, 0x120, 0x40)) // let result_2 := and(result_1, call(gas(), 7, 0, 0x80, 0x60, 0x160, 0x40)) // let result_3 := and(result_2, call(gas(), 6, 0, 0x120, 0x80, 0x160, 0x40)) // result := and(result_3, call(gas(), 6, 0, 0x160, 0x80, b, 0x40)) -// if eq(i, m) +// if eq(i_1, m) // { // mstore(0x260, mload(0x20)) // mstore(0x280, mload(0x40)) // mstore(0x1e0, mload(0xe0)) // mstore(0x200, sub(0x30644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd47, mload(0x100))) // } -// if gt(i, m) +// if gt(i_1, m) // { // mstore(0x60, c) // let result_4 := and(result, call(gas(), 7, 0, 0x20, 0x60, 0x220, 0x40)) @@ -318,7 +320,7 @@ // } // b := add(b, 0x40) // } -// if lt(m, n) { validatePairing() } +// if lt(m, n_1) { validatePairing() } // if iszero(eq(mod(keccak256(0x2a0, add(b, not(671))), 0x30644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000001), challenge)) // { // mstore(0, 404) @@ -329,11 +331,11 @@ // } // function validatePairing() // { -// let t2_x := calldataload(0x64) -// let t2_x_1 := calldataload(132) -// let t2_y := calldataload(164) -// let t2_y_1 := calldataload(196) -// if or(or(or(or(or(or(or(iszero(t2_x), iszero(t2_x_1)), iszero(t2_y)), iszero(t2_y_1)), eq(t2_x, 0x1800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed)), eq(t2_x_1, 0x198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c2)), eq(t2_y, 0x12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa)), eq(t2_y_1, 0x90689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b)) +// let t2_x_1 := calldataload(0x64) +// let t2_x_2 := calldataload(132) +// let t2_y_1 := calldataload(164) +// let t2_y_2 := calldataload(196) +// if or(or(or(or(or(or(or(iszero(t2_x_1), iszero(t2_x_2)), iszero(t2_y_1)), iszero(t2_y_2)), eq(t2_x_1, 0x1800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed)), eq(t2_x_2, 0x198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c2)), eq(t2_y_1, 0x12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa)), eq(t2_y_2, 0x90689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b)) // { // mstore(0x00, 400) // revert(0x00, 0x20) @@ -346,10 +348,10 @@ // mstore(0xa0, 0x90689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b) // mstore(0xe0, mload(0x260)) // mstore(0x100, mload(0x280)) -// mstore(0x140, t2_x) -// mstore(0x120, t2_x_1) -// mstore(0x180, t2_y) -// mstore(0x160, t2_y_1) +// mstore(0x140, t2_x_1) +// mstore(0x120, t2_x_2) +// mstore(0x180, t2_y_1) +// mstore(0x160, t2_y_2) // let success := call(gas(), 8, 0, 0x20, 0x180, 0x20, 0x20) // if or(iszero(success), iszero(mload(0x20))) // { diff --git a/test/libyul/yulOptimizerTests/fullSuite/loopInvariantCodeMotion.yul b/test/libyul/yulOptimizerTests/fullSuite/loopInvariantCodeMotion.yul index a0be61939b1f..9076107fea1f 100644 --- a/test/libyul/yulOptimizerTests/fullSuite/loopInvariantCodeMotion.yul +++ b/test/libyul/yulOptimizerTests/fullSuite/loopInvariantCodeMotion.yul @@ -28,13 +28,13 @@ // let sum := 0 // let length := calldataload(_1) // let i := 0 -// let _2 := calldataload(7) +// let _3 := calldataload(7) // for { } 1 { i := add(i, 1) } // { -// let _3 := iszero(lt(i, length)) -// if _3 { break } -// _3 := 0 -// sum := add(sum, add(calldataload(add(add(_1, shl(5, i)), 0x20)), _2)) +// let _2 := iszero(lt(i, length)) +// if _2 { break } +// _2 := 0 +// sum := add(sum, add(calldataload(add(add(_1, shl(5, i)), 0x20)), _3)) // } // sstore(0, sum) // } diff --git a/test/libyul/yulOptimizerTests/fullSuite/name_cleaner_reserved.yul b/test/libyul/yulOptimizerTests/fullSuite/name_cleaner_reserved.yul index 05cf04a71024..f1cf9fe29a3b 100644 --- a/test/libyul/yulOptimizerTests/fullSuite/name_cleaner_reserved.yul +++ b/test/libyul/yulOptimizerTests/fullSuite/name_cleaner_reserved.yul @@ -18,16 +18,16 @@ // { // { // pop(mstore_(7)) -// nonmstore(70) +// nonmstore_(70) // } -// function nonmstore(x) +// function nonmstore_(x) // { -// if calldataload(0) { nonmstore(x) } +// if calldataload(0) { nonmstore_(x) } // sstore(10, calldataload(2)) // } -// function mstore_(x) -> y +// function mstore_(x_1) -> y // { -// if calldataload(0) { pop(mstore_(x)) } +// if calldataload(0) { pop(mstore_(x_1)) } // y := 8 // sstore(8, calldataload(8)) // } diff --git a/test/libyul/yulOptimizerTests/fullSuite/name_dependent_cse_bug_part_2.yul b/test/libyul/yulOptimizerTests/fullSuite/name_dependent_cse_bug_part_2.yul index 879f84834e96..7e0384e1ab87 100644 --- a/test/libyul/yulOptimizerTests/fullSuite/name_dependent_cse_bug_part_2.yul +++ b/test/libyul/yulOptimizerTests/fullSuite/name_dependent_cse_bug_part_2.yul @@ -35,8 +35,8 @@ // let a := 0 // for { } a { } // { -// let _1 := add(a, a) -// let var := add(_1, _1) +// let _2 := add(a, a) +// let var := add(_2, _2) // switch a // case 0 { a := var } // default { sstore(0, var) } diff --git a/test/libyul/yulOptimizerTests/fullSuite/name_dependent_cse_bug_part_2_pre_shanghai.yul b/test/libyul/yulOptimizerTests/fullSuite/name_dependent_cse_bug_part_2_pre_shanghai.yul index 3161dc2efac4..f8e14d95ab02 100644 --- a/test/libyul/yulOptimizerTests/fullSuite/name_dependent_cse_bug_part_2_pre_shanghai.yul +++ b/test/libyul/yulOptimizerTests/fullSuite/name_dependent_cse_bug_part_2_pre_shanghai.yul @@ -35,8 +35,8 @@ // let a := 0 // for { } a { } // { -// let _1 := add(a, a) -// let var := add(_1, _1) +// let _2 := add(a, a) +// let var := add(_2, _2) // switch a // case 0 { a := var } // default { sstore(0, var) } diff --git a/test/libyul/yulOptimizerTests/fullSuite/reserved_identifiers.yul b/test/libyul/yulOptimizerTests/fullSuite/reserved_identifiers.yul index e8ddcf98539c..afc9c7c1349a 100644 --- a/test/libyul/yulOptimizerTests/fullSuite/reserved_identifiers.yul +++ b/test/libyul/yulOptimizerTests/fullSuite/reserved_identifiers.yul @@ -17,16 +17,19 @@ // { // { // let dataoffset_ := datasize_(7) -// sstore(dataoffset_, g(9)) +// sstore(dataoffset_, g_(9)) // } -// function g(x) -> z +// function g_(x) -> z_ // { -// if calldataload(1) { z := g(x) } -// sstore(z, calldataload(add(x, 1))) +// if calldataload(1) { z_ := g_(x) } +// sstore(z_, calldataload(add(x, 1))) // } -// function datasize_(x) -> linkersymbol_ +// function datasize_(x_1) -> linkersymbol_ // { -// if calldataload(0) { linkersymbol_ := datasize_(x) } +// if calldataload(0) +// { +// linkersymbol_ := datasize_(x_1) +// } // sstore(linkersymbol_, calldataload(linkersymbol_)) // } // } diff --git a/test/libyul/yulOptimizerTests/fullSuite/ssaReverse.yul b/test/libyul/yulOptimizerTests/fullSuite/ssaReverse.yul index a7ecc0e46ba1..066d977e7f5f 100644 --- a/test/libyul/yulOptimizerTests/fullSuite/ssaReverse.yul +++ b/test/libyul/yulOptimizerTests/fullSuite/ssaReverse.yul @@ -36,21 +36,21 @@ // // { // { -// let a, b := abi_decode_bytes_calldata(mload(0), mload(1)) -// let a_1, b_1 := abi_decode_bytes_calldata(a, b) -// let a_2, b_2 := abi_decode_bytes_calldata(a_1, b_1) -// let a_3, b_3 := abi_decode_bytes_calldata(a_2, b_2) -// let a_4, b_4 := abi_decode_bytes_calldata(a_3, b_3) -// let a_5, b_5 := abi_decode_bytes_calldata(a_4, b_4) -// let a_6, b_6 := abi_decode_bytes_calldata(a_5, b_5) +// let a, b := abi_decode_t_bytes_calldata_ptr(mload(0), mload(1)) +// let a_1, b_1 := abi_decode_t_bytes_calldata_ptr(a, b) +// let a_2, b_2 := abi_decode_t_bytes_calldata_ptr(a_1, b_1) +// let a_3, b_3 := abi_decode_t_bytes_calldata_ptr(a_2, b_2) +// let a_4, b_4 := abi_decode_t_bytes_calldata_ptr(a_3, b_3) +// let a_5, b_5 := abi_decode_t_bytes_calldata_ptr(a_4, b_4) +// let a_6, b_6 := abi_decode_t_bytes_calldata_ptr(a_5, b_5) // sstore(a_6, b_6) // } -// function abi_decode_bytes_calldata(offset, end) -> arrayPos, length +// function abi_decode_t_bytes_calldata_ptr(offset_12, end_13) -> arrayPos_14, length_15 // { -// if iszero(slt(add(offset, 0x1f), end)) { revert(0, 0) } -// length := calldataload(offset) -// if gt(length, 0xffffffffffffffff) { revert(0, 0) } -// arrayPos := add(offset, 0x20) -// if gt(add(add(offset, length), 0x20), end) { revert(0, 0) } +// if iszero(slt(add(offset_12, 0x1f), end_13)) { revert(0, 0) } +// length_15 := calldataload(offset_12) +// if gt(length_15, 0xffffffffffffffff) { revert(0, 0) } +// arrayPos_14 := add(offset_12, 0x20) +// if gt(add(add(offset_12, length_15), 0x20), end_13) { revert(0, 0) } // } // } diff --git a/test/libyul/yulOptimizerTests/fullSuite/stack_compressor_msize.yul b/test/libyul/yulOptimizerTests/fullSuite/stack_compressor_msize.yul index c7eb0a405b80..1ca91e449b82 100644 --- a/test/libyul/yulOptimizerTests/fullSuite/stack_compressor_msize.yul +++ b/test/libyul/yulOptimizerTests/fullSuite/stack_compressor_msize.yul @@ -49,7 +49,7 @@ // mstore(lt(or(gt(1, or(or(gt(or(or(or(gt(or(gt(not(0), _5), 1), _4), _3), _2), 1), 1), _1), 1)), 1), 1), 1) // sstore(not(gcd(10, 15)), 1) // sstore(2, 1) -// foo_singlereturn() +// foo_singlereturn_1() // sstore(0, 0) // sstore(3, 1) // } @@ -59,6 +59,6 @@ // case 0 { out := _a } // default { out := gcd(_b, mod(_a, _b)) } // } -// function foo_singlereturn() +// function foo_singlereturn_1() // { mstore8(msize(), 42) } // } diff --git a/test/libyul/yulOptimizerTests/fullSuite/unusedFunctionParameterPruner.yul b/test/libyul/yulOptimizerTests/fullSuite/unusedFunctionParameterPruner.yul index 9d893a7d3c5c..89f14971cb79 100644 --- a/test/libyul/yulOptimizerTests/fullSuite/unusedFunctionParameterPruner.yul +++ b/test/libyul/yulOptimizerTests/fullSuite/unusedFunctionParameterPruner.yul @@ -19,9 +19,9 @@ // // { // { -// let out1, out2 := foo(sload(32)) -// sstore(0, out2) -// let out1_1, out2_1 := foo(sload(8)) +// let out1_1, out2_1 := foo(sload(32)) +// sstore(0, out2_1) +// let out1_2, out2_2 := foo(sload(8)) // } // function foo(b) -> out1, out2 // { diff --git a/test/libyul/yulOptimizerTests/fullSuite/unusedFunctionParameterPruner_recursion.yul b/test/libyul/yulOptimizerTests/fullSuite/unusedFunctionParameterPruner_recursion.yul index 92d251cabe1a..4420949c551f 100644 --- a/test/libyul/yulOptimizerTests/fullSuite/unusedFunctionParameterPruner_recursion.yul +++ b/test/libyul/yulOptimizerTests/fullSuite/unusedFunctionParameterPruner_recursion.yul @@ -16,9 +16,9 @@ // // { // { -// let x, y, z := f() -// sstore(0, x) -// sstore(1, z) +// let x_2, y_2, z_2 := f() +// sstore(0, x_2) +// sstore(1, z_2) // } // function f() -> x, y, z // { diff --git a/test/libyul/yulOptimizerTests/fullSuite/unusedFunctionParameterPruner_return.yul b/test/libyul/yulOptimizerTests/fullSuite/unusedFunctionParameterPruner_return.yul index f95e6f30dcc3..936ecf12509f 100644 --- a/test/libyul/yulOptimizerTests/fullSuite/unusedFunctionParameterPruner_return.yul +++ b/test/libyul/yulOptimizerTests/fullSuite/unusedFunctionParameterPruner_return.yul @@ -23,9 +23,9 @@ // // { // { -// let out1, out2 := foo(sload(32)) +// let out1_1, out2_1 := foo(sload(32)) // sstore(0, 0) -// let out1_1, out2_1 := foo(sload(8)) +// let out1_2, out2_2 := foo(sload(8)) // } // function foo(b) -> out1, out2 // { diff --git a/test/libyul/yulOptimizerTests/functionSpecializer/multiple.yul b/test/libyul/yulOptimizerTests/functionSpecializer/multiple.yul index d4df4053729c..ea6b958e136e 100644 --- a/test/libyul/yulOptimizerTests/functionSpecializer/multiple.yul +++ b/test/libyul/yulOptimizerTests/functionSpecializer/multiple.yul @@ -21,14 +21,14 @@ // f(calldataload(0), calldataload(1)) // function f_1() // { -// let a_4 := 1 -// let b_3 := 2 -// sstore(a_4, b_3) +// let a_1 := 1 +// let b_1 := 2 +// sstore(a_1, b_1) // } -// function f_2(a_6) +// function f_2(a_2) // { -// let b_5 := 2 -// sstore(a_6, b_5) +// let b_2 := 2 +// sstore(a_2, b_2) // } // function f(a, b) // { sstore(a, b) } diff --git a/test/libyul/yulOptimizerTests/functionSpecializer/partial.yul b/test/libyul/yulOptimizerTests/functionSpecializer/partial.yul index 6b18da019dea..793a47b46424 100644 --- a/test/libyul/yulOptimizerTests/functionSpecializer/partial.yul +++ b/test/libyul/yulOptimizerTests/functionSpecializer/partial.yul @@ -16,12 +16,12 @@ // { // let x := 2 // f_1(x) -// function f_1(b_3) +// function f_1(b_1) // { -// let a_4 := 1 -// let c_2 := 3 -// sstore(a_4, b_3) -// sstore(b_3, c_2) +// let a_1 := 1 +// let c_1 := 3 +// sstore(a_1, b_1) +// sstore(b_1, c_1) // if calldataload(0) { leave } // } // function f(a, b, c) diff --git a/test/libyul/yulOptimizerTests/functionSpecializer/simple.yul b/test/libyul/yulOptimizerTests/functionSpecializer/simple.yul index 3ec298ebd953..c46fee77528c 100644 --- a/test/libyul/yulOptimizerTests/functionSpecializer/simple.yul +++ b/test/libyul/yulOptimizerTests/functionSpecializer/simple.yul @@ -14,11 +14,11 @@ // f_1() // function f_1() // { -// let a_4 := 1 -// let b_3 := 2 -// let c_2 := 3 -// sstore(a_4, b_3) -// sstore(b_3, c_2) +// let a_1 := 1 +// let b_1 := 2 +// let c_1 := 3 +// sstore(a_1, b_1) +// sstore(b_1, c_1) // } // function f(a, b, c) // { diff --git a/test/libyul/yulOptimizerTests/loadResolver/keccak_reuse_expr_mstore.yul b/test/libyul/yulOptimizerTests/loadResolver/keccak_reuse_expr_mstore.yul index 7b37f8c95f58..9cf18437837e 100644 --- a/test/libyul/yulOptimizerTests/loadResolver/keccak_reuse_expr_mstore.yul +++ b/test/libyul/yulOptimizerTests/loadResolver/keccak_reuse_expr_mstore.yul @@ -16,10 +16,10 @@ // { // let _1 := 0 // let a := calldataload(_1) +// let _2 := keccak256(_1, a) +// sstore(f(_2), _2) // let _3 := keccak256(_1, a) // sstore(f(_3), _3) -// let _8 := keccak256(_1, a) -// sstore(f(_8), _8) // sstore(keccak256(_1, a), f(keccak256(_1, a))) // } // function f(x) -> y diff --git a/test/libyul/yulOptimizerTests/loadResolver/keccak_reuse_in_expression.yul b/test/libyul/yulOptimizerTests/loadResolver/keccak_reuse_in_expression.yul index f4d37d90e7b8..7d3391b39c6d 100644 --- a/test/libyul/yulOptimizerTests/loadResolver/keccak_reuse_in_expression.yul +++ b/test/libyul/yulOptimizerTests/loadResolver/keccak_reuse_in_expression.yul @@ -8,7 +8,7 @@ // { // { // let _1 := 0 -// let _3 := keccak256(_1, calldataload(_1)) -// sstore(_3, _3) +// let _2 := keccak256(_1, calldataload(_1)) +// sstore(_2, _2) // } // } diff --git a/test/libyul/yulOptimizerTests/loadResolver/keccak_reuse_reassigned_branch.yul b/test/libyul/yulOptimizerTests/loadResolver/keccak_reuse_reassigned_branch.yul index b780d62b0a18..bba48b0e2566 100644 --- a/test/libyul/yulOptimizerTests/loadResolver/keccak_reuse_reassigned_branch.yul +++ b/test/libyul/yulOptimizerTests/loadResolver/keccak_reuse_reassigned_branch.yul @@ -26,12 +26,12 @@ // let x := calldataload(0) // let y := calldataload(1) // let a := keccak256(x, y) -// let _3 := 2 -// if calldataload(_3) { a := 8 } -// sstore(keccak256(x, y), _3) +// let _1 := 2 +// if calldataload(_1) { a := 8 } +// sstore(keccak256(x, y), _1) // if calldataload(3) { x := 8 } -// sstore(keccak256(x, y), _3) +// sstore(keccak256(x, y), _1) // if calldataload(4) { y := 8 } -// sstore(keccak256(x, y), _3) +// sstore(keccak256(x, y), _1) // } // } diff --git a/test/libyul/yulOptimizerTests/loadResolver/keccak_reuse_reassigned_value.yul b/test/libyul/yulOptimizerTests/loadResolver/keccak_reuse_reassigned_value.yul index 232d76f14575..d18fb365c49b 100644 --- a/test/libyul/yulOptimizerTests/loadResolver/keccak_reuse_reassigned_value.yul +++ b/test/libyul/yulOptimizerTests/loadResolver/keccak_reuse_reassigned_value.yul @@ -28,13 +28,13 @@ // let y := calldataload(1) // let a := keccak256(x, y) // sstore(a, 2) -// let _4 := 10 -// a := calldataload(_4) +// let _1 := 10 +// a := calldataload(_1) // sstore(keccak256(x, y), 3) -// x := _4 -// sstore(keccak256(_4, y), 4) +// x := _1 +// sstore(keccak256(_1, y), 4) // y := 9 -// let d := keccak256(_4, y) +// let d := keccak256(_1, y) // sstore(d, 5) // sstore(d, 6) // } diff --git a/test/libyul/yulOptimizerTests/loadResolver/keccak_short.yul b/test/libyul/yulOptimizerTests/loadResolver/keccak_short.yul index 58cb7c264ce9..85bba886c4b3 100644 --- a/test/libyul/yulOptimizerTests/loadResolver/keccak_short.yul +++ b/test/libyul/yulOptimizerTests/loadResolver/keccak_short.yul @@ -25,9 +25,9 @@ // mstore(_2, _1) // sstore(_2, 9948786400348073077032572701554570401043517428989726124163377057770909578447) // sstore(1, 110945455955148346822663466543669633859020391897956790847617069135813044810108) -// let _13 := 85131057757245807317576516368191972321038229705283732634690444270750521936266 -// let _14 := 2 -// sstore(_14, _13) -// sstore(_14, 89477152217924674838424037953991966239322087453347756267410168184682657981552) +// let _3 := 85131057757245807317576516368191972321038229705283732634690444270750521936266 +// let _4 := 2 +// sstore(_4, _3) +// sstore(_4, 89477152217924674838424037953991966239322087453347756267410168184682657981552) // } // } diff --git a/test/libyul/yulOptimizerTests/loadResolver/memory_with_call_invalidation.yul b/test/libyul/yulOptimizerTests/loadResolver/memory_with_call_invalidation.yul index 88d0ba64db73..0e161ec0654b 100644 --- a/test/libyul/yulOptimizerTests/loadResolver/memory_with_call_invalidation.yul +++ b/test/libyul/yulOptimizerTests/loadResolver/memory_with_call_invalidation.yul @@ -14,10 +14,10 @@ // let _1 := 9 // let _2 := 2 // mstore(_2, _1) -// let _4 := _1 -// let _5 := 0 -// sstore(_5, _4) -// pop(call(_5, _5, _5, _5, _5, _5, _5)) -// sstore(_5, mload(_2)) +// let _3 := _1 +// let _4 := 0 +// sstore(_4, _3) +// pop(call(_4, _4, _4, _4, _4, _4, _4)) +// sstore(_4, mload(_2)) // } // } diff --git a/test/libyul/yulOptimizerTests/loadResolver/memory_with_extcall_invalidation.yul b/test/libyul/yulOptimizerTests/loadResolver/memory_with_extcall_invalidation.yul index 55c131677f5a..99bae207525b 100644 --- a/test/libyul/yulOptimizerTests/loadResolver/memory_with_extcall_invalidation.yul +++ b/test/libyul/yulOptimizerTests/loadResolver/memory_with_extcall_invalidation.yul @@ -13,10 +13,10 @@ // { // let _1 := 9 // mstore(2, _1) -// let _4 := _1 -// let _5 := 0 -// sstore(_5, _4) -// pop(extcall(_5, _5, _5, _5)) -// sstore(_5, _1) +// let _2 := _1 +// let _3 := 0 +// sstore(_3, _2) +// pop(extcall(_3, _3, _3, _3)) +// sstore(_3, _1) // } // } diff --git a/test/libyul/yulOptimizerTests/loadResolver/memory_with_msize.yul b/test/libyul/yulOptimizerTests/loadResolver/memory_with_msize.yul index f54053bb10f2..6486599a5dc3 100644 --- a/test/libyul/yulOptimizerTests/loadResolver/memory_with_msize.yul +++ b/test/libyul/yulOptimizerTests/loadResolver/memory_with_msize.yul @@ -11,9 +11,9 @@ // { // { // let _1 := msize() -// let _3 := calldataload(0) -// mstore(_3, _1) +// let _2 := calldataload(0) +// mstore(_2, _1) // let t := mload(calldataload(10)) -// sstore(t, mload(_3)) +// sstore(t, mload(_2)) // } // } diff --git a/test/libyul/yulOptimizerTests/loadResolver/merge_known_write.yul b/test/libyul/yulOptimizerTests/loadResolver/merge_known_write.yul index acb96c07b102..0576874b1fd4 100644 --- a/test/libyul/yulOptimizerTests/loadResolver/merge_known_write.yul +++ b/test/libyul/yulOptimizerTests/loadResolver/merge_known_write.yul @@ -12,13 +12,13 @@ // // { // { -// let _2 := calldataload(10) -// let _3 := 0 -// let _4 := calldataload(_3) -// mstore(_4, _2) -// let _5 := 1 -// if calldataload(_5) { mstore(_4, _5) } -// let t := mload(_3) -// sstore(t, mload(_4)) +// let _1 := calldataload(10) +// let _2 := 0 +// let _3 := calldataload(_2) +// mstore(_3, _1) +// let _4 := 1 +// if calldataload(_4) { mstore(_3, _4) } +// let t := mload(_2) +// sstore(t, mload(_3)) // } // } diff --git a/test/libyul/yulOptimizerTests/loadResolver/merge_known_write_with_distance.yul b/test/libyul/yulOptimizerTests/loadResolver/merge_known_write_with_distance.yul index 1659949a3caf..47ce59a7973c 100644 --- a/test/libyul/yulOptimizerTests/loadResolver/merge_known_write_with_distance.yul +++ b/test/libyul/yulOptimizerTests/loadResolver/merge_known_write_with_distance.yul @@ -12,11 +12,11 @@ // // { // { -// let _2 := calldataload(10) -// let _4 := calldataload(0) -// mstore(_4, _2) -// let _5 := 1 -// if calldataload(_5) { mstore(add(_4, 0x20), _5) } -// sstore(mload(add(_4, 0x20)), _2) +// let _1 := calldataload(10) +// let _2 := calldataload(0) +// mstore(_2, _1) +// let _3 := 1 +// if calldataload(_3) { mstore(add(_2, 0x20), _3) } +// sstore(mload(add(_2, 0x20)), _1) // } // } diff --git a/test/libyul/yulOptimizerTests/loadResolver/merge_mload_with_known_distance.yul b/test/libyul/yulOptimizerTests/loadResolver/merge_mload_with_known_distance.yul index 18740c049095..6497224dcd66 100644 --- a/test/libyul/yulOptimizerTests/loadResolver/merge_mload_with_known_distance.yul +++ b/test/libyul/yulOptimizerTests/loadResolver/merge_mload_with_known_distance.yul @@ -12,10 +12,10 @@ // // { // { -// let _2 := calldataload(0) -// let x := mload(_2) -// let _3 := 1 -// if calldataload(_3) { mstore(add(_2, 0x20), _3) } -// sstore(mload(add(_2, 0x20)), x) +// let _1 := calldataload(0) +// let x := mload(_1) +// let _2 := 1 +// if calldataload(_2) { mstore(add(_1, 0x20), _2) } +// sstore(mload(add(_1, 0x20)), x) // } // } diff --git a/test/libyul/yulOptimizerTests/loadResolver/merge_unknown_write.yul b/test/libyul/yulOptimizerTests/loadResolver/merge_unknown_write.yul index e8cc3cf4b010..6c73872e34fb 100644 --- a/test/libyul/yulOptimizerTests/loadResolver/merge_unknown_write.yul +++ b/test/libyul/yulOptimizerTests/loadResolver/merge_unknown_write.yul @@ -12,13 +12,13 @@ // // { // { -// let _2 := calldataload(10) -// let _3 := 0 -// let _4 := calldataload(_3) -// mstore(_4, _2) -// let _5 := 1 -// if calldataload(_5) { mstore(_3, _5) } -// let t := mload(_3) -// sstore(t, mload(_4)) +// let _1 := calldataload(10) +// let _2 := 0 +// let _3 := calldataload(_2) +// mstore(_3, _1) +// let _4 := 1 +// if calldataload(_4) { mstore(_2, _4) } +// let t := mload(_2) +// sstore(t, mload(_3)) // } // } diff --git a/test/libyul/yulOptimizerTests/loadResolver/mload_in_function.yul b/test/libyul/yulOptimizerTests/loadResolver/mload_in_function.yul index b76d071ae8f2..b33b0e61acf9 100644 --- a/test/libyul/yulOptimizerTests/loadResolver/mload_in_function.yul +++ b/test/libyul/yulOptimizerTests/loadResolver/mload_in_function.yul @@ -22,9 +22,9 @@ // for { } // x // { -// let _7 := 0 -// x := mload(_7) -// mstore(_7, _7) +// let _3 := 0 +// x := mload(_3) +// mstore(_3, _3) // } // { } // } diff --git a/test/libyul/yulOptimizerTests/loadResolver/mstore_in_function_loop_body.yul b/test/libyul/yulOptimizerTests/loadResolver/mstore_in_function_loop_body.yul index 901ea12efc8c..5752be65878d 100644 --- a/test/libyul/yulOptimizerTests/loadResolver/mstore_in_function_loop_body.yul +++ b/test/libyul/yulOptimizerTests/loadResolver/mstore_in_function_loop_body.yul @@ -29,8 +29,8 @@ // for { } // userNot(x_1) // { -// let _7 := 0 -// mstore(_7, _7) +// let _3 := 0 +// mstore(_3, _3) // } // { } // } diff --git a/test/libyul/yulOptimizerTests/loadResolver/mstore_in_function_loop_init.yul b/test/libyul/yulOptimizerTests/loadResolver/mstore_in_function_loop_init.yul index 6fb0fdcba99a..c986e65fdada 100644 --- a/test/libyul/yulOptimizerTests/loadResolver/mstore_in_function_loop_init.yul +++ b/test/libyul/yulOptimizerTests/loadResolver/mstore_in_function_loop_init.yul @@ -26,8 +26,8 @@ // { y := iszero(x) } // function funcWithLoop(x_1) // { -// let _7 := 0 -// mstore(_7, _7) +// let _3 := 0 +// mstore(_3, _3) // for { } userNot(x_1) { } // { } // } diff --git a/test/libyul/yulOptimizerTests/loadResolver/multi_sload_loop.yul b/test/libyul/yulOptimizerTests/loadResolver/multi_sload_loop.yul index c367059eb90c..40673c5d753b 100644 --- a/test/libyul/yulOptimizerTests/loadResolver/multi_sload_loop.yul +++ b/test/libyul/yulOptimizerTests/loadResolver/multi_sload_loop.yul @@ -19,7 +19,7 @@ // let x := calldataload(_1) // let len := sload(x) // let sum -// let i := _1 +// let i := sum // for { } lt(i, len) { i := add(i, 1) } // { // let p := add(add(x, i), 1) diff --git a/test/libyul/yulOptimizerTests/loadResolver/reassign_value_expression.yul b/test/libyul/yulOptimizerTests/loadResolver/reassign_value_expression.yul index 402987acb4ae..30c3b988bba5 100644 --- a/test/libyul/yulOptimizerTests/loadResolver/reassign_value_expression.yul +++ b/test/libyul/yulOptimizerTests/loadResolver/reassign_value_expression.yul @@ -21,14 +21,14 @@ // { // let x := calldataload(1) // let a := add(x, 10) -// let _3 := 7 -// sstore(a, _3) +// let _1 := 7 +// sstore(a, _1) // x := 9 -// let _4 := 11 -// mstore(_3, _4) +// let _2 := 11 +// mstore(_1, _2) // a := 33 -// mstore(sload(a), _4) +// mstore(sload(a), _2) // a := 39 -// mstore(sload(a), _4) +// mstore(sload(a), _2) // } // } diff --git a/test/libyul/yulOptimizerTests/loadResolver/second_mstore_with_delta.yul b/test/libyul/yulOptimizerTests/loadResolver/second_mstore_with_delta.yul index 8f1cf338f66d..c1473cc6e804 100644 --- a/test/libyul/yulOptimizerTests/loadResolver/second_mstore_with_delta.yul +++ b/test/libyul/yulOptimizerTests/loadResolver/second_mstore_with_delta.yul @@ -17,10 +17,10 @@ // let x := calldataload(1) // let a := add(x, 10) // let b := add(x, 42) -// let _4 := 7 -// mstore(a, _4) -// let _5 := 8 -// mstore(b, _5) -// sstore(_4, _5) +// let _1 := 7 +// mstore(a, _1) +// let _2 := 8 +// mstore(b, _2) +// sstore(_1, _2) // } // } diff --git a/test/libyul/yulOptimizerTests/loadResolver/second_store.yul b/test/libyul/yulOptimizerTests/loadResolver/second_store.yul index eb960a9f6e5c..6b1ce65ca03a 100644 --- a/test/libyul/yulOptimizerTests/loadResolver/second_store.yul +++ b/test/libyul/yulOptimizerTests/loadResolver/second_store.yul @@ -13,9 +13,9 @@ // { // let x := calldataload(1) // sstore(x, 7) -// let _3 := 6 -// let _4 := 0 -// sstore(calldataload(_4), _3) -// mstore(_4, sload(x)) +// let _1 := 6 +// let _2 := 0 +// sstore(calldataload(_2), _1) +// mstore(_2, sload(x)) // } // } diff --git a/test/libyul/yulOptimizerTests/loadResolver/second_store_same_value.yul b/test/libyul/yulOptimizerTests/loadResolver/second_store_same_value.yul index e13b8aa5f64f..88fc5aeb7865 100644 --- a/test/libyul/yulOptimizerTests/loadResolver/second_store_same_value.yul +++ b/test/libyul/yulOptimizerTests/loadResolver/second_store_same_value.yul @@ -12,10 +12,10 @@ // { // { // let x := calldataload(1) -// let _2 := 7 -// sstore(x, _2) -// let _4 := 0 -// sstore(calldataload(_4), _2) -// mstore(_4, _2) +// let _1 := 7 +// sstore(x, _1) +// let _2 := 0 +// sstore(calldataload(_2), _1) +// mstore(_2, _1) // } // } diff --git a/test/libyul/yulOptimizerTests/loadResolver/second_store_with_delta.yul b/test/libyul/yulOptimizerTests/loadResolver/second_store_with_delta.yul index f301737ecaa1..e180e339862e 100644 --- a/test/libyul/yulOptimizerTests/loadResolver/second_store_with_delta.yul +++ b/test/libyul/yulOptimizerTests/loadResolver/second_store_with_delta.yul @@ -17,10 +17,10 @@ // let x := calldataload(1) // let a := add(x, 10) // let b := add(x, 20) -// let _4 := 7 -// sstore(a, _4) -// let _5 := 8 -// sstore(b, _5) -// mstore(_4, _5) +// let _1 := 7 +// sstore(a, _1) +// let _2 := 8 +// sstore(b, _2) +// mstore(_1, _2) // } // } diff --git a/test/libyul/yulOptimizerTests/loadResolver/side_effects_of_user_functions.yul b/test/libyul/yulOptimizerTests/loadResolver/side_effects_of_user_functions.yul index b1eefd0890d6..72ab69ea5d31 100644 --- a/test/libyul/yulOptimizerTests/loadResolver/side_effects_of_user_functions.yul +++ b/test/libyul/yulOptimizerTests/loadResolver/side_effects_of_user_functions.yul @@ -17,11 +17,11 @@ // let _2 := 2 // mstore(_2, _1) // reads() -// let _4 := _1 -// let _5 := 0 -// sstore(_5, _4) +// let _3 := _1 +// let _4 := 0 +// sstore(_4, _3) // stores() -// sstore(_5, mload(_2)) +// sstore(_4, mload(_2)) // } // function stores() // { mstore(0, 1) } diff --git a/test/libyul/yulOptimizerTests/loadResolver/simple.yul b/test/libyul/yulOptimizerTests/loadResolver/simple.yul index a20025bcdf09..3a2990a78f73 100644 --- a/test/libyul/yulOptimizerTests/loadResolver/simple.yul +++ b/test/libyul/yulOptimizerTests/loadResolver/simple.yul @@ -9,8 +9,8 @@ // // { // { -// let _2 := calldataload(10) -// sstore(calldataload(0), _2) -// mstore(sload(_2), _2) +// let _1 := calldataload(10) +// sstore(calldataload(0), _1) +// mstore(sload(_1), _1) // } // } diff --git a/test/libyul/yulOptimizerTests/loadResolver/simple_memory.yul b/test/libyul/yulOptimizerTests/loadResolver/simple_memory.yul index 3aa1d740f496..32dc5f590731 100644 --- a/test/libyul/yulOptimizerTests/loadResolver/simple_memory.yul +++ b/test/libyul/yulOptimizerTests/loadResolver/simple_memory.yul @@ -9,8 +9,8 @@ // // { // { -// let _2 := calldataload(10) -// mstore(calldataload(0), _2) -// sstore(mload(_2), _2) +// let _1 := calldataload(10) +// mstore(calldataload(0), _1) +// sstore(mload(_1), _1) // } // } diff --git a/test/libyul/yulOptimizerTests/loadResolver/verbatim_sload.yul b/test/libyul/yulOptimizerTests/loadResolver/verbatim_sload.yul index 81479a509249..ffe3292783b0 100644 --- a/test/libyul/yulOptimizerTests/loadResolver/verbatim_sload.yul +++ b/test/libyul/yulOptimizerTests/loadResolver/verbatim_sload.yul @@ -14,10 +14,10 @@ // let _1 := 20 // let _2 := 10 // sstore(_2, _1) -// let _4 := _1 -// let _5 := 30 -// sstore(_5, _4) +// let _3 := _1 +// let _4 := 30 +// sstore(_4, _3) // verbatim_0i_0o("test") -// sstore(_5, sload(_2)) +// sstore(_4, sload(_2)) // } // } diff --git a/test/libyul/yulOptimizerTests/loopInvariantCodeMotion/no_move_memory.yul b/test/libyul/yulOptimizerTests/loopInvariantCodeMotion/no_move_memory.yul index 486921ae6304..4b0c7bca7a7f 100644 --- a/test/libyul/yulOptimizerTests/loopInvariantCodeMotion/no_move_memory.yul +++ b/test/libyul/yulOptimizerTests/loopInvariantCodeMotion/no_move_memory.yul @@ -28,11 +28,11 @@ // mstore(a, inv) // } // let a_1 := 1 -// let inv_2 := add(b, 42) +// let inv_1 := add(b, 42) // for { } iszero(eq(a_1, 10)) { a_1 := add(a_1, 1) } // { -// let x_3 := balance(mload(mul(inv_2, 3))) -// a_1 := add(x_3, 1) -// mstore(a_1, inv_2) +// let x_1 := balance(mload(mul(inv_1, 3))) +// a_1 := add(x_1, 1) +// mstore(a_1, inv_1) // } // } diff --git a/test/libyul/yulOptimizerTests/loopInvariantCodeMotion/no_move_memory_msize.yul b/test/libyul/yulOptimizerTests/loopInvariantCodeMotion/no_move_memory_msize.yul index 95f968d89195..153420e39999 100644 --- a/test/libyul/yulOptimizerTests/loopInvariantCodeMotion/no_move_memory_msize.yul +++ b/test/libyul/yulOptimizerTests/loopInvariantCodeMotion/no_move_memory_msize.yul @@ -26,10 +26,10 @@ // a := add(x, 1) // } // let a_1 := 1 -// let inv_2 := add(b, 42) +// let inv_1 := add(b, 42) // for { } iszero(eq(a_1, 10)) { a_1 := add(a_1, 1) } // { -// let x_3 := balance(mload(mul(inv_2, 3))) -// a_1 := add(x_3, 1) +// let x_1 := balance(mload(mul(inv_1, 3))) +// a_1 := add(x_1, 1) // } // } diff --git a/test/libyul/yulOptimizerTests/loopInvariantCodeMotion/no_move_state.yul b/test/libyul/yulOptimizerTests/loopInvariantCodeMotion/no_move_state.yul index c2ea86bc82f0..b4e687c4ef65 100644 --- a/test/libyul/yulOptimizerTests/loopInvariantCodeMotion/no_move_state.yul +++ b/test/libyul/yulOptimizerTests/loopInvariantCodeMotion/no_move_state.yul @@ -45,20 +45,20 @@ // mstore(a, inv) // } // let a_1 := 1 -// let inv_2 := add(b, 42) +// let inv_1 := add(b, 42) // for { } iszero(eq(a_1, 10)) { a_1 := add(a_1, 1) } // { // pop(create(0x08, 0x00, 0x02)) -// let x_3 := extcodesize(mul(inv_2, 3)) -// a_1 := add(x_3, 1) -// mstore(a_1, inv_2) +// let x_1 := extcodesize(mul(inv_1, 3)) +// a_1 := add(x_1, 1) +// mstore(a_1, inv_1) // } -// let a_4 := 1 -// let inv_5 := add(b, 42) -// for { } iszero(create(0x08, 0x00, 0x02)) { a_4 := add(a_4, 1) } +// let a_2 := 1 +// let inv_2 := add(b, 42) +// for { } iszero(create(0x08, 0x00, 0x02)) { a_2 := add(a_2, 1) } // { -// let x_6 := extcodesize(mul(inv_5, 3)) -// a_4 := add(x_6, 1) -// mstore(a_4, inv_5) +// let x_2 := extcodesize(mul(inv_2, 3)) +// a_2 := add(x_2, 1) +// mstore(a_2, inv_2) // } // } diff --git a/test/libyul/yulOptimizerTests/nameDisplacer/funtion_call.yul b/test/libyul/yulOptimizerTests/nameDisplacer/funtion_call.yul index 54045ce379f1..ff175331b6db 100644 --- a/test/libyul/yulOptimizerTests/nameDisplacer/funtion_call.yul +++ b/test/libyul/yulOptimizerTests/nameDisplacer/funtion_call.yul @@ -11,15 +11,15 @@ // // { // let x := illegal4_1(1, 2) -// function illegal4_1(illegal1_2, illegal2_3) -> illegal3_4 +// function illegal4_1(illegal1_2, illegal2_2) -> illegal3_2 // { -// illegal3_4 := add(illegal1_2, illegal2_3) +// illegal3_2 := add(illegal1_2, illegal2_2) // } // { -// let y := illegal5_5(3, 4) -// function illegal5_5(illegal1_1, illegal2_2) -> illegal3_3 +// let y := illegal5_1(3, 4) +// function illegal5_1(illegal1_1, illegal2_1) -> illegal3_1 // { -// illegal3_3 := add(illegal1_1, illegal2_2) +// illegal3_1 := add(illegal1_1, illegal2_1) // } // } // } diff --git a/test/libyul/yulOptimizerTests/nameDisplacer/variables.yul b/test/libyul/yulOptimizerTests/nameDisplacer/variables.yul index 08b7bc43121d..208adc19373c 100644 --- a/test/libyul/yulOptimizerTests/nameDisplacer/variables.yul +++ b/test/libyul/yulOptimizerTests/nameDisplacer/variables.yul @@ -5,7 +5,7 @@ // { // { let illegal1_1 := 1 } // { -// let illegal2_2 := 2 -// let illegal3_3, illegal4_4 +// let illegal2_1 := 2 +// let illegal3_1, illegal4_1 // } // } diff --git a/test/libyul/yulOptimizerTests/nameDisplacer/variables_inside_functions.yul b/test/libyul/yulOptimizerTests/nameDisplacer/variables_inside_functions.yul index 472aa6a33e8f..55171e5f2403 100644 --- a/test/libyul/yulOptimizerTests/nameDisplacer/variables_inside_functions.yul +++ b/test/libyul/yulOptimizerTests/nameDisplacer/variables_inside_functions.yul @@ -8,9 +8,9 @@ // step: nameDisplacer // // { -// function f(illegal1_1, illegal2_2) -> illegal3_3 +// function f(illegal1_1, illegal2_1) -> illegal3_1 // { -// let illegal4_4 := illegal1_1 -// illegal3_3 := add(illegal1_1, illegal2_2) +// let illegal4_1 := illegal1_1 +// illegal3_1 := add(illegal1_1, illegal2_1) // } // } diff --git a/test/libyul/yulOptimizerTests/ssaAndBack/for_loop.yul b/test/libyul/yulOptimizerTests/ssaAndBack/for_loop.yul index 19b3ba44ea02..e917705c29d6 100644 --- a/test/libyul/yulOptimizerTests/ssaAndBack/for_loop.yul +++ b/test/libyul/yulOptimizerTests/ssaAndBack/for_loop.yul @@ -24,8 +24,8 @@ // let b := mload(1) // for { } lt(mload(a), mload(b)) { a := mload(b) } // { -// let b_4 := mload(a) -// a := mload(b_4) +// let b_1 := mload(a) +// a := mload(b_1) // b := mload(a) // } // } diff --git a/test/libyul/yulOptimizerTests/ssaAndBack/multi_assign.yul b/test/libyul/yulOptimizerTests/ssaAndBack/multi_assign.yul index 1bfd89cd8384..9703e4679dfb 100644 --- a/test/libyul/yulOptimizerTests/ssaAndBack/multi_assign.yul +++ b/test/libyul/yulOptimizerTests/ssaAndBack/multi_assign.yul @@ -11,7 +11,7 @@ // // { // { -// let a_5 := mload(4) -// mstore(a_5, 0) +// let a := mload(4) +// mstore(a, 0) // } // } diff --git a/test/libyul/yulOptimizerTests/ssaAndBack/multi_assign_multi_var_if.yul b/test/libyul/yulOptimizerTests/ssaAndBack/multi_assign_multi_var_if.yul index e3a671028207..9bc1231838ca 100644 --- a/test/libyul/yulOptimizerTests/ssaAndBack/multi_assign_multi_var_if.yul +++ b/test/libyul/yulOptimizerTests/ssaAndBack/multi_assign_multi_var_if.yul @@ -18,9 +18,9 @@ // let b := mload(1) // if mload(2) // { -// let a_3 := mload(b) -// let b_4 := mload(a_3) -// a := mload(b_4) +// let a_1 := mload(b) +// let b_1 := mload(a_1) +// a := mload(b_1) // b := mload(a) // } // mstore(a, b) diff --git a/test/libyul/yulOptimizerTests/ssaAndBack/multi_assign_multi_var_switch.yul b/test/libyul/yulOptimizerTests/ssaAndBack/multi_assign_multi_var_switch.yul index 89f3acaa63c9..f747847f5158 100644 --- a/test/libyul/yulOptimizerTests/ssaAndBack/multi_assign_multi_var_switch.yul +++ b/test/libyul/yulOptimizerTests/ssaAndBack/multi_assign_multi_var_switch.yul @@ -25,15 +25,15 @@ // let b := mload(1) // switch mload(2) // case 0 { -// let a_3 := mload(b) -// let b_4 := mload(a_3) -// a := mload(b_4) +// let a_1 := mload(b) +// let b_1 := mload(a_1) +// a := mload(b_1) // b := mload(a) // } // default { -// let b_7 := mload(a) -// let a_8 := mload(b_7) -// b := mload(a_8) +// let b_2 := mload(a) +// let a_2 := mload(b_2) +// b := mload(a_2) // a := mload(b) // } // mstore(a, b) diff --git a/test/libyul/yulOptimizerTests/ssaAndBack/simple.yul b/test/libyul/yulOptimizerTests/ssaAndBack/simple.yul index b2979e76d2e8..dc315347c51a 100644 --- a/test/libyul/yulOptimizerTests/ssaAndBack/simple.yul +++ b/test/libyul/yulOptimizerTests/ssaAndBack/simple.yul @@ -8,7 +8,7 @@ // // { // { -// let a_2 := mload(1) -// mstore(a_2, 0) +// let a := mload(1) +// mstore(a, 0) // } // } diff --git a/test/libyul/yulOptimizerTests/ssaAndBack/two_vars.yul b/test/libyul/yulOptimizerTests/ssaAndBack/two_vars.yul index 1205993567b2..2a3ad893683b 100644 --- a/test/libyul/yulOptimizerTests/ssaAndBack/two_vars.yul +++ b/test/libyul/yulOptimizerTests/ssaAndBack/two_vars.yul @@ -12,12 +12,12 @@ // // { // { -// let a_1 := mload(0) -// let b_2 := mload(a_1) -// let a_3 := mload(b_2) -// let b_4 := mload(a_3) -// let a_5 := mload(b_4) -// let b_6 := mload(a_5) -// mstore(a_5, b_6) +// let a := mload(0) +// let b := mload(a) +// let a_1 := mload(b) +// let b_1 := mload(a_1) +// let a_2 := mload(b_1) +// let b_2 := mload(a_2) +// mstore(a_2, b_2) // } // } diff --git a/test/libyul/yulOptimizerTests/ssaPlusCleanup/control_structures.yul b/test/libyul/yulOptimizerTests/ssaPlusCleanup/control_structures.yul index 104dc2822ea0..547dddcc5e20 100644 --- a/test/libyul/yulOptimizerTests/ssaPlusCleanup/control_structures.yul +++ b/test/libyul/yulOptimizerTests/ssaPlusCleanup/control_structures.yul @@ -16,25 +16,25 @@ // { // function copy(from, to) -> length // { -// let from_6 := from -// let to_7 := to -// let length_1 := mload(from_6) +// let from_2 := from +// let to_2 := to +// let length_1 := mload(from_2) // length := length_1 -// mstore(to_7, length_1) -// let from_2 := add(from_6, 0x20) -// let to_3 := add(to_7, 0x20) -// let x_4 := 1 -// let x := x_4 +// mstore(to_2, length_1) +// let from_1 := add(from_2, 0x20) +// let to_1 := add(to_2, 0x20) +// let x_1 := 1 +// let x := x_1 // for { } // lt(x, length_1) // { -// let x_9 := x -// let x_5 := add(x_9, 0x20) -// x := x_5 +// let x_4 := x +// let x_2 := add(x_4, 0x20) +// x := x_2 // } // { -// let x_8 := x -// mstore(add(to_3, x_8), mload(add(from_2, x_8))) +// let x_3 := x +// mstore(add(to_1, x_3), mload(add(from_1, x_3))) // } // } // } diff --git a/test/libyul/yulOptimizerTests/ssaTransform/for_def_in_init.yul b/test/libyul/yulOptimizerTests/ssaTransform/for_def_in_init.yul index 40fce8613e27..3ccf8c746093 100644 --- a/test/libyul/yulOptimizerTests/ssaTransform/for_def_in_init.yul +++ b/test/libyul/yulOptimizerTests/ssaTransform/for_def_in_init.yul @@ -13,20 +13,20 @@ // for { } // 1 // { -// let x_7 := x +// let x_4 := x // let x_2 := 2 // x := x_2 // } // { -// let x_5 := x -// let y_3 := 0 -// let y := y_3 +// let x_3 := x +// let y_1 := 0 +// let y := y_1 // for { } // 1 // { -// let y_6 := y -// let y_4 := 6 -// y := y_4 +// let y_3 := y +// let y_2 := 6 +// y := y_2 // } // { } // } diff --git a/test/libyul/yulOptimizerTests/ssaTransform/function.yul b/test/libyul/yulOptimizerTests/ssaTransform/function.yul index 341d18cc12ce..79aa2721fbf0 100644 --- a/test/libyul/yulOptimizerTests/ssaTransform/function.yul +++ b/test/libyul/yulOptimizerTests/ssaTransform/function.yul @@ -12,15 +12,15 @@ // { // function f(a, b) -> c, d // { -// let a_5 := a -// let b_6 := b -// let b_1 := add(b_6, a_5) +// let a_2 := a +// let b_2 := b +// let b_1 := add(b_2, a_2) // b := b_1 -// let c_2 := add(c, b_1) -// c := c_2 -// let d_3 := add(d, c_2) -// d := d_3 -// let a_4 := add(a_5, d_3) -// a := a_4 +// let c_1 := add(c, b_1) +// c := c_1 +// let d_1 := add(d, c_1) +// d := d_1 +// let a_1 := add(a_2, d_1) +// a := a_1 // } // } diff --git a/test/libyul/yulOptimizerTests/ssaTransform/multi_assign.yul b/test/libyul/yulOptimizerTests/ssaTransform/multi_assign.yul index ff4a0eb1de8a..eff6d55dd10d 100644 --- a/test/libyul/yulOptimizerTests/ssaTransform/multi_assign.yul +++ b/test/libyul/yulOptimizerTests/ssaTransform/multi_assign.yul @@ -13,16 +13,16 @@ // { // let a_1 := mload(0) // let a := a_1 -// let b_2 := mload(1) -// let b := b_2 -// let a_3, b_4 := f() +// let b_1 := mload(1) +// let b := b_1 +// let a_2, b_2 := f() +// a := a_2 +// b := b_2 +// sstore(a_2, b_2) +// let a_3 := mload(5) // a := a_3 -// b := b_4 -// sstore(a_3, b_4) -// let a_5 := mload(5) -// a := a_5 -// let b_6 := mload(a_5) -// b := b_6 +// let b_3 := mload(a_3) +// b := b_3 // function f() -> x, y // { } // } diff --git a/test/libyul/yulOptimizerTests/ssaTransform/multi_decl.yul b/test/libyul/yulOptimizerTests/ssaTransform/multi_decl.yul index 06847711e465..da4f2243ec30 100644 --- a/test/libyul/yulOptimizerTests/ssaTransform/multi_decl.yul +++ b/test/libyul/yulOptimizerTests/ssaTransform/multi_decl.yul @@ -10,14 +10,14 @@ // step: ssaTransform // // { -// let x_1, y_2 := f(1, 2) +// let x_1, y_1 := f(1, 2) // let x := x_1 -// let y := y_2 -// let x_3 := mload(y_2) -// x := x_3 -// let y_4 := mload(x_3) -// y := y_4 -// let a, b := f(x_3, y_4) +// let y := y_1 +// let x_2 := mload(y_1) +// x := x_2 +// let y_2 := mload(x_2) +// y := y_2 +// let a, b := f(x_2, y_2) // sstore(a, b) // function f(t, v) -> w, z // { } diff --git a/test/libyul/yulOptimizerTests/ssaTransform/nested.yul b/test/libyul/yulOptimizerTests/ssaTransform/nested.yul index e075f06a2462..b3e9bd21c4ce 100644 --- a/test/libyul/yulOptimizerTests/ssaTransform/nested.yul +++ b/test/libyul/yulOptimizerTests/ssaTransform/nested.yul @@ -18,17 +18,17 @@ // let a := a_1 // let a_2 := 2 // a := a_2 -// let b_3 := 3 -// let b := b_3 -// let b_4 := 4 -// b := b_4 +// let b_1 := 3 +// let b := b_1 +// let b_2 := 4 +// b := b_2 // { -// let a_5 := 3 -// a := a_5 -// let a_6 := 4 -// a := a_6 +// let a_3 := 3 +// a := a_3 +// let a_4 := 4 +// a := a_4 // } -// let a_8 := a -// let a_7 := add(b_4, a_8) -// a := a_7 +// let a_6 := a +// let a_5 := add(b_2, a_6) +// a := a_5 // } diff --git a/test/libyul/yulOptimizerTests/ssaTransform/typed.yul b/test/libyul/yulOptimizerTests/ssaTransform/typed.yul index 4b722e25cc9d..bc1f272471ba 100644 --- a/test/libyul/yulOptimizerTests/ssaTransform/typed.yul +++ b/test/libyul/yulOptimizerTests/ssaTransform/typed.yul @@ -18,23 +18,23 @@ // { // let b_1 := true // let b := b_1 -// let c_2 := false -// let c := c_2 -// let c_3 := b_1 -// c := c_3 -// let b_4 := false -// b := b_4 -// let a_5 := 1 -// let a := a_5 -// let a_6 := add(a_5, 1) -// a := a_6 -// if c_3 +// let c_1 := false +// let c := c_1 +// let c_2 := b_1 +// c := c_2 +// let b_2 := false +// b := b_2 +// let a_1 := 1 +// let a := a_1 +// let a_2 := add(a_1, 1) +// a := a_2 +// if c_2 // { -// let a_7 := add(a_6, 1) -// a := a_7 +// let a_3 := add(a_2, 1) +// a := a_3 // } -// let a_9 := a -// let a_8 := add(a_9, 1) -// a := a_8 -// mstore(a_8, 1) +// let a_5 := a +// let a_4 := add(a_5, 1) +// a := a_4 +// mstore(a_4, 1) // } diff --git a/test/libyul/yulOptimizerTests/stackLimitEvader/cycle_before_2.yul b/test/libyul/yulOptimizerTests/stackLimitEvader/cycle_before_2.yul index 59872e4a75f2..03dd7d647c93 100644 --- a/test/libyul/yulOptimizerTests/stackLimitEvader/cycle_before_2.yul +++ b/test/libyul/yulOptimizerTests/stackLimitEvader/cycle_before_2.yul @@ -66,9 +66,9 @@ // case 0 { v := h(x) } // case 1 { v := g(sub(x, f())) } // } -// function h(x_1) -> v_2 -// { v_2 := g(x_1) } -// function f() -> v_3 +// function h(x_1) -> v_1 +// { v_1 := g(x_1) } +// function f() -> v_2 // { // mstore(0x80, calldataload(mul(1, 4))) // let a2 := calldataload(mul(2, 4)) diff --git a/test/libyul/yulOptimizerTests/stackLimitEvader/tree.yul b/test/libyul/yulOptimizerTests/stackLimitEvader/tree.yul index e97e458da0e2..6253e2b8f790 100644 --- a/test/libyul/yulOptimizerTests/stackLimitEvader/tree.yul +++ b/test/libyul/yulOptimizerTests/stackLimitEvader/tree.yul @@ -216,126 +216,126 @@ // function g() -> v_1 // { // mstore(0xc0, calldataload(mul(1, 4))) -// let a2_3 := calldataload(mul(2, 4)) -// let a3_4 := calldataload(mul(3, 4)) -// let a4_5 := calldataload(mul(4, 4)) -// let a5_6 := calldataload(mul(5, 4)) -// let a6_7 := calldataload(mul(6, 4)) -// let a7_8 := calldataload(mul(7, 4)) -// let a8_9 := calldataload(mul(8, 4)) -// let a9_10 := calldataload(mul(9, 4)) +// let a2_1 := calldataload(mul(2, 4)) +// let a3_1 := calldataload(mul(3, 4)) +// let a4_1 := calldataload(mul(4, 4)) +// let a5_1 := calldataload(mul(5, 4)) +// let a6_1 := calldataload(mul(6, 4)) +// let a7_1 := calldataload(mul(7, 4)) +// let a8_1 := calldataload(mul(8, 4)) +// let a9_1 := calldataload(mul(9, 4)) // mstore(0xc0, calldataload(mul(0, 4))) -// let a10_11 := calldataload(mul(10, 4)) -// let a11_12 := calldataload(mul(11, 4)) -// let a12_13 := calldataload(mul(12, 4)) -// let a13_14 := calldataload(mul(13, 4)) -// let a14_15 := calldataload(mul(14, 4)) -// let a15_16 := calldataload(mul(15, 4)) -// let a16_17 := calldataload(mul(16, 4)) -// let a17_18 := calldataload(mul(17, 4)) +// let a10_1 := calldataload(mul(10, 4)) +// let a11_1 := calldataload(mul(11, 4)) +// let a12_1 := calldataload(mul(12, 4)) +// let a13_1 := calldataload(mul(13, 4)) +// let a14_1 := calldataload(mul(14, 4)) +// let a15_1 := calldataload(mul(15, 4)) +// let a16_1 := calldataload(mul(16, 4)) +// let a17_1 := calldataload(mul(17, 4)) // sstore(0, mload(0xc0)) -// sstore(mul(17, 4), a17_18) -// sstore(mul(16, 4), a16_17) -// sstore(mul(15, 4), a15_16) -// sstore(mul(14, 4), a14_15) -// sstore(mul(13, 4), a13_14) -// sstore(mul(12, 4), a12_13) -// sstore(mul(11, 4), a11_12) -// sstore(mul(10, 4), a10_11) -// sstore(mul(9, 4), a9_10) -// sstore(mul(8, 4), a8_9) -// sstore(mul(7, 4), a7_8) -// sstore(mul(6, 4), a6_7) -// sstore(mul(5, 4), a5_6) -// sstore(mul(4, 4), a4_5) -// sstore(mul(3, 4), a3_4) -// sstore(mul(2, 4), a2_3) +// sstore(mul(17, 4), a17_1) +// sstore(mul(16, 4), a16_1) +// sstore(mul(15, 4), a15_1) +// sstore(mul(14, 4), a14_1) +// sstore(mul(13, 4), a13_1) +// sstore(mul(12, 4), a12_1) +// sstore(mul(11, 4), a11_1) +// sstore(mul(10, 4), a10_1) +// sstore(mul(9, 4), a9_1) +// sstore(mul(8, 4), a8_1) +// sstore(mul(7, 4), a7_1) +// sstore(mul(6, 4), a6_1) +// sstore(mul(5, 4), a5_1) +// sstore(mul(4, 4), a4_1) +// sstore(mul(3, 4), a3_1) +// sstore(mul(2, 4), a2_1) // sstore(mul(1, 4), mload(0xc0)) // v_1 := i() // } -// function h() -> v_19 +// function h() -> v_2 // { // mstore(0xa0, calldataload(mul(1, 4))) // mstore(0xc0, calldataload(mul(2, 4))) -// let a3_22 := calldataload(mul(3, 4)) -// let a4_23 := calldataload(mul(4, 4)) -// let a5_24 := calldataload(mul(5, 4)) -// let a6_25 := calldataload(mul(6, 4)) -// let a7_26 := calldataload(mul(7, 4)) -// let a8_27 := calldataload(mul(8, 4)) -// let a9_28 := calldataload(mul(9, 4)) -// let a10_29 := calldataload(mul(10, 4)) -// let a11_30 := calldataload(mul(10, 4)) +// let a3_2 := calldataload(mul(3, 4)) +// let a4_2 := calldataload(mul(4, 4)) +// let a5_2 := calldataload(mul(5, 4)) +// let a6_2 := calldataload(mul(6, 4)) +// let a7_2 := calldataload(mul(7, 4)) +// let a8_2 := calldataload(mul(8, 4)) +// let a9_2 := calldataload(mul(9, 4)) +// let a10_2 := calldataload(mul(10, 4)) +// let a11_2 := calldataload(mul(10, 4)) // mstore(0xa0, calldataload(mul(0, 4))) // mstore(0xc0, calldataload(mul(1, 4))) -// let a12_31 := calldataload(mul(12, 4)) -// let a13_32 := calldataload(mul(13, 4)) -// let a14_33 := calldataload(mul(14, 4)) -// let a15_34 := calldataload(mul(15, 4)) -// let a16_35 := calldataload(mul(16, 4)) -// let a17_36 := calldataload(mul(17, 4)) +// let a12_2 := calldataload(mul(12, 4)) +// let a13_2 := calldataload(mul(13, 4)) +// let a14_2 := calldataload(mul(14, 4)) +// let a15_2 := calldataload(mul(15, 4)) +// let a16_2 := calldataload(mul(16, 4)) +// let a17_2 := calldataload(mul(17, 4)) // let a18 := calldataload(mul(18, 4)) // let a19 := calldataload(mul(19, 4)) // sstore(0, add(mload(0xa0), mload(0xc0))) // sstore(mul(17, 4), a19) // sstore(mul(17, 4), a18) -// sstore(mul(17, 4), a17_36) -// sstore(mul(16, 4), a16_35) -// sstore(mul(15, 4), a15_34) -// sstore(mul(14, 4), a14_33) -// sstore(mul(13, 4), a13_32) -// sstore(mul(12, 4), a12_31) -// sstore(mul(11, 4), a11_30) -// sstore(mul(10, 4), a10_29) -// sstore(mul(9, 4), a9_28) -// sstore(mul(8, 4), a8_27) -// sstore(mul(7, 4), a7_26) -// sstore(mul(6, 4), a6_25) -// sstore(mul(5, 4), a5_24) -// sstore(mul(4, 4), a4_23) -// sstore(mul(3, 4), a3_22) +// sstore(mul(17, 4), a17_2) +// sstore(mul(16, 4), a16_2) +// sstore(mul(15, 4), a15_2) +// sstore(mul(14, 4), a14_2) +// sstore(mul(13, 4), a13_2) +// sstore(mul(12, 4), a12_2) +// sstore(mul(11, 4), a11_2) +// sstore(mul(10, 4), a10_2) +// sstore(mul(9, 4), a9_2) +// sstore(mul(8, 4), a8_2) +// sstore(mul(7, 4), a7_2) +// sstore(mul(6, 4), a6_2) +// sstore(mul(5, 4), a5_2) +// sstore(mul(4, 4), a4_2) +// sstore(mul(3, 4), a3_2) // sstore(mul(2, 4), mload(0xc0)) // sstore(mul(1, 4), mload(0xa0)) -// v_19 := i() +// v_2 := i() // } -// function i() -> v_37 +// function i() -> v_3 // { // mstore(0xe0, calldataload(mul(1, 4))) -// let a2_39 := calldataload(mul(2, 4)) -// let a3_40 := calldataload(mul(3, 4)) -// let a4_41 := calldataload(mul(4, 4)) -// let a5_42 := calldataload(mul(5, 4)) -// let a6_43 := calldataload(mul(6, 4)) -// let a7_44 := calldataload(mul(7, 4)) -// let a8_45 := calldataload(mul(8, 4)) -// let a9_46 := calldataload(mul(9, 4)) +// let a2_2 := calldataload(mul(2, 4)) +// let a3_3 := calldataload(mul(3, 4)) +// let a4_3 := calldataload(mul(4, 4)) +// let a5_3 := calldataload(mul(5, 4)) +// let a6_3 := calldataload(mul(6, 4)) +// let a7_3 := calldataload(mul(7, 4)) +// let a8_3 := calldataload(mul(8, 4)) +// let a9_3 := calldataload(mul(9, 4)) // mstore(0xe0, calldataload(mul(0, 4))) -// let a10_47 := calldataload(mul(10, 4)) -// let a11_48 := calldataload(mul(11, 4)) -// let a12_49 := calldataload(mul(12, 4)) -// let a13_50 := calldataload(mul(13, 4)) -// let a14_51 := calldataload(mul(14, 4)) -// let a15_52 := calldataload(mul(15, 4)) -// let a16_53 := calldataload(mul(16, 4)) -// let a17_54 := calldataload(mul(17, 4)) +// let a10_3 := calldataload(mul(10, 4)) +// let a11_3 := calldataload(mul(11, 4)) +// let a12_3 := calldataload(mul(12, 4)) +// let a13_3 := calldataload(mul(13, 4)) +// let a14_3 := calldataload(mul(14, 4)) +// let a15_3 := calldataload(mul(15, 4)) +// let a16_3 := calldataload(mul(16, 4)) +// let a17_3 := calldataload(mul(17, 4)) // sstore(0, mload(0xe0)) -// sstore(mul(17, 4), a17_54) -// sstore(mul(16, 4), a16_53) -// sstore(mul(15, 4), a15_52) -// sstore(mul(14, 4), a14_51) -// sstore(mul(13, 4), a13_50) -// sstore(mul(12, 4), a12_49) -// sstore(mul(11, 4), a11_48) -// sstore(mul(10, 4), a10_47) -// sstore(mul(9, 4), a9_46) -// sstore(mul(8, 4), a8_45) -// sstore(mul(7, 4), a7_44) -// sstore(mul(6, 4), a6_43) -// sstore(mul(5, 4), a5_42) -// sstore(mul(4, 4), a4_41) -// sstore(mul(3, 4), a3_40) -// sstore(mul(2, 4), a2_39) +// sstore(mul(17, 4), a17_3) +// sstore(mul(16, 4), a16_3) +// sstore(mul(15, 4), a15_3) +// sstore(mul(14, 4), a14_3) +// sstore(mul(13, 4), a13_3) +// sstore(mul(12, 4), a12_3) +// sstore(mul(11, 4), a11_3) +// sstore(mul(10, 4), a10_3) +// sstore(mul(9, 4), a9_3) +// sstore(mul(8, 4), a8_3) +// sstore(mul(7, 4), a7_3) +// sstore(mul(6, 4), a6_3) +// sstore(mul(5, 4), a5_3) +// sstore(mul(4, 4), a4_3) +// sstore(mul(3, 4), a3_3) +// sstore(mul(2, 4), a2_2) // sstore(mul(1, 4), mload(0xe0)) -// v_37 := sload(mul(42, 8)) +// v_3 := sload(mul(42, 8)) // } // } diff --git a/test/libyul/yulOptimizerTests/stackLimitEvader/verbatim_many_arguments_and_returns.yul b/test/libyul/yulOptimizerTests/stackLimitEvader/verbatim_many_arguments_and_returns.yul index e7170a10defd..8da925474494 100644 --- a/test/libyul/yulOptimizerTests/stackLimitEvader/verbatim_many_arguments_and_returns.yul +++ b/test/libyul/yulOptimizerTests/stackLimitEvader/verbatim_many_arguments_and_returns.yul @@ -73,27 +73,27 @@ // let a_18 := 18 // let a_19 := 19 // let a_20 := 20 -// let b_1_1, b_2_2, b_3_3, b_4_4, b_5_5, b_6_6, b_7_7, b_8_8, b_9_9, b_10_10, b_11_11, b_12_12, b_13_13, b_14_14, b_15_15, b_16_16, b_17_17, b_18_18, b_19_19, b_20_20 := verbatim_20i_20o("test", mload(0x0100), mload(0x0120), mload(0x0140), mload(0x0160), mload(0x0180), mload(0x01a0), mload(0x01c0), mload(0x01e0), mload(0x0200), mload(0x0220), mload(0x0240), mload(0x0260), a_13, a_14, a_15, a_16, a_17, a_18, a_19, a_20) -// mstore(0x80, b_4_4) -// mstore(0xa0, b_3_3) -// mstore(0xc0, b_2_2) -// mstore(0xe0, b_1_1) -// let b_20 := b_20_20 -// let b_19 := b_19_19 -// let b_18 := b_18_18 -// let b_17 := b_17_17 -// let b_16 := b_16_16 -// let b_15 := b_15_15 -// let b_14 := b_14_14 -// let b_13 := b_13_13 -// let b_12 := b_12_12 -// let b_11 := b_11_11 -// let b_10 := b_10_10 -// let b_9 := b_9_9 -// let b_8 := b_8_8 -// let b_7 := b_7_7 -// let b_6 := b_6_6 -// let b_5 := b_5_5 +// let b_1, b_2, b_3, b_4, b_5_1, b_6_1, b_7_1, b_8_1, b_9_1, b_10_1, b_11_1, b_12_1, b_13_1, b_14_1, b_15_1, b_16_1, b_17_1, b_18_1, b_19_1, b_20_1 := verbatim_20i_20o("test", mload(0x0100), mload(0x0120), mload(0x0140), mload(0x0160), mload(0x0180), mload(0x01a0), mload(0x01c0), mload(0x01e0), mload(0x0200), mload(0x0220), mload(0x0240), mload(0x0260), a_13, a_14, a_15, a_16, a_17, a_18, a_19, a_20) +// mstore(0x80, b_4) +// mstore(0xa0, b_3) +// mstore(0xc0, b_2) +// mstore(0xe0, b_1) +// let b_20 := b_20_1 +// let b_19 := b_19_1 +// let b_18 := b_18_1 +// let b_17 := b_17_1 +// let b_16 := b_16_1 +// let b_15 := b_15_1 +// let b_14 := b_14_1 +// let b_13 := b_13_1 +// let b_12 := b_12_1 +// let b_11 := b_11_1 +// let b_10 := b_10_1 +// let b_9 := b_9_1 +// let b_8 := b_8_1 +// let b_7 := b_7_1 +// let b_6 := b_6_1 +// let b_5 := b_5_1 // sstore(1, mload(0xe0)) // sstore(2, mload(0xc0)) // sstore(3, mload(0xa0)) diff --git a/test/libyul/yulOptimizerTests/stackLimitEvader/verbatim_many_returns.yul b/test/libyul/yulOptimizerTests/stackLimitEvader/verbatim_many_returns.yul index e06dd8d8b0a9..df7ee753a948 100644 --- a/test/libyul/yulOptimizerTests/stackLimitEvader/verbatim_many_returns.yul +++ b/test/libyul/yulOptimizerTests/stackLimitEvader/verbatim_many_returns.yul @@ -15,40 +15,40 @@ // { // { // mstore(0x40, memoryguard(0xa0)) -// let a1_1, a2_2, a3_3, a4_4, a5_5, a6_6, a7_7, a8_8, a9_9, a10_10, a13_11, a14_12, a15_13, a16_14, a17_15, a18_16 := verbatim_0i_16o("test") +// let a1, a2_1, a3_1, a4_1, a5_1, a6_1, a7_1, a8_1, a9_1, a10_1, a13_1, a14_1, a15_1, a16_1, a17_1, a18_1 := verbatim_0i_16o("test") +// mstore(0x80, a1) +// let a18 := a18_1 +// let a17 := a17_1 +// let a16 := a16_1 +// let a15 := a15_1 +// let a14 := a14_1 +// let a13 := a13_1 +// let a10 := a10_1 +// let a9 := a9_1 +// let a8 := a8_1 +// let a7 := a7_1 +// let a6 := a6_1 +// let a5 := a5_1 +// let a4 := a4_1 +// let a3 := a3_1 +// let a2 := a2_1 +// let a1_1, a2_2, a3_2, a4_2, a5_2, a6_2, a7_2, a8_2, a9_2, a10_2, a13_2, a14_2, a15_2, a16_2, a17_2, a18_2 := verbatim_0i_16o("test") // mstore(0x80, a1_1) -// let a18 := a18_16 -// let a17 := a17_15 -// let a16 := a16_14 -// let a15 := a15_13 -// let a14 := a14_12 -// let a13 := a13_11 -// let a10 := a10_10 -// let a9 := a9_9 -// let a8 := a8_8 -// let a7 := a7_7 -// let a6 := a6_6 -// let a5 := a5_5 -// let a4 := a4_4 -// let a3 := a3_3 -// let a2 := a2_2 -// let a1_17, a2_18, a3_19, a4_20, a5_21, a6_22, a7_23, a8_24, a9_25, a10_26, a13_27, a14_28, a15_29, a16_30, a17_31, a18_32 := verbatim_0i_16o("test") -// mstore(0x80, a1_17) -// a18 := a18_32 -// a17 := a17_31 -// a16 := a16_30 -// a15 := a15_29 -// a14 := a14_28 -// a13 := a13_27 -// a10 := a10_26 -// a9 := a9_25 -// a8 := a8_24 -// a7 := a7_23 -// a6 := a6_22 -// a5 := a5_21 -// a4 := a4_20 -// a3 := a3_19 -// a2 := a2_18 +// a18 := a18_2 +// a17 := a17_2 +// a16 := a16_2 +// a15 := a15_2 +// a14 := a14_2 +// a13 := a13_2 +// a10 := a10_2 +// a9 := a9_2 +// a8 := a8_2 +// a7 := a7_2 +// a6 := a6_2 +// a5 := a5_2 +// a4 := a4_2 +// a3 := a3_2 +// a2 := a2_2 // sstore(mload(0x80), 10) // sstore(a18, 20) // } diff --git a/test/libyul/yulOptimizerTests/unusedAssignEliminator/leave.yul b/test/libyul/yulOptimizerTests/unusedAssignEliminator/leave.yul index 82bf493470c8..302ca3e865eb 100644 --- a/test/libyul/yulOptimizerTests/unusedAssignEliminator/leave.yul +++ b/test/libyul/yulOptimizerTests/unusedAssignEliminator/leave.yul @@ -31,10 +31,10 @@ // if b { leave } // x := 8 // } -// function g(a_1, b_2) -> x_3 +// function g(a_1, b_1) -> x_1 // { -// let t_4 -// if b_2 { } -// x_3 := 8 +// let t_1 +// if b_1 { } +// x_1 := 8 // } // } diff --git a/test/libyul/yulOptimizerTests/unusedFunctionParameterPruner/LiteralRematerialiser.yul b/test/libyul/yulOptimizerTests/unusedFunctionParameterPruner/LiteralRematerialiser.yul index e11ea2a96f9e..7af5e37bc2a4 100644 --- a/test/libyul/yulOptimizerTests/unusedFunctionParameterPruner/LiteralRematerialiser.yul +++ b/test/libyul/yulOptimizerTests/unusedFunctionParameterPruner/LiteralRematerialiser.yul @@ -22,6 +22,6 @@ // if iszero(x) { revert(0, 0) } // if iszero(add(x, 1)) { revert(0, 0) } // } -// function f_1(x_2) -> y_3 -// { f(x_2) } +// function f_1(x_1) -> y +// { f(x_1) } // } diff --git a/test/libyul/yulOptimizerTests/unusedFunctionParameterPruner/multiple_param.yul b/test/libyul/yulOptimizerTests/unusedFunctionParameterPruner/multiple_param.yul index f2a036459817..0718b67d0202 100644 --- a/test/libyul/yulOptimizerTests/unusedFunctionParameterPruner/multiple_param.yul +++ b/test/libyul/yulOptimizerTests/unusedFunctionParameterPruner/multiple_param.yul @@ -19,6 +19,6 @@ // y := mload(a) // z := mload(c) // } -// function f_1(a_2, b_3, c_4) -> x_5, y_6, z_7 -// { y_6, z_7 := f(a_2, c_4) } +// function f_1(a_1, b, c_1) -> x, y_1, z_1 +// { y_1, z_1 := f(a_1, c_1) } // } diff --git a/test/libyul/yulOptimizerTests/unusedFunctionParameterPruner/multiple_return.yul b/test/libyul/yulOptimizerTests/unusedFunctionParameterPruner/multiple_return.yul index 51612a699b0f..1edd68c5e7e1 100644 --- a/test/libyul/yulOptimizerTests/unusedFunctionParameterPruner/multiple_return.yul +++ b/test/libyul/yulOptimizerTests/unusedFunctionParameterPruner/multiple_return.yul @@ -19,6 +19,6 @@ // y := mload(1) // z := mload(2) // } -// function f_1(d_2) -> x_3, y_4, z_5 -// { y_4, z_5 := f() } +// function f_1(d) -> x, y_1, z_1 +// { y_1, z_1 := f() } // } diff --git a/test/libyul/yulOptimizerTests/unusedFunctionParameterPruner/nested_function.yul b/test/libyul/yulOptimizerTests/unusedFunctionParameterPruner/nested_function.yul index d09ba44a6634..497cb21e747d 100644 --- a/test/libyul/yulOptimizerTests/unusedFunctionParameterPruner/nested_function.yul +++ b/test/libyul/yulOptimizerTests/unusedFunctionParameterPruner/nested_function.yul @@ -42,15 +42,15 @@ // x := g(1) // x := add(x, 1) // } -// function f_1(a_3) -> x_4 -// { x_4 := f() } +// function f_1(a) -> x_1 +// { x_1 := f() } // function j() -> w // { // w := 13 // w := add(13, 1) // } -// function j_2(d_5) -> w_6 -// { w_6 := j() } +// function j_1(d) -> w_1 +// { w_1 := j() } // function h(c) -> u -// { u := j_2(c) } +// { u := j_1(c) } // } diff --git a/test/libyul/yulOptimizerTests/unusedFunctionParameterPruner/nested_function_name_collision.yul b/test/libyul/yulOptimizerTests/unusedFunctionParameterPruner/nested_function_name_collision.yul index 8ce80f140edb..6eb892aaa4fa 100644 --- a/test/libyul/yulOptimizerTests/unusedFunctionParameterPruner/nested_function_name_collision.yul +++ b/test/libyul/yulOptimizerTests/unusedFunctionParameterPruner/nested_function_name_collision.yul @@ -36,17 +36,17 @@ // w := 13 // sstore(0, 13) // } -// function g_1(d_3) -> w_4 -// { w_4 := g() } +// function g_2(d) -> w_2 +// { w_2 := g() } // function f(c) -> u -// { u := g_1(c) } -// function g_3() -> w_5 +// { u := g_2(c) } +// function g_1() -> w_1 // { -// w_5 := 13 +// w_1 := 13 // sstore(0, 13) // } -// function g_3_2(d_4_5) -> w_5_6 -// { w_5_6 := g_3() } -// function h(c_1) -> u_2 -// { u_2 := g_3_2(c_1) } +// function g_3(d_1) -> w_3 +// { w_3 := g_1() } +// function h(c_1) -> u_1 +// { u_1 := g_3(c_1) } // } diff --git a/test/libyul/yulOptimizerTests/unusedFunctionParameterPruner/no_return.yul b/test/libyul/yulOptimizerTests/unusedFunctionParameterPruner/no_return.yul index 1cf059da2979..96d24ee4c638 100644 --- a/test/libyul/yulOptimizerTests/unusedFunctionParameterPruner/no_return.yul +++ b/test/libyul/yulOptimizerTests/unusedFunctionParameterPruner/no_return.yul @@ -16,6 +16,6 @@ // sstore(a, 0) // a := add(a, 1) // } -// function f_1(a_2, b_3) -// { f(a_2) } +// function f_1(a_1, b) +// { f(a_1) } // } diff --git a/test/libyul/yulOptimizerTests/unusedFunctionParameterPruner/recursion.yul b/test/libyul/yulOptimizerTests/unusedFunctionParameterPruner/recursion.yul index 4a2c5b6ccc30..6acab50336a5 100644 --- a/test/libyul/yulOptimizerTests/unusedFunctionParameterPruner/recursion.yul +++ b/test/libyul/yulOptimizerTests/unusedFunctionParameterPruner/recursion.yul @@ -16,6 +16,6 @@ // x, y, z := f_1(1, 2, 3) // x := add(x, 1) // } -// function f_1(a_2, b_3, c_4) -> x_5, y_6, z_7 -// { x_5, y_6, z_7 := f() } +// function f_1(a, b, c) -> x_1, y_1, z_1 +// { x_1, y_1, z_1 := f() } // } diff --git a/test/libyul/yulOptimizerTests/unusedFunctionParameterPruner/simple.yul b/test/libyul/yulOptimizerTests/unusedFunctionParameterPruner/simple.yul index 873eef9777ab..6ee9e4f3b42e 100644 --- a/test/libyul/yulOptimizerTests/unusedFunctionParameterPruner/simple.yul +++ b/test/libyul/yulOptimizerTests/unusedFunctionParameterPruner/simple.yul @@ -16,6 +16,6 @@ // let w := mload(1) // y := mload(w) // } -// function f_1(x_2) -> y_3 -// { y_3 := f() } +// function f_1(x) -> y_1 +// { y_1 := f() } // } diff --git a/test/libyul/yulOptimizerTests/unusedFunctionParameterPruner/too_many_arguments.yul b/test/libyul/yulOptimizerTests/unusedFunctionParameterPruner/too_many_arguments.yul index 720489d57328..0ed95f76e099 100644 --- a/test/libyul/yulOptimizerTests/unusedFunctionParameterPruner/too_many_arguments.yul +++ b/test/libyul/yulOptimizerTests/unusedFunctionParameterPruner/too_many_arguments.yul @@ -18,6 +18,6 @@ // y := mload(x3) // z := mload(x7) // } -// function f_1(x1_2, x2_3, x3_4, x4_5, x5_6, x6_7, x7_8, x8_9, x9_10, x10_11, x11_12, x12_13, x13_14, x14_15, x15_16, x16_17, x17_18, x18_19) -> y_20, z_21 -// { y_20, z_21 := f(x3_4, x7_8) } +// function f_1(x1, x2, x3_1, x4, x5, x6, x7_1, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18) -> y_1, z_1 +// { y_1, z_1 := f(x3_1, x7_1) } // } diff --git a/test/libyul/yulOptimizerTests/unusedStoreEliminator/covering_calldatacopy.yul b/test/libyul/yulOptimizerTests/unusedStoreEliminator/covering_calldatacopy.yul index 7fd227089b83..9ca1d879b4d7 100644 --- a/test/libyul/yulOptimizerTests/unusedStoreEliminator/covering_calldatacopy.yul +++ b/test/libyul/yulOptimizerTests/unusedStoreEliminator/covering_calldatacopy.yul @@ -30,28 +30,28 @@ // let start := calldataload(0x10) // if calldataload(0) // { -// let _4 := 7 -// mstore(add(start, 2), _4) +// let _1 := 7 +// mstore(add(start, 2), _1) // calldatacopy(start, 0, 0x20) // } // if calldataload(1) // { -// let _11 := 9 -// mstore(add(start, 2), _11) -// let _14 := 0x21 -// let _15 := 0 -// calldatacopy(add(start, 1), _15, _14) +// let _2 := 9 +// mstore(add(start, 2), _2) +// let _3 := 0x21 +// let _4 := 0 +// calldatacopy(add(start, 1), _4, _3) // } // if calldataload(2) // { -// let _20 := 7 -// mstore8(add(start, 2), _20) +// let _5 := 7 +// mstore8(add(start, 2), _5) // calldatacopy(start, 0, 3) // } // if calldataload(3) // { -// let _27 := 7 -// mstore8(add(start, 3), _27) +// let _6 := 7 +// mstore8(add(start, 3), _6) // calldatacopy(start, 0, 3) // } // sstore(0, keccak256(start, 0x40)) diff --git a/test/libyul/yulOptimizerTests/unusedStoreEliminator/covering_calldatacopy_fixed.yul b/test/libyul/yulOptimizerTests/unusedStoreEliminator/covering_calldatacopy_fixed.yul index 47e0b95fa3a3..3c0b8dcbddfd 100644 --- a/test/libyul/yulOptimizerTests/unusedStoreEliminator/covering_calldatacopy_fixed.yul +++ b/test/libyul/yulOptimizerTests/unusedStoreEliminator/covering_calldatacopy_fixed.yul @@ -33,14 +33,14 @@ // } // if calldataload(1) // { -// let _10 := 9 -// let _11 := 2 +// let _1 := 9 +// let _2 := 2 // calldatacopy(1, 0, 0x21) // } // if calldataload(2) // { -// let _17 := 7 -// let _18 := 2 +// let _3 := 7 +// let _4 := 2 // calldatacopy(0, 0, 3) // } // if calldataload(3) diff --git a/test/libyul/yulOptimizerTests/unusedStoreEliminator/function_end.yul b/test/libyul/yulOptimizerTests/unusedStoreEliminator/function_end.yul index cb69be363594..23586187f49e 100644 --- a/test/libyul/yulOptimizerTests/unusedStoreEliminator/function_end.yul +++ b/test/libyul/yulOptimizerTests/unusedStoreEliminator/function_end.yul @@ -14,7 +14,7 @@ // function f() // { // let x := calldataload(2) -// let _2 := 2 +// let _1 := 2 // mstore(x, 3) // } // } diff --git a/test/libyul/yulOptimizerTests/unusedStoreEliminator/if_overwrite_all_branches.yul b/test/libyul/yulOptimizerTests/unusedStoreEliminator/if_overwrite_all_branches.yul index 7054dc255464..b15fecd84a91 100644 --- a/test/libyul/yulOptimizerTests/unusedStoreEliminator/if_overwrite_all_branches.yul +++ b/test/libyul/yulOptimizerTests/unusedStoreEliminator/if_overwrite_all_branches.yul @@ -13,8 +13,8 @@ // { // { // let c := calldataload(0) -// let _2 := 1 -// if c { let _3 := 2 } +// let _1 := 1 +// if c { let _2 := 2 } // sstore(c, 3) // } // } diff --git a/test/libyul/yulOptimizerTests/unusedStoreEliminator/leave.yul b/test/libyul/yulOptimizerTests/unusedStoreEliminator/leave.yul index 92a75155410b..66e31e9eb3d1 100644 --- a/test/libyul/yulOptimizerTests/unusedStoreEliminator/leave.yul +++ b/test/libyul/yulOptimizerTests/unusedStoreEliminator/leave.yul @@ -16,8 +16,8 @@ // { // mstore(0, 5) // if calldataload(0) { leave } -// let _5 := 5 -// let _6 := 0x20 +// let _1 := 5 +// let _2 := 0x20 // revert(0, 0) // } // } diff --git a/test/libyul/yulOptimizerTests/unusedStoreEliminator/memoryguard.yul b/test/libyul/yulOptimizerTests/unusedStoreEliminator/memoryguard.yul index 466cd02e5331..83aa7ac0a23d 100644 --- a/test/libyul/yulOptimizerTests/unusedStoreEliminator/memoryguard.yul +++ b/test/libyul/yulOptimizerTests/unusedStoreEliminator/memoryguard.yul @@ -15,9 +15,9 @@ // { // mstore(0x40, memoryguard(100)) // let free_mem_ptr := mload(0x40) -// let _4 := 100 -// let _5 := 200 -// mstore8(add(free_mem_ptr, 31), _5) +// let _1 := 100 +// let _2 := 200 +// mstore8(add(free_mem_ptr, 31), _2) // mstore(free_mem_ptr, 300) // return(free_mem_ptr, add(free_mem_ptr, 100)) // } diff --git a/test/libyul/yulOptimizerTests/unusedStoreEliminator/no_storage_inside_function.yul b/test/libyul/yulOptimizerTests/unusedStoreEliminator/no_storage_inside_function.yul index 524b328e9e7e..204a90019da9 100644 --- a/test/libyul/yulOptimizerTests/unusedStoreEliminator/no_storage_inside_function.yul +++ b/test/libyul/yulOptimizerTests/unusedStoreEliminator/no_storage_inside_function.yul @@ -14,7 +14,7 @@ // { // { // let x := 5 -// let _2 := 10 +// let _1 := 10 // mstore(0, 42) // pop(f()) // sstore(x, 10) @@ -22,6 +22,6 @@ // function f() -> r // { // r := mload(0x20) -// let r_7 := r +// let r_1 := r // } // } diff --git a/test/libyul/yulOptimizerTests/unusedStoreEliminator/remove_before_revert.yul b/test/libyul/yulOptimizerTests/unusedStoreEliminator/remove_before_revert.yul index e7777964c20e..3d23316f964c 100644 --- a/test/libyul/yulOptimizerTests/unusedStoreEliminator/remove_before_revert.yul +++ b/test/libyul/yulOptimizerTests/unusedStoreEliminator/remove_before_revert.yul @@ -13,8 +13,8 @@ // { // { // let c := calldataload(0) -// let _2 := 4 -// if c { let _3 := 2 } +// let _1 := 4 +// if c { let _2 := 2 } // let d := 0 // revert(d, d) // } diff --git a/test/libyul/yulOptimizerTests/unusedStoreEliminator/tstore.yul b/test/libyul/yulOptimizerTests/unusedStoreEliminator/tstore.yul index f3befb79d0ad..4eb4cc2dbbb7 100644 --- a/test/libyul/yulOptimizerTests/unusedStoreEliminator/tstore.yul +++ b/test/libyul/yulOptimizerTests/unusedStoreEliminator/tstore.yul @@ -15,7 +15,7 @@ // { // let x := 5 // tstore(x, 10) -// let _2 := 10 +// let _1 := 10 // pop(mload(0)) // tstore(x, 10) // sstore(x, 20) diff --git a/test/libyul/yulOptimizerTests/unusedStoreEliminator/unknown_length2.yul b/test/libyul/yulOptimizerTests/unusedStoreEliminator/unknown_length2.yul index db5f060a634d..e02b34bb78e5 100644 --- a/test/libyul/yulOptimizerTests/unusedStoreEliminator/unknown_length2.yul +++ b/test/libyul/yulOptimizerTests/unusedStoreEliminator/unknown_length2.yul @@ -13,21 +13,21 @@ // // { // { -// let a_9 -// let a := a_9 +// let a_1 +// let a := a_1 // switch calldataload(0) // case 0 { // a := calldataload(9) -// let a_10 := a +// let a_2 := a // } // case 1 { -// let a_12 := a +// let a_4 := a // a := calldataload(10) -// let a_11 := a +// let a_3 := a // } -// let a_13 := a -// let _5 := 0 -// let _6 := 0x20 +// let a_5 := a +// let _1 := 0 +// let _2 := 0x20 // sstore(0, mload(0)) // } // } diff --git a/test/libyul/yulOptimizerTests/unusedStoreEliminator/unrelated_relative.yul b/test/libyul/yulOptimizerTests/unusedStoreEliminator/unrelated_relative.yul index b0b42060f49c..b3fb063ca0a7 100644 --- a/test/libyul/yulOptimizerTests/unusedStoreEliminator/unrelated_relative.yul +++ b/test/libyul/yulOptimizerTests/unusedStoreEliminator/unrelated_relative.yul @@ -13,11 +13,11 @@ // { // let c := calldataload(0) // mstore(c, 4) -// let _3 := 8 -// let _5 := add(c, 0x20) +// let _1 := 8 +// let _2 := add(c, 0x20) // sstore(0, mload(c)) -// let _8 := 9 -// let _9 := 20 -// let _11 := add(c, 0x20) +// let _3 := 9 +// let _4 := 20 +// let _5 := add(c, 0x20) // } // } diff --git a/test/libyul/yulOptimizerTests/varNameCleaner/builtins.yul b/test/libyul/yulOptimizerTests/varNameCleaner/builtins.yul deleted file mode 100644 index 43c30137a869..000000000000 --- a/test/libyul/yulOptimizerTests/varNameCleaner/builtins.yul +++ /dev/null @@ -1,7 +0,0 @@ -{ - let datasize_256 := 1 -} -// ---- -// step: varNameCleaner -// -// { { let datasize_1 := 1 } } diff --git a/test/libyul/yulOptimizerTests/varNameCleaner/function_names.yul b/test/libyul/yulOptimizerTests/varNameCleaner/function_names.yul deleted file mode 100644 index c8b2bef2429f..000000000000 --- a/test/libyul/yulOptimizerTests/varNameCleaner/function_names.yul +++ /dev/null @@ -1,16 +0,0 @@ -{ - function f() { let f_1 } - let f_2 - let f_10 -} -// ---- -// step: varNameCleaner -// -// { -// { -// let f_1 -// let f_2 -// } -// function f() -// { let f_1 } -// } diff --git a/test/libyul/yulOptimizerTests/varNameCleaner/function_parameters.yul b/test/libyul/yulOptimizerTests/varNameCleaner/function_parameters.yul deleted file mode 100644 index c0656056eec0..000000000000 --- a/test/libyul/yulOptimizerTests/varNameCleaner/function_parameters.yul +++ /dev/null @@ -1,25 +0,0 @@ -{ - let f_2 - function f(x_12) -> x, y_14 - { - let y := x_12 - y_14 := y - x := y_14 - } - let f_10 -} -// ---- -// step: varNameCleaner -// -// { -// { -// let f_1 -// let f_2 -// } -// function f(x) -> x_1, y -// { -// let y_1 := x -// y := y_1 -// x_1 := y -// } -// } diff --git a/test/libyul/yulOptimizerTests/varNameCleaner/function_scopes.yul b/test/libyul/yulOptimizerTests/varNameCleaner/function_scopes.yul deleted file mode 100644 index 2882459dbe93..000000000000 --- a/test/libyul/yulOptimizerTests/varNameCleaner/function_scopes.yul +++ /dev/null @@ -1,14 +0,0 @@ -{ - function f() { let x_1 := 0 } - function g() { let x_2 := 0 } -} -// ---- -// step: varNameCleaner -// -// { -// { } -// function f() -// { let x := 0 } -// function g() -// { let x := 0 } -// } diff --git a/test/libyul/yulOptimizerTests/varNameCleaner/instructions.yul b/test/libyul/yulOptimizerTests/varNameCleaner/instructions.yul deleted file mode 100644 index 325ec7d8414a..000000000000 --- a/test/libyul/yulOptimizerTests/varNameCleaner/instructions.yul +++ /dev/null @@ -1,7 +0,0 @@ -{ - let mul_256 := 1 -} -// ---- -// step: varNameCleaner -// -// { { let mul_1 := 1 } } diff --git a/test/libyul/yulOptimizerTests/varNameCleaner/name_stripping.yul b/test/libyul/yulOptimizerTests/varNameCleaner/name_stripping.yul deleted file mode 100644 index 7d7d763c5424..000000000000 --- a/test/libyul/yulOptimizerTests/varNameCleaner/name_stripping.yul +++ /dev/null @@ -1,17 +0,0 @@ -{ - let a_1 := 1 - let a_2_1 := 2 - let a_4312 := 0xdeadbeef - let _42 := 21718 -} -// ---- -// step: varNameCleaner -// -// { -// { -// let a := 1 -// let a_1 := 2 -// let a_2 := 0xdeadbeef -// let _1 := 21718 -// } -// } diff --git a/test/libyul/yulOptimizerTests/varNameCleaner/reshuffling-inverse.yul b/test/libyul/yulOptimizerTests/varNameCleaner/reshuffling-inverse.yul deleted file mode 100644 index 237ab8612e92..000000000000 --- a/test/libyul/yulOptimizerTests/varNameCleaner/reshuffling-inverse.yul +++ /dev/null @@ -1,17 +0,0 @@ -{ - let x_4 := 1 - let x_3 := 2 - let x_2 := 3 - let x_1 := 4 -} -// ---- -// step: varNameCleaner -// -// { -// { -// let x := 1 -// let x_1 := 2 -// let x_2 := 3 -// let x_3 := 4 -// } -// } diff --git a/test/libyul/yulOptimizerTests/varNameCleaner/reshuffling.yul b/test/libyul/yulOptimizerTests/varNameCleaner/reshuffling.yul deleted file mode 100644 index 0df1715d739b..000000000000 --- a/test/libyul/yulOptimizerTests/varNameCleaner/reshuffling.yul +++ /dev/null @@ -1,15 +0,0 @@ -{ - let x_1 := 1 - let x_2 := 2 - let x_3 := 3 -} -// ---- -// step: varNameCleaner -// -// { -// { -// let x := 1 -// let x_1 := 2 -// let x_2 := 3 -// } -// } diff --git a/test/libyul/yulStackLayout/complex.yul b/test/libyul/yulStackLayout/complex.yul index 66390f7d4741..7b968e824a18 100644 --- a/test/libyul/yulStackLayout/complex.yul +++ b/test/libyul/yulStackLayout/complex.yul @@ -117,12 +117,12 @@ // mload\l\ // [ c RET a b x TMP[mload, 0] ]\l\ // [ c RET a b x TMP[mload, 0] ]\l\ -// Assignment(GHOST[0])\l\ -// [ c RET a b x GHOST[0] ]\l\ -// [ c RET a b x GHOST[0] GHOST[0] 0x00 ]\l\ +// Assignment(GHOST[7])\l\ +// [ c RET a b x GHOST[7] ]\l\ +// [ c RET a b x GHOST[7] GHOST[7] 0x00 ]\l\ // eq\l\ -// [ c RET a b x GHOST[0] TMP[eq, 0] ]\l\ -// [ c RET a b x GHOST[0] TMP[eq, 0] ]\l\ +// [ c RET a b x GHOST[7] TMP[eq, 0] ]\l\ +// [ c RET a b x GHOST[7] TMP[eq, 0] ]\l\ // "]; // Block4 -> Block4Exit; // Block4Exit [label="{ TMP[eq, 0]| { <0> Zero | <1> NonZero }}" shape=Mrecord]; @@ -148,11 +148,11 @@ // Block6Exit -> Block5; // // Block7 [label="\ -// [ c RET a b x GHOST[0] ]\l\ -// [ c RET a b x GHOST[0] GHOST[0] 0x01 ]\l\ +// [ c RET a b x GHOST[7] ]\l\ +// [ c RET a b x GHOST[7] GHOST[7] 0x01 ]\l\ // eq\l\ -// [ c RET a b x GHOST[0] TMP[eq, 0] ]\l\ -// [ c RET a b x GHOST[0] TMP[eq, 0] ]\l\ +// [ c RET a b x GHOST[7] TMP[eq, 0] ]\l\ +// [ c RET a b x GHOST[7] TMP[eq, 0] ]\l\ // "]; // Block7 -> Block7Exit; // Block7Exit [label="{ TMP[eq, 0]| { <0> Zero | <1> NonZero }}" shape=Mrecord]; @@ -171,11 +171,11 @@ // Block8Exit -> Block3; // // Block9 [label="\ -// [ c RET a b x GHOST[0] ]\l\ -// [ c RET a b x GHOST[0] GHOST[0] 0x02 ]\l\ +// [ c RET a b x GHOST[7] ]\l\ +// [ c RET a b x GHOST[7] GHOST[7] 0x02 ]\l\ // eq\l\ -// [ c RET a b x GHOST[0] TMP[eq, 0] ]\l\ -// [ c RET a b x GHOST[0] TMP[eq, 0] ]\l\ +// [ c RET a b x GHOST[7] TMP[eq, 0] ]\l\ +// [ c RET a b x GHOST[7] TMP[eq, 0] ]\l\ // "]; // Block9 -> Block9Exit; // Block9Exit [label="{ TMP[eq, 0]| { <0> Zero | <1> NonZero }}" shape=Mrecord]; @@ -193,8 +193,8 @@ // Block10 -> Block10Exit; // // Block11 [label="\ -// [ c RET a b x GHOST[0] ]\l\ -// [ c RET a b x GHOST[0] 0x03 ]\l\ +// [ c RET a b x GHOST[7] ]\l\ +// [ c RET a b x GHOST[7] 0x03 ]\l\ // eq\l\ // [ c RET a b x TMP[eq, 0] ]\l\ // [ c RET a b x TMP[eq, 0] ]\l\ diff --git a/test/libyul/yulStackLayout/switch.yul b/test/libyul/yulStackLayout/switch.yul index 5f655731bedf..5dfea5f5db47 100644 --- a/test/libyul/yulStackLayout/switch.yul +++ b/test/libyul/yulStackLayout/switch.yul @@ -37,12 +37,12 @@ // sload\l\ // [ y z TMP[sload, 0] ]\l\ // [ y z TMP[sload, 0] ]\l\ -// Assignment(GHOST[0])\l\ -// [ y z GHOST[0] ]\l\ -// [ y z GHOST[0] GHOST[0] 0x00 ]\l\ +// Assignment(GHOST[5])\l\ +// [ y z GHOST[5] ]\l\ +// [ y z GHOST[5] GHOST[5] 0x00 ]\l\ // eq\l\ -// [ y z GHOST[0] TMP[eq, 0] ]\l\ -// [ y z GHOST[0] TMP[eq, 0] ]\l\ +// [ y z GHOST[5] TMP[eq, 0] ]\l\ +// [ y z GHOST[5] TMP[eq, 0] ]\l\ // "]; // Block0 -> Block0Exit; // Block0Exit [label="{ TMP[eq, 0]| { <0> Zero | <1> NonZero }}" shape=Mrecord]; @@ -50,8 +50,8 @@ // Block0Exit:1 -> Block2; // // Block1 [label="\ -// [ y z GHOST[0] ]\l\ -// [ y z GHOST[0] 0x01 ]\l\ +// [ y z GHOST[5] ]\l\ +// [ y z GHOST[5] 0x01 ]\l\ // eq\l\ // [ y z TMP[eq, 0] ]\l\ // [ y z TMP[eq, 0] ]\l\ From cd8bcdf92a9b3990236da3bb9810656d0d567b36 Mon Sep 17 00:00:00 2001 From: clonker <1685266+clonker@users.noreply.github.com> Date: Fri, 21 Mar 2025 15:09:56 +0100 Subject: [PATCH 12/17] Remove NameSimplifier --- libyul/CMakeLists.txt | 2 - libyul/optimiser/NameSimplifier.cpp | 125 ---------------------------- libyul/optimiser/NameSimplifier.h | 72 ---------------- libyul/optimiser/Suite.cpp | 1 - 4 files changed, 200 deletions(-) delete mode 100644 libyul/optimiser/NameSimplifier.cpp delete mode 100644 libyul/optimiser/NameSimplifier.h diff --git a/libyul/CMakeLists.txt b/libyul/CMakeLists.txt index 68756fca92f0..255da1d1e2c7 100644 --- a/libyul/CMakeLists.txt +++ b/libyul/CMakeLists.txt @@ -159,8 +159,6 @@ add_library(yul optimiser/NameDispenser.h optimiser/NameDisplacer.cpp optimiser/NameDisplacer.h - optimiser/NameSimplifier.cpp - optimiser/NameSimplifier.h optimiser/OptimiserStep.h optimiser/OptimizerUtilities.cpp optimiser/OptimizerUtilities.h diff --git a/libyul/optimiser/NameSimplifier.cpp b/libyul/optimiser/NameSimplifier.cpp deleted file mode 100644 index 0572a9003523..000000000000 --- a/libyul/optimiser/NameSimplifier.cpp +++ /dev/null @@ -1,125 +0,0 @@ -/* - This file is part of solidity. - - solidity is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - solidity is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with solidity. If not, see . -*/ - -#include -#include -#include -#include -#include -#include -#include - -#include - -#include - -using namespace solidity::yul; - -NameSimplifier::NameSimplifier(OptimiserStepContext& _context, Block const& _ast): - m_context(_context) -{ - for (YulName name: _context.reservedIdentifiers) - m_translations[name] = name; - - for (YulName const& name: NameCollector(_ast).names()) - findSimplification(name); -} - -void NameSimplifier::operator()(FunctionDefinition& _funDef) -{ - translate(_funDef.name); - renameVariables(_funDef.parameters); - renameVariables(_funDef.returnVariables); - ASTModifier::operator()(_funDef); -} - -void NameSimplifier::operator()(VariableDeclaration& _varDecl) -{ - renameVariables(_varDecl.variables); - ASTModifier::operator()(_varDecl); -} - -void NameSimplifier::renameVariables(std::vector& _variables) -{ - for (NameWithDebugData& typedName: _variables) - translate(typedName.name); -} - -void NameSimplifier::operator()(Identifier& _identifier) -{ - translate(_identifier.name); -} - -void NameSimplifier::operator()(FunctionCall& _funCall) -{ - // The visitor on its own does not visit the function name. - if (!isBuiltinFunctionCall(_funCall)) - { - yulAssert(std::holds_alternative(_funCall.functionName)); - (*this)(std::get(_funCall.functionName)); - } - ASTModifier::operator()(_funCall); -} - -void NameSimplifier::findSimplification(YulName const& _name) -{ - if (m_translations.count(_name)) - return; - - std::string name = _name.str(); - - static auto replacements = std::vector>{ - {std::regex("_\\$|\\$_"), "_"}, // remove type mangling delimiters - {std::regex("_[0-9]+([^0-9a-fA-Fx])"), "$1"}, // removes AST IDs that are not hex. - {std::regex("_[0-9]+$"), ""}, // removes AST IDs that are not hex. - {std::regex("_t_"), "_"}, // remove type prefixes - {std::regex("__"), "_"}, - {std::regex("(abi_..code.*)_to_.*"), "$1"}, // removes _to... for abi functions - {std::regex("(stringliteral_?[0-9a-f][0-9a-f][0-9a-f][0-9a-f])[0-9a-f]*"), "$1"}, // shorten string literal - {std::regex("tuple_"), ""}, - {std::regex("_memory_ptr"), ""}, - {std::regex("_calldata_ptr"), "_calldata"}, - {std::regex("_fromStack"), ""}, - {std::regex("_storage_storage"), "_storage"}, - {std::regex("(storage.*)_?storage"), "$1"}, - {std::regex("_memory_memory"), "_memory"}, - {std::regex("_contract\\$_([^_]*)_?"), "$1_"}, - {std::regex("index_access_(t_)?array"), "index_access"}, - {std::regex("[0-9]*_$"), ""} - }; - - for (auto const& [pattern, substitute]: replacements) - { - std::string candidate = regex_replace(name, pattern, substitute); - if (!candidate.empty() && !m_context.dispenser.illegalName(YulName(candidate))) - name = candidate; - } - - if (name != _name.str()) - { - YulName newName{name}; - m_context.dispenser.markUsed(newName); - m_translations[_name] = std::move(newName); - } -} - -void NameSimplifier::translate(YulName& _name) -{ - auto it = m_translations.find(_name); - if (it != m_translations.end()) - _name = it->second; -} diff --git a/libyul/optimiser/NameSimplifier.h b/libyul/optimiser/NameSimplifier.h deleted file mode 100644 index f3426d60f8f8..000000000000 --- a/libyul/optimiser/NameSimplifier.h +++ /dev/null @@ -1,72 +0,0 @@ -/* - This file is part of solidity. - - solidity is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - solidity is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with solidity. If not, see . -*/ -// SPDX-License-Identifier: GPL-3.0 - -#pragma once - -#include -#include -#include -#include - -#include -#include -#include - -namespace solidity::yul -{ - -class Dialect; - -/** - * Pass to "simplify" all identifier names. - * - * The purpose of this is to make generated code more readable, but also - * to remove AST identifiers that could lead to a different sorting order - * and thus influence e.g. the order of function inlining. - * - * Prerequisites: Disambiguator, FunctionHoister, FunctionGrouper - */ -class NameSimplifier: public ASTModifier -{ -public: - static constexpr char const* name{"NameSimplifier"}; - static void run(OptimiserStepContext& _context, Block& _ast) - { - NameSimplifier{_context, _ast}(_ast); - } - - using ASTModifier::operator(); - void operator()(VariableDeclaration& _varDecl) override; - void operator()(Identifier& _identifier) override; - void operator()(FunctionCall& _funCall) override; - void operator()(FunctionDefinition& _funDef) override; - -private: - NameSimplifier(OptimiserStepContext& _context, Block const& _ast); - - /// Tries to rename a list of variables. - void renameVariables(std::vector& _variables); - - void findSimplification(YulName const& _name); - void translate(YulName& _name); - - OptimiserStepContext& m_context; - std::map m_translations; -}; - -} diff --git a/libyul/optimiser/Suite.cpp b/libyul/optimiser/Suite.cpp index f0fecad59f87..7408ad46bfd3 100644 --- a/libyul/optimiser/Suite.cpp +++ b/libyul/optimiser/Suite.cpp @@ -61,7 +61,6 @@ #include #include #include -#include #include #include #include From e7f602195560f18aba8522c3abca2d04c12b3f58 Mon Sep 17 00:00:00 2001 From: clonker <1685266+clonker@users.noreply.github.com> Date: Wed, 12 Mar 2025 13:45:31 +0100 Subject: [PATCH 13/17] Remove YulString --- libsolc/libsolc.cpp | 1 - libsolidity/interface/StandardCompiler.cpp | 2 - libyul/CMakeLists.txt | 1 - libyul/Dialect.h | 1 - libyul/YulString.h | 182 ------------------ libyul/backends/evm/EVMDialect.cpp | 2 - libyul/optimiser/UnusedStoreBase.h | 1 - .../tools/ossfuzz/StackReuseCodegenFuzzer.cpp | 2 - .../ossfuzz/strictasm_assembly_ossfuzz.cpp | 2 - test/tools/ossfuzz/strictasm_diff_ossfuzz.cpp | 2 - test/tools/ossfuzz/strictasm_opt_ossfuzz.cpp | 2 - test/tools/ossfuzz/yulProtoFuzzer.cpp | 2 - test/tools/ossfuzz/yulProto_diff_ossfuzz.cpp | 2 - .../EVMInstructionInterpreter.h | 1 - 14 files changed, 203 deletions(-) delete mode 100644 libyul/YulString.h diff --git a/libsolc/libsolc.cpp b/libsolc/libsolc.cpp index 47dddb3aea08..02919d43cd92 100644 --- a/libsolc/libsolc.cpp +++ b/libsolc/libsolc.cpp @@ -153,7 +153,6 @@ extern void solidity_reset() noexcept { // This is called right before each compilation, but not at the end, so additional memory // can be freed here. - yul::YulStringRepository::reset(); solidityAllocations.clear(); } } diff --git a/libsolidity/interface/StandardCompiler.cpp b/libsolidity/interface/StandardCompiler.cpp index d5502228bda4..9f1131935839 100644 --- a/libsolidity/interface/StandardCompiler.cpp +++ b/libsolidity/interface/StandardCompiler.cpp @@ -1794,8 +1794,6 @@ Json StandardCompiler::compileYul(InputsAndSettings _inputsAndSettings) Json StandardCompiler::compile(Json const& _input) noexcept { - YulStringRepository::reset(); - try { auto parsed = parseInput(_input); diff --git a/libyul/CMakeLists.txt b/libyul/CMakeLists.txt index 255da1d1e2c7..32c0eea5048e 100644 --- a/libyul/CMakeLists.txt +++ b/libyul/CMakeLists.txt @@ -45,7 +45,6 @@ add_library(yul YulControlFlowGraphExporter.h YulControlFlowGraphExporter.cpp YulName.h - YulString.h backends/evm/AbstractAssembly.h backends/evm/AsmCodeGen.cpp backends/evm/AsmCodeGen.h diff --git a/libyul/Dialect.h b/libyul/Dialect.h index 2afd4a579288..013c8a9f1785 100644 --- a/libyul/Dialect.h +++ b/libyul/Dialect.h @@ -25,7 +25,6 @@ #include #include #include -#include #include #include diff --git a/libyul/YulString.h b/libyul/YulString.h deleted file mode 100644 index 329825a4465b..000000000000 --- a/libyul/YulString.h +++ /dev/null @@ -1,182 +0,0 @@ -/* - This file is part of solidity. - - solidity is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - solidity is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with solidity. If not, see . -*/ -// SPDX-License-Identifier: GPL-3.0 -/** - * String abstraction that avoids copies. - */ - -#pragma once - -#include - -#include -#include -#include -#include -#include -#include - -namespace solidity::yul -{ - -/// Repository for YulStrings. -/// Owns the string data for all YulStrings, which can be referenced by a Handle. -/// A Handle consists of an ID (that depends on the insertion order of YulStrings and is potentially -/// non-deterministic) and a deterministic string hash. -class YulStringRepository -{ -public: - struct Handle - { - size_t id; - std::uint64_t hash; - }; - - static YulStringRepository& instance() - { - static YulStringRepository inst; - return inst; - } - - Handle stringToHandle(std::string_view const _string) - { - if (_string.empty()) - return { 0, emptyHash() }; - std::uint64_t h = hash(_string); - auto range = m_hashToID.equal_range(h); - for (auto it = range.first; it != range.second; ++it) - if (*m_strings[it->second] == _string) - return Handle{it->second, h}; - m_strings.emplace_back(std::make_shared(_string)); - size_t id = m_strings.size() - 1; - m_hashToID.emplace_hint(range.second, std::make_pair(h, id)); - - return Handle{id, h}; - } - std::string const& idToString(size_t _id) const { return *m_strings.at(_id); } - - static std::uint64_t hash(std::string_view const v) - { - // FNV hash - can be replaced by a better one, e.g. xxhash64 - std::uint64_t hash = emptyHash(); - for (char c: v) - { - hash *= 1099511628211u; - hash ^= static_cast(c); - } - - return hash; - } - static constexpr std::uint64_t emptyHash() { return 14695981039346656037u; } - /// Clear the repository. - /// Use with care - there cannot be any dangling YulString references. - /// If references need to be cleared manually, register the callback via - /// resetCallback. - static void reset() - { - for (auto const& cb: resetCallbacks()) - cb(); - instance() = YulStringRepository{}; - } - /// Struct that registers a reset callback as a side-effect of its construction. - /// Useful as static local variable to register a reset callback once. - struct ResetCallback - { - ResetCallback(std::function _fun) - { - YulStringRepository::resetCallbacks().emplace_back(std::move(_fun)); - } - }; - -private: - YulStringRepository() = default; - YulStringRepository(YulStringRepository const&) = delete; - YulStringRepository(YulStringRepository&&) = default; - YulStringRepository& operator=(YulStringRepository const& _rhs) = delete; - YulStringRepository& operator=(YulStringRepository&& _rhs) = default; - - static std::vector>& resetCallbacks() - { - static std::vector> callbacks; - return callbacks; - } - - std::vector> m_strings = {std::make_shared()}; - std::unordered_multimap m_hashToID = {{emptyHash(), 0}}; -}; - -/// Wrapper around handles into the YulString repository. -/// Equality of two YulStrings is determined by comparing their ID. -/// The <-operator depends on the string hash and is not consistent -/// with string comparisons (however, it is still deterministic). -class YulString -{ -public: - YulString() = default; - explicit YulString(std::string_view const _s): m_handle(YulStringRepository::instance().stringToHandle(_s)) {} - YulString(YulString const&) = default; - YulString(YulString&&) = default; - YulString& operator=(YulString const&) = default; - YulString& operator=(YulString&&) = default; - - /// This is not consistent with the string <-operator! - /// First compares the string hashes. If they are equal - /// it checks for identical IDs (only identical strings have - /// identical IDs and identical strings do not compare as "less"). - /// If the hashes are identical and the strings are distinct, it - /// falls back to string comparison. - bool operator<(YulString const& _other) const - { - if (m_handle.hash < _other.m_handle.hash) return true; - if (_other.m_handle.hash < m_handle.hash) return false; - if (m_handle.id == _other.m_handle.id) return false; - return str() < _other.str(); - } - /// Equality is determined based on the string ID. - bool operator==(YulString const& _other) const { return m_handle.id == _other.m_handle.id; } - bool operator!=(YulString const& _other) const { return m_handle.id != _other.m_handle.id; } - - bool empty() const { return m_handle.id == 0; } - std::string const& str() const - { - return YulStringRepository::instance().idToString(m_handle.id); - } - - uint64_t hash() const { return m_handle.hash; } - -private: - /// Handle of the string. Assumes that the empty string has ID zero. - YulStringRepository::Handle m_handle{ 0, YulStringRepository::emptyHash() }; -}; - -inline YulString operator "" _yulname(char const* _string, std::size_t _size) -{ - return YulString(std::string_view(_string, _size)); -} - -} - -namespace std -{ -template<> struct hash -{ - size_t operator()(solidity::yul::YulString const& x) const - { - return static_cast(x.hash()); - } -}; -} diff --git a/libyul/backends/evm/EVMDialect.cpp b/libyul/backends/evm/EVMDialect.cpp index 147fd619393b..b45e794f496b 100644 --- a/libyul/backends/evm/EVMDialect.cpp +++ b/libyul/backends/evm/EVMDialect.cpp @@ -546,7 +546,6 @@ bool EVMDialect::reservedIdentifier(std::string_view _name) const EVMDialect const& EVMDialect::strictAssemblyForEVM(langutil::EVMVersion _evmVersion, std::optional _eofVersion) { static std::map>, std::unique_ptr> dialects; - static YulStringRepository::ResetCallback callback{[&] { dialects.clear(); }}; if (!dialects[{_evmVersion, _eofVersion}]) dialects[{_evmVersion, _eofVersion}] = std::make_unique(_evmVersion, _eofVersion, false); return *dialects[{_evmVersion, _eofVersion}]; @@ -555,7 +554,6 @@ EVMDialect const& EVMDialect::strictAssemblyForEVM(langutil::EVMVersion _evmVers EVMDialect const& EVMDialect::strictAssemblyForEVMObjects(langutil::EVMVersion _evmVersion, std::optional _eofVersion) { static std::map>, std::unique_ptr> dialects; - static YulStringRepository::ResetCallback callback{[&] { dialects.clear(); }}; if (!dialects[{_evmVersion, _eofVersion}]) dialects[{_evmVersion, _eofVersion}] = std::make_unique(_evmVersion, _eofVersion, true); return *dialects[{_evmVersion, _eofVersion}]; diff --git a/libyul/optimiser/UnusedStoreBase.h b/libyul/optimiser/UnusedStoreBase.h index 2c51224c0f39..cf9cdc5a7cfc 100644 --- a/libyul/optimiser/UnusedStoreBase.h +++ b/libyul/optimiser/UnusedStoreBase.h @@ -100,6 +100,5 @@ class UnusedStoreBase: public ASTWalker }; enum class UnusedStoreEliminatorKey { Memory, Storage }; -extern template class UnusedStoreBase; extern template class UnusedStoreBase; } diff --git a/test/tools/ossfuzz/StackReuseCodegenFuzzer.cpp b/test/tools/ossfuzz/StackReuseCodegenFuzzer.cpp index 71a4ff54a9f4..ccc04458a3ff 100644 --- a/test/tools/ossfuzz/StackReuseCodegenFuzzer.cpp +++ b/test/tools/ossfuzz/StackReuseCodegenFuzzer.cpp @@ -91,8 +91,6 @@ DEFINE_PROTO_FUZZER(Program const& _input) of.write(yul_source.data(), static_cast(yul_source.size())); } - YulStringRepository::reset(); - solidity::frontend::OptimiserSettings settings = solidity::frontend::OptimiserSettings::full(); settings.runYulOptimiser = false; settings.optimizeStackAllocation = false; diff --git a/test/tools/ossfuzz/strictasm_assembly_ossfuzz.cpp b/test/tools/ossfuzz/strictasm_assembly_ossfuzz.cpp index 5a9192bc3a05..4c78adc6b3e4 100644 --- a/test/tools/ossfuzz/strictasm_assembly_ossfuzz.cpp +++ b/test/tools/ossfuzz/strictasm_assembly_ossfuzz.cpp @@ -33,8 +33,6 @@ extern "C" int LLVMFuzzerTestOneInput(uint8_t const* _data, size_t _size) if (_size > 600) return 0; - YulStringRepository::reset(); - std::string input(reinterpret_cast(_data), _size); YulStack stack( langutil::EVMVersion(), diff --git a/test/tools/ossfuzz/strictasm_diff_ossfuzz.cpp b/test/tools/ossfuzz/strictasm_diff_ossfuzz.cpp index 9abf269c869a..ce7e8f42ce38 100644 --- a/test/tools/ossfuzz/strictasm_diff_ossfuzz.cpp +++ b/test/tools/ossfuzz/strictasm_diff_ossfuzz.cpp @@ -58,8 +58,6 @@ extern "C" int LLVMFuzzerTestOneInput(uint8_t const* _data, size_t _size) })) return 0; - YulStringRepository::reset(); - YulStack stack( langutil::EVMVersion(), std::nullopt, diff --git a/test/tools/ossfuzz/strictasm_opt_ossfuzz.cpp b/test/tools/ossfuzz/strictasm_opt_ossfuzz.cpp index 4543804926ee..f6686d658fe1 100644 --- a/test/tools/ossfuzz/strictasm_opt_ossfuzz.cpp +++ b/test/tools/ossfuzz/strictasm_opt_ossfuzz.cpp @@ -34,8 +34,6 @@ extern "C" int LLVMFuzzerTestOneInput(uint8_t const* _data, size_t _size) if (_size > 600) return 0; - YulStringRepository::reset(); - std::string input(reinterpret_cast(_data), _size); YulStack stack( langutil::EVMVersion(), diff --git a/test/tools/ossfuzz/yulProtoFuzzer.cpp b/test/tools/ossfuzz/yulProtoFuzzer.cpp index 2f372c3254c1..ae1eacca4199 100644 --- a/test/tools/ossfuzz/yulProtoFuzzer.cpp +++ b/test/tools/ossfuzz/yulProtoFuzzer.cpp @@ -58,8 +58,6 @@ DEFINE_PROTO_FUZZER(Program const& _input) if (yul_source.size() > 1200) return; - YulStringRepository::reset(); - // YulStack entry point YulStack stack( version, diff --git a/test/tools/ossfuzz/yulProto_diff_ossfuzz.cpp b/test/tools/ossfuzz/yulProto_diff_ossfuzz.cpp index 4edfbf7ba4ee..bde8ff849291 100644 --- a/test/tools/ossfuzz/yulProto_diff_ossfuzz.cpp +++ b/test/tools/ossfuzz/yulProto_diff_ossfuzz.cpp @@ -58,8 +58,6 @@ DEFINE_PROTO_FUZZER(Program const& _input) of.write(yul_source.data(), static_cast(yul_source.size())); } - YulStringRepository::reset(); - // YulStack entry point YulStack stack( version, diff --git a/test/tools/yulInterpreter/EVMInstructionInterpreter.h b/test/tools/yulInterpreter/EVMInstructionInterpreter.h index d3d221112991..1c1651fbf2dd 100644 --- a/test/tools/yulInterpreter/EVMInstructionInterpreter.h +++ b/test/tools/yulInterpreter/EVMInstructionInterpreter.h @@ -38,7 +38,6 @@ enum class Instruction: uint8_t; namespace solidity::yul { -class YulString; struct BuiltinFunctionForEVM; } From 9a8a115a438f022032575826da6237f778bf6004 Mon Sep 17 00:00:00 2001 From: clonker <1685266+clonker@users.noreply.github.com> Date: Wed, 12 Mar 2025 13:45:57 +0100 Subject: [PATCH 14/17] Remove NameDispenser --- libyul/CMakeLists.txt | 2 - libyul/optimiser/NameDispenser.cpp | 68 ----------------------------- libyul/optimiser/NameDispenser.h | 70 ------------------------------ libyul/optimiser/SSATransform.h | 2 - 4 files changed, 142 deletions(-) delete mode 100644 libyul/optimiser/NameDispenser.cpp delete mode 100644 libyul/optimiser/NameDispenser.h diff --git a/libyul/CMakeLists.txt b/libyul/CMakeLists.txt index 32c0eea5048e..617042aea2aa 100644 --- a/libyul/CMakeLists.txt +++ b/libyul/CMakeLists.txt @@ -154,8 +154,6 @@ add_library(yul optimiser/Metrics.h optimiser/NameCollector.cpp optimiser/NameCollector.h - optimiser/NameDispenser.cpp - optimiser/NameDispenser.h optimiser/NameDisplacer.cpp optimiser/NameDisplacer.h optimiser/OptimiserStep.h diff --git a/libyul/optimiser/NameDispenser.cpp b/libyul/optimiser/NameDispenser.cpp deleted file mode 100644 index 3493c36682df..000000000000 --- a/libyul/optimiser/NameDispenser.cpp +++ /dev/null @@ -1,68 +0,0 @@ -/* - This file is part of solidity. - - solidity is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - solidity is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with solidity. If not, see . -*/ -// SPDX-License-Identifier: GPL-3.0 -/** - * Optimiser component that can create new unique names. - */ - -#include - -#include -#include -#include -#include - -#include - -using namespace solidity; -using namespace solidity::yul; -using namespace solidity::util; - -NameDispenser::NameDispenser(Dialect const& _dialect, Block const& _ast, std::set _reservedNames): - NameDispenser(_dialect, NameCollector(_ast).names() + _reservedNames) -{ - m_reservedNames = std::move(_reservedNames); -} - -NameDispenser::NameDispenser(Dialect const& _dialect, std::set _usedNames): - m_dialect(_dialect), - m_usedNames(std::move(_usedNames)) -{ -} - -YulName NameDispenser::newName(YulName _nameHint) -{ - YulName name = _nameHint; - while (illegalName(name)) - { - m_counter++; - name = YulName(_nameHint.str() + "_" + std::to_string(m_counter)); - } - m_usedNames.emplace(name); - return name; -} - -bool NameDispenser::illegalName(YulName _name) -{ - return isRestrictedIdentifier(m_dialect, _name.str()) || m_usedNames.contains(_name); -} - -void NameDispenser::reset(Block const& _ast) -{ - m_usedNames = NameCollector(_ast).names() + m_reservedNames; - m_counter = 0; -} diff --git a/libyul/optimiser/NameDispenser.h b/libyul/optimiser/NameDispenser.h deleted file mode 100644 index ec936d39af1b..000000000000 --- a/libyul/optimiser/NameDispenser.h +++ /dev/null @@ -1,70 +0,0 @@ -/* - This file is part of solidity. - - solidity is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - solidity is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with solidity. If not, see . -*/ -// SPDX-License-Identifier: GPL-3.0 -/** - * Optimiser component that can create new unique names. - */ -#pragma once - -#include - -#include - -#include - -namespace solidity::yul -{ -class Dialect; - -/** - * Optimizer component that can be used to generate new names that - * do not conflict with existing names. - * - * Tries to keep names short and appends decimals to disambiguate. - */ -class NameDispenser -{ -public: - /// Initialize the name dispenser with all the names used in the given AST. - explicit NameDispenser(Dialect const& _dialect, Block const& _ast, std::set _reservedNames = {}); - /// Initialize the name dispenser with the given used names. - explicit NameDispenser(Dialect const& _dialect, std::set _usedNames); - - /// @returns a currently unused name that should be similar to _nameHint. - YulName newName(YulName _nameHint); - - /// Mark @a _name as used, i.e. the dispenser's newName function will not - /// return it. - void markUsed(YulName _name) { m_usedNames.insert(_name); } - - std::set const& usedNames() { return m_usedNames; } - - /// Returns true if `_name` is either used or is a restricted identifier. - bool illegalName(YulName _name); - - /// Resets `m_usedNames` with *only* the names that are used in the AST. Also resets value of - /// `m_counter` to zero. - void reset(Block const& _ast); - -private: - Dialect const& m_dialect; - std::set m_usedNames; - std::set m_reservedNames; - size_t m_counter = 0; -}; - -} diff --git a/libyul/optimiser/SSATransform.h b/libyul/optimiser/SSATransform.h index 4b46d7169f80..53a784b045ff 100644 --- a/libyul/optimiser/SSATransform.h +++ b/libyul/optimiser/SSATransform.h @@ -32,8 +32,6 @@ namespace solidity::yul { -class NameDispenser; - /** * Optimizer stage that tries to replace repeated assignments to * existing variables by declarations of new variables as much as From ce6fc4a2182084f000d3020c27762bfcfc2b30ca Mon Sep 17 00:00:00 2001 From: clonker <1685266+clonker@users.noreply.github.com> Date: Fri, 21 Mar 2025 15:29:07 +0100 Subject: [PATCH 15/17] Remove YulName header --- libsolc/libsolc.cpp | 1 - libsolidity/codegen/CompilerContext.cpp | 1 - libsolidity/codegen/ContractCompiler.cpp | 1 - libsolidity/interface/CompilerStack.cpp | 1 - libyul/AST.h | 1 - libyul/ASTForward.h | 1 + libyul/AsmPrinter.h | 1 - libyul/CMakeLists.txt | 1 - libyul/Exceptions.h | 4 +-- libyul/ObjectOptimizer.h | 1 + libyul/Scope.cpp | 1 - libyul/Scope.h | 9 +++---- libyul/YulName.h | 26 ------------------- libyul/backends/evm/ConstantOptimiser.h | 1 - libyul/optimiser/ASTCopier.h | 2 -- libyul/optimiser/ASTWalker.h | 1 - libyul/optimiser/BlockHasher.h | 1 - libyul/optimiser/CircularReferencesPruner.h | 1 - libyul/optimiser/DataFlowAnalyzer.h | 1 - libyul/optimiser/DeadCodeEliminator.h | 1 - libyul/optimiser/ExpressionInliner.h | 1 - libyul/optimiser/FullInliner.h | 1 + libyul/optimiser/FunctionSpecializer.cpp | 1 - libyul/optimiser/KnowledgeBase.h | 2 +- libyul/optimiser/NameCollector.h | 1 - libyul/optimiser/SimplificationRules.h | 1 - libyul/optimiser/StackToMemoryMover.h | 1 - libyul/optimiser/Substitution.h | 1 - libyul/optimiser/Suite.h | 1 - libyul/optimiser/SyntacticalEquality.h | 1 - .../UnusedFunctionParameterPruner.cpp | 2 -- libyul/optimiser/UnusedPruner.h | 1 - test/libyul/YulOptimizerTestCommon.h | 2 -- tools/yulPhaser/Program.cpp | 1 - 34 files changed, 9 insertions(+), 65 deletions(-) delete mode 100644 libyul/YulName.h diff --git a/libsolc/libsolc.cpp b/libsolc/libsolc.cpp index 02919d43cd92..b4cbf23bd2ad 100644 --- a/libsolc/libsolc.cpp +++ b/libsolc/libsolc.cpp @@ -24,7 +24,6 @@ #include #include #include -#include #include #include diff --git a/libsolidity/codegen/CompilerContext.cpp b/libsolidity/codegen/CompilerContext.cpp index 2ba0353dffba..c4e9b89ee031 100644 --- a/libsolidity/codegen/CompilerContext.cpp +++ b/libsolidity/codegen/CompilerContext.cpp @@ -38,7 +38,6 @@ #include #include #include -#include #include #include diff --git a/libsolidity/codegen/ContractCompiler.cpp b/libsolidity/codegen/ContractCompiler.cpp index d1bfaaaf2fa6..8c223f3eacaf 100644 --- a/libsolidity/codegen/ContractCompiler.cpp +++ b/libsolidity/codegen/ContractCompiler.cpp @@ -38,7 +38,6 @@ #include #include #include -#include #include #include diff --git a/libsolidity/interface/CompilerStack.cpp b/libsolidity/interface/CompilerStack.cpp index 98aaf43b0681..eff4bb78ff95 100644 --- a/libsolidity/interface/CompilerStack.cpp +++ b/libsolidity/interface/CompilerStack.cpp @@ -66,7 +66,6 @@ #include -#include #include #include #include diff --git a/libyul/AST.h b/libyul/AST.h index 2288713c205f..5c65501d81dd 100644 --- a/libyul/AST.h +++ b/libyul/AST.h @@ -26,7 +26,6 @@ #include #include #include -#include #include diff --git a/libyul/ASTForward.h b/libyul/ASTForward.h index 6009fc1956da..7ea42173ca77 100644 --- a/libyul/ASTForward.h +++ b/libyul/ASTForward.h @@ -30,6 +30,7 @@ namespace solidity::yul using YulName = std::size_t; +class ASTLabelRegistry; enum class LiteralKind; class LiteralValue; struct Literal; diff --git a/libyul/AsmPrinter.h b/libyul/AsmPrinter.h index 1303def7b27c..f0ce7efa754c 100644 --- a/libyul/AsmPrinter.h +++ b/libyul/AsmPrinter.h @@ -24,7 +24,6 @@ #pragma once #include -#include #include diff --git a/libyul/CMakeLists.txt b/libyul/CMakeLists.txt index 617042aea2aa..a798407e166c 100644 --- a/libyul/CMakeLists.txt +++ b/libyul/CMakeLists.txt @@ -44,7 +44,6 @@ add_library(yul Utilities.h YulControlFlowGraphExporter.h YulControlFlowGraphExporter.cpp - YulName.h backends/evm/AbstractAssembly.h backends/evm/AsmCodeGen.cpp backends/evm/AsmCodeGen.h diff --git a/libyul/Exceptions.h b/libyul/Exceptions.h index 9d0a13007ce3..81e2f8f166a9 100644 --- a/libyul/Exceptions.h +++ b/libyul/Exceptions.h @@ -21,11 +21,11 @@ #pragma once +#include + #include #include -#include - #include #include #include diff --git a/libyul/ObjectOptimizer.h b/libyul/ObjectOptimizer.h index c1884d9820ee..ab2775efbe73 100644 --- a/libyul/ObjectOptimizer.h +++ b/libyul/ObjectOptimizer.h @@ -19,6 +19,7 @@ #pragma once #include +#include #include #include diff --git a/libyul/Scope.cpp b/libyul/Scope.cpp index a73b2f9fd07e..17b8f1c1f90e 100644 --- a/libyul/Scope.cpp +++ b/libyul/Scope.cpp @@ -23,7 +23,6 @@ using namespace solidity; using namespace solidity::yul; -using namespace solidity::util; bool Scope::registerVariable(YulName _name) { diff --git a/libyul/Scope.h b/libyul/Scope.h index 20850cc56f09..201d2a043169 100644 --- a/libyul/Scope.h +++ b/libyul/Scope.h @@ -21,13 +21,10 @@ #pragma once -#include +#include -#include - -#include -#include -#include +#include +#include #include namespace solidity::yul diff --git a/libyul/YulName.h b/libyul/YulName.h deleted file mode 100644 index afd63c12f664..000000000000 --- a/libyul/YulName.h +++ /dev/null @@ -1,26 +0,0 @@ -/* - This file is part of solidity. - - solidity is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - solidity is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with solidity. If not, see . -*/ -// SPDX-License-Identifier: GPL-3.0 - -#pragma once - -#include - -namespace solidity::yul -{ -using YulName = ASTLabelRegistry::LabelID; -} diff --git a/libyul/backends/evm/ConstantOptimiser.h b/libyul/backends/evm/ConstantOptimiser.h index 9c25450bf96f..b0588a1039fd 100644 --- a/libyul/backends/evm/ConstantOptimiser.h +++ b/libyul/backends/evm/ConstantOptimiser.h @@ -22,7 +22,6 @@ #pragma once #include -#include #include #include #include diff --git a/libyul/optimiser/ASTCopier.h b/libyul/optimiser/ASTCopier.h index e1c3a16aa3ea..29b0c73f3de3 100644 --- a/libyul/optimiser/ASTCopier.h +++ b/libyul/optimiser/ASTCopier.h @@ -23,8 +23,6 @@ #include -#include - #include #include #include diff --git a/libyul/optimiser/ASTWalker.h b/libyul/optimiser/ASTWalker.h index 0c23a836e624..a158593a93b9 100644 --- a/libyul/optimiser/ASTWalker.h +++ b/libyul/optimiser/ASTWalker.h @@ -24,7 +24,6 @@ #include #include -#include #include #include diff --git a/libyul/optimiser/BlockHasher.h b/libyul/optimiser/BlockHasher.h index 12c1c5e72b19..9d06a32de385 100644 --- a/libyul/optimiser/BlockHasher.h +++ b/libyul/optimiser/BlockHasher.h @@ -22,7 +22,6 @@ #include #include -#include namespace solidity::yul { diff --git a/libyul/optimiser/CircularReferencesPruner.h b/libyul/optimiser/CircularReferencesPruner.h index 090b0617fc8e..db7ef7b8310e 100644 --- a/libyul/optimiser/CircularReferencesPruner.h +++ b/libyul/optimiser/CircularReferencesPruner.h @@ -27,7 +27,6 @@ #include #include #include -#include namespace solidity::yul { diff --git a/libyul/optimiser/DataFlowAnalyzer.h b/libyul/optimiser/DataFlowAnalyzer.h index 5b4ddab2537c..89916faf9702 100644 --- a/libyul/optimiser/DataFlowAnalyzer.h +++ b/libyul/optimiser/DataFlowAnalyzer.h @@ -25,7 +25,6 @@ #include #include -#include #include // Needed for m_zero below. #include diff --git a/libyul/optimiser/DeadCodeEliminator.h b/libyul/optimiser/DeadCodeEliminator.h index 701af3ad1561..7fcf82d90752 100644 --- a/libyul/optimiser/DeadCodeEliminator.h +++ b/libyul/optimiser/DeadCodeEliminator.h @@ -22,7 +22,6 @@ #pragma once #include -#include #include #include diff --git a/libyul/optimiser/ExpressionInliner.h b/libyul/optimiser/ExpressionInliner.h index f8cf70d56e13..33007fd8bd70 100644 --- a/libyul/optimiser/ExpressionInliner.h +++ b/libyul/optimiser/ExpressionInliner.h @@ -22,7 +22,6 @@ #include #include -#include #include #include diff --git a/libyul/optimiser/FullInliner.h b/libyul/optimiser/FullInliner.h index 7ca35b6ebd8d..7455ef954686 100644 --- a/libyul/optimiser/FullInliner.h +++ b/libyul/optimiser/FullInliner.h @@ -21,6 +21,7 @@ #pragma once #include +#include #include #include diff --git a/libyul/optimiser/FunctionSpecializer.cpp b/libyul/optimiser/FunctionSpecializer.cpp index 300c12ecdbcc..c0c5cdf8196b 100644 --- a/libyul/optimiser/FunctionSpecializer.cpp +++ b/libyul/optimiser/FunctionSpecializer.cpp @@ -24,7 +24,6 @@ #include #include -#include #include #include diff --git a/libyul/optimiser/KnowledgeBase.h b/libyul/optimiser/KnowledgeBase.h index 8ae7f9abcff0..717da4a85bd5 100644 --- a/libyul/optimiser/KnowledgeBase.h +++ b/libyul/optimiser/KnowledgeBase.h @@ -22,8 +22,8 @@ #pragma once #include +#include #include -#include #include #include diff --git a/libyul/optimiser/NameCollector.h b/libyul/optimiser/NameCollector.h index 2adc73ced8e3..aef452eb09bd 100644 --- a/libyul/optimiser/NameCollector.h +++ b/libyul/optimiser/NameCollector.h @@ -22,7 +22,6 @@ #pragma once #include -#include #include #include diff --git a/libyul/optimiser/SimplificationRules.h b/libyul/optimiser/SimplificationRules.h index f4b584b99ca4..c445e8516b2f 100644 --- a/libyul/optimiser/SimplificationRules.h +++ b/libyul/optimiser/SimplificationRules.h @@ -25,7 +25,6 @@ #include #include -#include #include #include diff --git a/libyul/optimiser/StackToMemoryMover.h b/libyul/optimiser/StackToMemoryMover.h index c31a100632f5..5c74c1ff79c3 100644 --- a/libyul/optimiser/StackToMemoryMover.h +++ b/libyul/optimiser/StackToMemoryMover.h @@ -23,7 +23,6 @@ #include #include #include -#include #include #include diff --git a/libyul/optimiser/Substitution.h b/libyul/optimiser/Substitution.h index 2d4ccffc0148..055e749f1df6 100644 --- a/libyul/optimiser/Substitution.h +++ b/libyul/optimiser/Substitution.h @@ -22,7 +22,6 @@ #pragma once #include -#include #include diff --git a/libyul/optimiser/Suite.h b/libyul/optimiser/Suite.h index 39f33e61c065..16bdb0fcadea 100644 --- a/libyul/optimiser/Suite.h +++ b/libyul/optimiser/Suite.h @@ -22,7 +22,6 @@ #pragma once #include -#include #include #include diff --git a/libyul/optimiser/SyntacticalEquality.h b/libyul/optimiser/SyntacticalEquality.h index 0bdffce927dd..511a6b711492 100644 --- a/libyul/optimiser/SyntacticalEquality.h +++ b/libyul/optimiser/SyntacticalEquality.h @@ -22,7 +22,6 @@ #pragma once #include -#include #include #include diff --git a/libyul/optimiser/UnusedFunctionParameterPruner.cpp b/libyul/optimiser/UnusedFunctionParameterPruner.cpp index 49c0a9c4d427..f9f780757442 100644 --- a/libyul/optimiser/UnusedFunctionParameterPruner.cpp +++ b/libyul/optimiser/UnusedFunctionParameterPruner.cpp @@ -25,8 +25,6 @@ #include #include #include -#include -#include #include #include diff --git a/libyul/optimiser/UnusedPruner.h b/libyul/optimiser/UnusedPruner.h index cd9a7e341d7f..7bf0a88101e6 100644 --- a/libyul/optimiser/UnusedPruner.h +++ b/libyul/optimiser/UnusedPruner.h @@ -23,7 +23,6 @@ #include #include -#include #include #include diff --git a/test/libyul/YulOptimizerTestCommon.h b/test/libyul/YulOptimizerTestCommon.h index b6881d5d97eb..b24754bc5998 100644 --- a/test/libyul/YulOptimizerTestCommon.h +++ b/test/libyul/YulOptimizerTestCommon.h @@ -21,8 +21,6 @@ #include #include -#include - #include #include diff --git a/tools/yulPhaser/Program.cpp b/tools/yulPhaser/Program.cpp index ba4aea0bf18d..3bd6563d602a 100644 --- a/tools/yulPhaser/Program.cpp +++ b/tools/yulPhaser/Program.cpp @@ -28,7 +28,6 @@ #include #include #include -#include #include #include #include From 5bf8e5d48f3e6f72447a719e8ceaa0382948e3d8 Mon Sep 17 00:00:00 2001 From: clonker <1685266+clonker@users.noreply.github.com> Date: Fri, 21 Mar 2025 14:35:40 +0100 Subject: [PATCH 16/17] Remove Yul VarNameCleaner --- libyul/CMakeLists.txt | 2 - libyul/optimiser/Suite.cpp | 2 - libyul/optimiser/VarNameCleaner.cpp | 125 ------------------------- libyul/optimiser/VarNameCleaner.h | 100 -------------------- test/libyul/YulOptimizerTestCommon.cpp | 1 - test/tools/yulopti.cpp | 7 -- 6 files changed, 237 deletions(-) delete mode 100644 libyul/optimiser/VarNameCleaner.cpp delete mode 100644 libyul/optimiser/VarNameCleaner.h diff --git a/libyul/CMakeLists.txt b/libyul/CMakeLists.txt index a798407e166c..0febbc56a381 100644 --- a/libyul/CMakeLists.txt +++ b/libyul/CMakeLists.txt @@ -198,8 +198,6 @@ add_library(yul optimiser/UnusedPruner.h optimiser/VarDeclInitializer.cpp optimiser/VarDeclInitializer.h - optimiser/VarNameCleaner.cpp - optimiser/VarNameCleaner.h ) target_link_libraries(yul PUBLIC evmasm solutil langutil smtutil fmt::fmt-header-only) diff --git a/libyul/optimiser/Suite.cpp b/libyul/optimiser/Suite.cpp index 7408ad46bfd3..a45b759dbad5 100644 --- a/libyul/optimiser/Suite.cpp +++ b/libyul/optimiser/Suite.cpp @@ -57,7 +57,6 @@ #include #include #include -#include #include #include #include @@ -260,7 +259,6 @@ std::map> const& OptimiserSuite::all UnusedPruner, VarDeclInitializer >(); - // Does not include VarNameCleaner because it destroys the property of unique names. // Does not include NameSimplifier. return instance; } diff --git a/libyul/optimiser/VarNameCleaner.cpp b/libyul/optimiser/VarNameCleaner.cpp deleted file mode 100644 index 8d34ce85e408..000000000000 --- a/libyul/optimiser/VarNameCleaner.cpp +++ /dev/null @@ -1,125 +0,0 @@ -/* - This file is part of solidity. - - solidity is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - solidity is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with solidity. If not, see . -*/ -// SPDX-License-Identifier: GPL-3.0 - -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -using namespace solidity::yul; - -VarNameCleaner::VarNameCleaner( - Block const& _ast, - Dialect const& _dialect, - std::set _namesToKeep -): - m_dialect{_dialect}, - m_namesToKeep{std::move(_namesToKeep)}, - m_translatedNames{} -{ - for (auto const& statement: _ast.statements) - if (std::holds_alternative(statement)) - m_namesToKeep.insert(std::get(statement).name); - m_usedNames = m_namesToKeep; -} - -void VarNameCleaner::operator()(FunctionDefinition& _funDef) -{ - yulAssert(!m_insideFunction, ""); - m_insideFunction = true; - - std::set globalUsedNames = std::move(m_usedNames); - m_usedNames = m_namesToKeep; - std::map globalTranslatedNames; - swap(globalTranslatedNames, m_translatedNames); - - renameVariables(_funDef.parameters); - renameVariables(_funDef.returnVariables); - ASTModifier::operator()(_funDef); - - swap(globalUsedNames, m_usedNames); - swap(globalTranslatedNames, m_translatedNames); - - m_insideFunction = false; -} - -void VarNameCleaner::operator()(VariableDeclaration& _varDecl) -{ - renameVariables(_varDecl.variables); - ASTModifier::operator()(_varDecl); -} - -void VarNameCleaner::renameVariables(std::vector& _variables) -{ - for (NameWithDebugData& variable: _variables) - { - auto newName = findCleanName(variable.name); - if (newName != variable.name) - { - m_translatedNames[variable.name] = newName; - variable.name = newName; - } - m_usedNames.insert(variable.name); - } -} - -void VarNameCleaner::operator()(Identifier& _identifier) -{ - auto name = m_translatedNames.find(_identifier.name); - if (name != m_translatedNames.end()) - _identifier.name = name->second; -} - -YulName VarNameCleaner::findCleanName(YulName const& _name) const -{ - auto newName = stripSuffix(_name); - if (!isUsedName(newName)) - return newName; - - // create new name with suffix (by finding a free identifier) - for (size_t i = 1; i < std::numeric_limits::max(); ++i) - { - YulName newNameSuffixed = YulName{newName.str() + "_" + std::to_string(i)}; - if (!isUsedName(newNameSuffixed)) - return newNameSuffixed; - } - yulAssert(false, "Exhausted by attempting to find an available suffix."); -} - -bool VarNameCleaner::isUsedName(YulName const& _name) const -{ - return isRestrictedIdentifier(m_dialect, _name.str()) || m_usedNames.contains(_name); -} - -YulName VarNameCleaner::stripSuffix(YulName const& _name) const -{ - static std::regex const suffixRegex("(_+[0-9]+)+$"); - - std::smatch suffixMatch; - if (regex_search(_name.str(), suffixMatch, suffixRegex)) - return {YulName{suffixMatch.prefix().str()}}; - return _name; -} diff --git a/libyul/optimiser/VarNameCleaner.h b/libyul/optimiser/VarNameCleaner.h deleted file mode 100644 index 47f3aca48db9..000000000000 --- a/libyul/optimiser/VarNameCleaner.h +++ /dev/null @@ -1,100 +0,0 @@ -/* - This file is part of solidity. - - solidity is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - solidity is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with solidity. If not, see . -*/ -// SPDX-License-Identifier: GPL-3.0 - -#pragma once - - -#include -#include -#include -#include - -#include -#include -#include - -namespace solidity::yul -{ - -class Dialect; - -/** - * Pass to normalize identifier suffixes. - * - * That is, for each function scope, nested suffixes get flattened and all suffixes - * renumbered by their base name. - * Function names are not modified. - * - * NOTE: This step destroys the promise of the Disambiguator and thus cannot - * be used in the main loop of the optimizer without running the disambiguator again. - * Because of that, it is not included in the step list of the Optimizer Suite. - * - * Prerequisites: Disambiguator, FunctionHoister, FunctionGrouper - */ -class VarNameCleaner: public ASTModifier -{ -public: - static constexpr char const* name{"VarNameCleaner"}; - static void run(OptimiserStepContext& _context, Block& _ast) - { - VarNameCleaner{_ast, _context.dialect, _context.reservedIdentifiers}(_ast); - } - - using ASTModifier::operator(); - void operator()(VariableDeclaration& _varDecl) override; - void operator()(Identifier& _identifier) override; - void operator()(FunctionDefinition& _funDef) override; - -private: - VarNameCleaner( - Block const& _ast, - Dialect const& _dialect, - std::set _namesToKeep = {} - ); - - /// Tries to rename a list of variables. - void renameVariables(std::vector& _variables); - - /// @returns suffix-stripped name, if a suffix was detected, none otherwise. - YulName stripSuffix(YulName const& _name) const; - - /// Looks out for a "clean name" the given @p name could be trimmed down to. - /// @returns a trimmed down and "clean name" in case it found one, none otherwise. - YulName findCleanName(YulName const& name) const; - - /// Tests whether a given name was already used within this pass - /// or was set to be kept. - bool isUsedName(YulName const& _name) const; - - Dialect const& m_dialect; - - /// These names will not be modified. - std::set m_namesToKeep; - - /// Set of names that are in use. - std::set m_usedNames; - - /// Maps old to new names. - std::map m_translatedNames; - - /// Whether the traverse is inside a function definition. - /// Used to assert that a function definition cannot be inside another. - bool m_insideFunction = false; -}; - -} diff --git a/test/libyul/YulOptimizerTestCommon.cpp b/test/libyul/YulOptimizerTestCommon.cpp index dd6b72fe01cd..4c96c283d724 100644 --- a/test/libyul/YulOptimizerTestCommon.cpp +++ b/test/libyul/YulOptimizerTestCommon.cpp @@ -22,7 +22,6 @@ #include #include -#include #include #include #include diff --git a/test/tools/yulopti.cpp b/test/tools/yulopti.cpp index bc73e7a41fd3..e931c3def033 100644 --- a/test/tools/yulopti.cpp +++ b/test/tools/yulopti.cpp @@ -35,7 +35,6 @@ #include #include #include -#include #include #include @@ -202,7 +201,6 @@ class YulOpti std::map const& extraOptions = { // QUIT starts with a non-letter character on purpose to get it to show up on top of the list {'#', ">>> QUIT <<<"}, - {',', "VarNameCleaner"}, {';', "StackCompressor"} }; @@ -219,11 +217,6 @@ class YulOpti case 4: case '#': return; - case ',': - VarNameCleaner::run(m_context, *m_astRoot); - // VarNameCleaner destroys the unique names guarantee of the disambiguator. - disambiguated = false; - break; case ';': { Object obj; From 8f02233e52b59398c240b6c40be3883fa5ac8f93 Mon Sep 17 00:00:00 2001 From: clonker <1685266+clonker@users.noreply.github.com> Date: Wed, 16 Apr 2025 08:55:12 +0200 Subject: [PATCH 17/17] Assert presence of `yulLabels` and `yulAnnotation` in references resolver --- libsolidity/analysis/ReferencesResolver.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libsolidity/analysis/ReferencesResolver.cpp b/libsolidity/analysis/ReferencesResolver.cpp index 3c5e3c88a7b9..54e9684ac36c 100644 --- a/libsolidity/analysis/ReferencesResolver.cpp +++ b/libsolidity/analysis/ReferencesResolver.cpp @@ -285,6 +285,8 @@ void ReferencesResolver::operator()(yul::FunctionDefinition const& _function) void ReferencesResolver::operator()(yul::Identifier const& _identifier) { + solAssert(m_yulLabels); + solAssert(m_yulAnnotation); solAssert(nativeLocationOf(_identifier) == originLocationOf(_identifier), ""); if (m_resolver.experimentalSolidity()) @@ -392,6 +394,7 @@ void ReferencesResolver::operator()(yul::Identifier const& _identifier) void ReferencesResolver::operator()(yul::VariableDeclaration const& _varDecl) { + solAssert(m_yulLabels); for (auto const& identifier: _varDecl.variables) { solAssert(nativeLocationOf(identifier) == originLocationOf(identifier), ""); @@ -491,6 +494,7 @@ void ReferencesResolver::resolveInheritDoc(StructuredDocumentation const& _docum void ReferencesResolver::validateYulIdentifierName(yul::YulName _name, SourceLocation const& _location) { + solAssert(m_yulLabels); std::string_view const label = (*m_yulLabels)[_name]; if (util::contains(label, '.')) m_errorReporter.declarationError(