diff --git a/libevmasm/Assembly.h b/libevmasm/Assembly.h index bd42fc785..1b35cfe38 100644 --- a/libevmasm/Assembly.h +++ b/libevmasm/Assembly.h @@ -49,7 +49,7 @@ using AssemblyPointer = std::shared_ptr; class Assembly { public: - Assembly(bool _creation, std::string _name): m_creation(_creation), m_name(std::move(_name)) { } + Assembly(langutil::EVMVersion _evmVersion, std::optional _eofVersion, bool _creation, std::string _name): m_creation(_creation), m_name(std::move(_name)), m_evmVersion(_evmVersion), m_eofVersion(_eofVersion) { } AssemblyItem newTag() { assertThrow(m_usedTags < 0xffffffff, AssemblyException, ""); return AssemblyItem(Tag, m_usedTags++); } AssemblyItem newPushTag() { assertThrow(m_usedTags < 0xffffffff, AssemblyException, ""); return AssemblyItem(PushTag, m_usedTags++); } @@ -93,11 +93,11 @@ public: } unsigned maxDup() const { - return 16; + return m_eofVersion.has_value() ? 256 : 16; } unsigned maxSwap() const { - return 16; + return m_eofVersion.has_value() ? 256 : 16; } AssemblyItem appendJump() { auto ret = append(newPushTag()); append(Instruction::JUMP); return ret; } @@ -234,8 +234,13 @@ protected: langutil::SourceLocation m_currentSourceLocation; + langutil::EVMVersion const m_evmVersion; + std::optional const m_eofVersion; public: size_t m_currentModifierDepth = 0; + + langutil::EVMVersion evmVersion() const { return m_evmVersion; } + std::optional eofVersion() const { return m_eofVersion; } }; inline std::ostream& operator<<(std::ostream& _out, Assembly const& _a) diff --git a/libsolidity/codegen/Compiler.h b/libsolidity/codegen/Compiler.h index 1267c1a2d..63e362e3f 100644 --- a/libsolidity/codegen/Compiler.h +++ b/libsolidity/codegen/Compiler.h @@ -37,10 +37,10 @@ namespace solidity::frontend class Compiler { public: - Compiler(langutil::EVMVersion _evmVersion, RevertStrings _revertStrings, OptimiserSettings _optimiserSettings): + Compiler(langutil::EVMVersion _evmVersion, std::optional _eofVersion, RevertStrings _revertStrings, OptimiserSettings _optimiserSettings): m_optimiserSettings(std::move(_optimiserSettings)), - m_runtimeContext(_evmVersion, _revertStrings), - m_context(_evmVersion, _revertStrings, &m_runtimeContext) + m_runtimeContext(_evmVersion, _eofVersion, _revertStrings), + m_context(_evmVersion, _eofVersion, _revertStrings, &m_runtimeContext) { } /// Compiles a contract. diff --git a/libsolidity/codegen/CompilerContext.cpp b/libsolidity/codegen/CompilerContext.cpp index 6d09fa143..f9ffeacec 100644 --- a/libsolidity/codegen/CompilerContext.cpp +++ b/libsolidity/codegen/CompilerContext.cpp @@ -549,7 +549,9 @@ void CompilerContext::optimizeYul(yul::Object& _object, yul::EVMDialect const& _ _optimiserSettings.yulOptimiserSteps, _optimiserSettings.yulOptimiserCleanupSteps, isCreation? nullopt : make_optional(_optimiserSettings.expectedExecutionsPerDeployment), - _externalIdentifiers + _externalIdentifiers, + m_asm->maxSwap(), + m_asm->maxDup() ); #ifdef SOL_OUTPUT_ASM diff --git a/libsolidity/codegen/CompilerContext.h b/libsolidity/codegen/CompilerContext.h index 3fcb87f47..c564a66d8 100644 --- a/libsolidity/codegen/CompilerContext.h +++ b/libsolidity/codegen/CompilerContext.h @@ -62,10 +62,11 @@ class CompilerContext public: explicit CompilerContext( langutil::EVMVersion _evmVersion, + std::optional _eofVersion, RevertStrings _revertStrings, CompilerContext* _runtimeContext = nullptr ): - m_asm(std::make_shared(_runtimeContext != nullptr, std::string{})), + m_asm(std::make_shared(_evmVersion, _eofVersion, _runtimeContext != nullptr, std::string{})), m_evmVersion(_evmVersion), m_revertStrings(_revertStrings), m_reservedMemory{0}, diff --git a/libsolidity/interface/CompilerStack.cpp b/libsolidity/interface/CompilerStack.cpp index 14fa3c528..7d1eeeff0 100644 --- a/libsolidity/interface/CompilerStack.cpp +++ b/libsolidity/interface/CompilerStack.cpp @@ -1333,7 +1333,7 @@ void CompilerStack::compileContract( Contract& compiledContract = m_contracts.at(_contract.fullyQualifiedName()); - shared_ptr compiler = make_shared(m_evmVersion, m_revertStrings, m_optimiserSettings); + shared_ptr compiler = make_shared(m_evmVersion, m_eofVersion, m_revertStrings, m_optimiserSettings); compiledContract.compiler = compiler; solAssert(!m_viaIR, ""); diff --git a/libyul/CompilabilityChecker.cpp b/libyul/CompilabilityChecker.cpp index 270773cbc..32b38211c 100644 --- a/libyul/CompilabilityChecker.cpp +++ b/libyul/CompilabilityChecker.cpp @@ -34,7 +34,9 @@ using namespace solidity::util; CompilabilityChecker::CompilabilityChecker( Dialect const& _dialect, Object const& _object, - bool _optimizeStackAllocation + bool _optimizeStackAllocation, + unsigned _maxDup, + unsigned _maxSwap ) { if (auto const* evmDialect = dynamic_cast(&_dialect)) @@ -50,7 +52,7 @@ CompilabilityChecker::CompilabilityChecker( builtinContext.subIDs[_object.name] = 1; for (auto const& subNode: _object.subObjects) builtinContext.subIDs[subNode->name] = 1; - NoOutputAssembly assembly; + NoOutputAssembly assembly(_maxSwap, _maxDup); CodeTransform transform( assembly, analysisInfo, diff --git a/libyul/CompilabilityChecker.h b/libyul/CompilabilityChecker.h index 307d719e4..c81b2d9c7 100644 --- a/libyul/CompilabilityChecker.h +++ b/libyul/CompilabilityChecker.h @@ -44,7 +44,7 @@ namespace solidity::yul */ struct CompilabilityChecker { - CompilabilityChecker(Dialect const& _dialect, Object const& _object, bool _optimizeStackAllocation); + CompilabilityChecker(Dialect const& _dialect, Object const& _object, bool _optimizeStackAllocation, unsigned _maxSwap, unsigned _maxDup); std::map> unreachableVariables; std::map stackDeficit; }; diff --git a/libyul/YulStack.cpp b/libyul/YulStack.cpp index b33026949..f1ac75dcf 100644 --- a/libyul/YulStack.cpp +++ b/libyul/YulStack.cpp @@ -179,6 +179,11 @@ void YulStack::optimize(Object& _object, bool _isCreation) } Dialect const& dialect = languageToDialect(m_language, m_evmVersion); + + // TODO + unsigned maxSwap = m_eofVersion.has_value() ? 256 : 16; + unsigned maxDup = m_eofVersion.has_value() ? 256 : 16; + unique_ptr meter; if (EVMDialect const* evmDialect = dynamic_cast(&dialect)) meter = make_unique(*evmDialect, _isCreation, m_optimiserSettings.expectedExecutionsPerDeployment); @@ -190,7 +195,9 @@ void YulStack::optimize(Object& _object, bool _isCreation) m_optimiserSettings.yulOptimiserSteps, m_optimiserSettings.yulOptimiserCleanupSteps, _isCreation ? nullopt : make_optional(m_optimiserSettings.expectedExecutionsPerDeployment), - {} + {}, + maxSwap, + maxDup ); } @@ -264,7 +271,7 @@ YulStack::assembleEVMWithDeployed(optional _deployName) const yulAssert(m_parserResult->code, ""); yulAssert(m_parserResult->analysisInfo, ""); - evmasm::Assembly assembly(true, {}); + evmasm::Assembly assembly(m_evmVersion, m_eofVersion, true, {}); EthAssemblyAdapter adapter(assembly); compileEVM(adapter, m_optimiserSettings.optimizeStackAllocation); diff --git a/libyul/backends/evm/EthAssemblyAdapter.cpp b/libyul/backends/evm/EthAssemblyAdapter.cpp index 157896c3e..2476419ce 100644 --- a/libyul/backends/evm/EthAssemblyAdapter.cpp +++ b/libyul/backends/evm/EthAssemblyAdapter.cpp @@ -146,7 +146,7 @@ void EthAssemblyAdapter::appendAssemblySize() pair, AbstractAssembly::SubID> EthAssemblyAdapter::createSubAssembly(bool _creation, string _name) { - shared_ptr assembly{make_shared(_creation, std::move(_name))}; + shared_ptr assembly{make_shared(m_assembly.evmVersion(), m_assembly.eofVersion(), _creation, std::move(_name))}; auto sub = m_assembly.newSub(assembly); return {make_shared(*assembly), static_cast(sub.data())}; } diff --git a/libyul/backends/evm/NoOutputAssembly.cpp b/libyul/backends/evm/NoOutputAssembly.cpp index a8b5c32cd..d60247d2e 100644 --- a/libyul/backends/evm/NoOutputAssembly.cpp +++ b/libyul/backends/evm/NoOutputAssembly.cpp @@ -50,11 +50,11 @@ void NoOutputAssembly::appendDup(unsigned) } unsigned NoOutputAssembly::maxDup() const { - return 16; + return m_maxDup; } unsigned NoOutputAssembly::maxSwap() const { - return 16; + return m_maxSwap; } void NoOutputAssembly::appendConstant(u256 const&) { diff --git a/libyul/backends/evm/NoOutputAssembly.h b/libyul/backends/evm/NoOutputAssembly.h index cdccda0fc..693802928 100644 --- a/libyul/backends/evm/NoOutputAssembly.h +++ b/libyul/backends/evm/NoOutputAssembly.h @@ -45,7 +45,7 @@ namespace solidity::yul class NoOutputAssembly: public AbstractAssembly { public: - explicit NoOutputAssembly() { } + explicit NoOutputAssembly(unsigned _maxSwap, unsigned _maxDup): m_maxSwap(_maxSwap), m_maxDup(_maxDup) { } ~NoOutputAssembly() override = default; void setSourceLocation(langutil::SourceLocation const&) override {} @@ -83,6 +83,8 @@ public: private: int m_stackHeight = 0; + unsigned m_maxSwap = 16; + unsigned m_maxDup = 16; }; diff --git a/libyul/backends/evm/OptimizedEVMCodeTransform.cpp b/libyul/backends/evm/OptimizedEVMCodeTransform.cpp index 3da242c98..fe227a0a3 100644 --- a/libyul/backends/evm/OptimizedEVMCodeTransform.cpp +++ b/libyul/backends/evm/OptimizedEVMCodeTransform.cpp @@ -50,7 +50,7 @@ vector OptimizedEVMCodeTransform::run( ) { std::unique_ptr dfg = ControlFlowGraphBuilder::build(_analysisInfo, _dialect, _block); - StackLayout stackLayout = StackLayoutGenerator::run(*dfg); + StackLayout stackLayout = StackLayoutGenerator::run(*dfg, _assembly.maxSwap(), _assembly.maxDup()); OptimizedEVMCodeTransform optimizedCodeTransform( _assembly, _builtinContext, diff --git a/libyul/backends/evm/StackLayoutGenerator.cpp b/libyul/backends/evm/StackLayoutGenerator.cpp index c3d8224bd..089c23da9 100644 --- a/libyul/backends/evm/StackLayoutGenerator.cpp +++ b/libyul/backends/evm/StackLayoutGenerator.cpp @@ -48,28 +48,28 @@ using namespace solidity; using namespace solidity::yul; using namespace std; -StackLayout StackLayoutGenerator::run(CFG const& _cfg) +StackLayout StackLayoutGenerator::run(CFG const& _cfg, unsigned _maxSwap, unsigned _maxDup) { StackLayout stackLayout; - StackLayoutGenerator{stackLayout}.processEntryPoint(*_cfg.entry); + StackLayoutGenerator{stackLayout, _maxSwap, _maxDup}.processEntryPoint(*_cfg.entry); for (auto& functionInfo: _cfg.functionInfo | ranges::views::values) - StackLayoutGenerator{stackLayout}.processEntryPoint(*functionInfo.entry, &functionInfo); + StackLayoutGenerator{stackLayout, _maxSwap, _maxDup}.processEntryPoint(*functionInfo.entry, &functionInfo); return stackLayout; } -map> StackLayoutGenerator::reportStackTooDeep(CFG const& _cfg) +map> StackLayoutGenerator::reportStackTooDeep(CFG const& _cfg, unsigned _maxSwap, unsigned _maxDup) { map> stackTooDeepErrors; - stackTooDeepErrors[YulString{}] = reportStackTooDeep(_cfg, YulString{}); + stackTooDeepErrors[YulString{}] = reportStackTooDeep(_cfg, YulString{}, _maxSwap, _maxDup); for (auto const& function: _cfg.functions) - if (auto errors = reportStackTooDeep(_cfg, function->name); !errors.empty()) + if (auto errors = reportStackTooDeep(_cfg, function->name, _maxSwap, _maxDup); !errors.empty()) stackTooDeepErrors[function->name] = std::move(errors); return stackTooDeepErrors; } -vector StackLayoutGenerator::reportStackTooDeep(CFG const& _cfg, YulString _functionName) +vector StackLayoutGenerator::reportStackTooDeep(CFG const& _cfg, YulString _functionName, unsigned _maxSwap, unsigned _maxDup) { StackLayout stackLayout; CFG::FunctionInfo const* functionInfo = nullptr; @@ -83,13 +83,13 @@ vector StackLayoutGenerator::reportStackTooD yulAssert(functionInfo, "Function not found."); } - StackLayoutGenerator generator{stackLayout}; + StackLayoutGenerator generator{stackLayout, _maxSwap, _maxDup}; CFG::BasicBlock const* entry = functionInfo ? functionInfo->entry : _cfg.entry; generator.processEntryPoint(*entry); return generator.reportStackTooDeep(*entry); } -StackLayoutGenerator::StackLayoutGenerator(StackLayout& _layout): m_layout(_layout) +StackLayoutGenerator::StackLayoutGenerator(StackLayout& _layout, unsigned _maxSwap, unsigned _maxDup): m_layout(_layout), m_maxSwap(_maxSwap), m_maxDup(_maxDup) { } diff --git a/libyul/backends/evm/StackLayoutGenerator.h b/libyul/backends/evm/StackLayoutGenerator.h index 56563c6d1..c72a99201 100644 --- a/libyul/backends/evm/StackLayoutGenerator.h +++ b/libyul/backends/evm/StackLayoutGenerator.h @@ -55,18 +55,18 @@ public: std::vector variableChoices; }; - static StackLayout run(CFG const& _cfg); + static StackLayout run(CFG const& _cfg, unsigned _maxSwap, unsigned _maxDup); /// @returns a map from function names to the stack too deep errors occurring in that function. /// Requires @a _cfg to be a control flow graph generated from disambiguated Yul. /// The empty string is mapped to the stack too deep errors of the main entry point. - static std::map> reportStackTooDeep(CFG const& _cfg); + static std::map> reportStackTooDeep(CFG const& _cfg, unsigned _maxSwap, unsigned _maxDup); /// @returns all stack too deep errors in the function named @a _functionName. /// Requires @a _cfg to be a control flow graph generated from disambiguated Yul. /// If @a _functionName is empty, the stack too deep errors of the main entry point are reported instead. - static std::vector reportStackTooDeep(CFG const& _cfg, YulString _functionName); + static std::vector reportStackTooDeep(CFG const& _cfg, YulString _functionName, unsigned _maxSwap, unsigned _maxDup); private: - StackLayoutGenerator(StackLayout& _context); + StackLayoutGenerator(StackLayout& _context, unsigned _maxSwap, unsigned _maxDup); /// @returns the optimal entry stack layout, s.t. @a _operation can be applied to it and /// the result can be transformed to @a _exitStack with minimal stack shuffling. @@ -116,9 +116,10 @@ private: StackLayout& m_layout; - // TODO - unsigned maxSwap() const { return 16; } - unsigned maxDup() const { return 16; } + unsigned maxSwap() const { return m_maxSwap; } + unsigned maxDup() const { return m_maxDup; } + unsigned const m_maxSwap = 16; + unsigned const m_maxDup = 16; }; } diff --git a/libyul/optimiser/OptimiserStep.h b/libyul/optimiser/OptimiserStep.h index e3e5fe4c6..fecb0b6cd 100644 --- a/libyul/optimiser/OptimiserStep.h +++ b/libyul/optimiser/OptimiserStep.h @@ -39,6 +39,9 @@ struct OptimiserStepContext std::set const& reservedIdentifiers; /// The value nullopt represents creation code std::optional expectedExecutionsPerDeployment; + + unsigned maxSwap = 16; + unsigned maxDup = 16; }; diff --git a/libyul/optimiser/StackCompressor.cpp b/libyul/optimiser/StackCompressor.cpp index a6173996f..3bb2520e5 100644 --- a/libyul/optimiser/StackCompressor.cpp +++ b/libyul/optimiser/StackCompressor.cpp @@ -240,7 +240,9 @@ bool StackCompressor::run( Dialect const& _dialect, Object& _object, bool _optimizeStackAllocation, - size_t _maxIterations + size_t _maxIterations, + unsigned _maxSwap, + unsigned _maxDup ) { yulAssert( @@ -262,14 +264,14 @@ bool StackCompressor::run( eliminateVariablesOptimizedCodegen( _dialect, *_object.code, - StackLayoutGenerator::reportStackTooDeep(*cfg), + StackLayoutGenerator::reportStackTooDeep(*cfg, _maxSwap, _maxDup), allowMSizeOptimzation ); } else for (size_t iterations = 0; iterations < _maxIterations; iterations++) { - map stackSurplus = CompilabilityChecker(_dialect, _object, _optimizeStackAllocation).stackDeficit; + map stackSurplus = CompilabilityChecker(_dialect, _object, _optimizeStackAllocation, _maxSwap, _maxDup).stackDeficit; if (stackSurplus.empty()) return true; eliminateVariables( diff --git a/libyul/optimiser/StackCompressor.h b/libyul/optimiser/StackCompressor.h index d18618667..03dd00e85 100644 --- a/libyul/optimiser/StackCompressor.h +++ b/libyul/optimiser/StackCompressor.h @@ -50,7 +50,9 @@ public: Dialect const& _dialect, Object& _object, bool _optimizeStackAllocation, - size_t _maxIterations + size_t _maxIterations, + unsigned _maxSwap, + unsigned _maxDup ); }; diff --git a/libyul/optimiser/StackLimitEvader.cpp b/libyul/optimiser/StackLimitEvader.cpp index b4b9d5469..9e15c817c 100644 --- a/libyul/optimiser/StackLimitEvader.cpp +++ b/libyul/optimiser/StackLimitEvader.cpp @@ -132,13 +132,15 @@ void StackLimitEvader::run( { yul::AsmAnalysisInfo analysisInfo = yul::AsmAnalyzer::analyzeStrictAssertCorrect(*evmDialect, _object); unique_ptr cfg = ControlFlowGraphBuilder::build(analysisInfo, *evmDialect, *_object.code); - run(_context, _object, StackLayoutGenerator::reportStackTooDeep(*cfg)); + run(_context, _object, StackLayoutGenerator::reportStackTooDeep(*cfg, _context.maxSwap, _context.maxDup)); } else run(_context, _object, CompilabilityChecker{ _context.dialect, _object, - true + true, + _context.maxSwap, + _context.maxDup }.unreachableVariables); } diff --git a/libyul/optimiser/Suite.cpp b/libyul/optimiser/Suite.cpp index 0641328f1..4e3374425 100644 --- a/libyul/optimiser/Suite.cpp +++ b/libyul/optimiser/Suite.cpp @@ -141,7 +141,9 @@ void OptimiserSuite::run( string_view _optimisationSequence, string_view _optimisationCleanupSequence, optional _expectedExecutionsPerDeployment, - set const& _externallyUsedIdentifiers + set const& _externallyUsedIdentifiers, + unsigned _maxSwap, + unsigned _maxDup ) { EVMDialect const* evmDialect = dynamic_cast(&_dialect); @@ -161,7 +163,7 @@ void OptimiserSuite::run( Block& ast = *_object.code; NameDispenser dispenser{_dialect, ast, reservedIdentifiers}; - OptimiserStepContext context{_dialect, dispenser, reservedIdentifiers, _expectedExecutionsPerDeployment}; + OptimiserStepContext context{_dialect, dispenser, reservedIdentifiers, _expectedExecutionsPerDeployment, _maxSwap, _maxDup}; OptimiserSuite suite(context, Debug::None); @@ -184,7 +186,9 @@ void OptimiserSuite::run( _dialect, _object, _optimizeStackAllocation, - stackCompressorMaxIterations + stackCompressorMaxIterations, + context.maxSwap, + context.maxDup ); // Run the user-supplied clean up sequence @@ -204,7 +208,9 @@ void OptimiserSuite::run( _dialect, _object, _optimizeStackAllocation, - stackCompressorMaxIterations + stackCompressorMaxIterations, + context.maxSwap, + context.maxDup ); if (evmDialect->providesObjectAccess()) StackLimitEvader::run(suite.m_context, _object); diff --git a/libyul/optimiser/Suite.h b/libyul/optimiser/Suite.h index abed2720e..3356bf143 100644 --- a/libyul/optimiser/Suite.h +++ b/libyul/optimiser/Suite.h @@ -70,7 +70,9 @@ public: std::string_view _optimisationSequence, std::string_view _optimisationCleanupSequence, std::optional _expectedExecutionsPerDeployment, - std::set const& _externallyUsedIdentifiers = {} + std::set const& _externallyUsedIdentifiers, + unsigned _maxSwap, + unsigned _maxDup ); /// Ensures that specified sequence of step abbreviations is well-formed and can be executed. diff --git a/test/libevmasm/Assembler.cpp b/test/libevmasm/Assembler.cpp index 680531799..c92e05094 100644 --- a/test/libevmasm/Assembler.cpp +++ b/test/libevmasm/Assembler.cpp @@ -59,15 +59,16 @@ BOOST_AUTO_TEST_CASE(all_assembly_items) { "sub.asm", 1 }, { "verbatim.asm", 2 } }; - Assembly _assembly{false, {}}; + // TODO: versions + Assembly _assembly{{}, {}, false, {}}; auto root_asm = make_shared("root.asm"); _assembly.setSourceLocation({1, 3, root_asm}); - Assembly _subAsm{false, {}}; + Assembly _subAsm{{}, {}, false, {}}; auto sub_asm = make_shared("sub.asm"); _subAsm.setSourceLocation({6, 8, sub_asm}); - Assembly _verbatimAsm(true, ""); + Assembly _verbatimAsm({}, {}, true, ""); auto verbatim_asm = make_shared("verbatim.asm"); _verbatimAsm.setSourceLocation({8, 18, verbatim_asm}); @@ -243,7 +244,7 @@ BOOST_AUTO_TEST_CASE(immutables_and_its_source_maps) { *subName, 1 } }; - auto subAsm = make_shared(false, string{}); + auto subAsm = make_shared(langutil::EVMVersion{}, std::nullopt, false, string{}); for (char i = 0; i < numImmutables; ++i) { for (int r = 0; r < numActualRefs; ++r) @@ -253,7 +254,7 @@ BOOST_AUTO_TEST_CASE(immutables_and_its_source_maps) } } - Assembly assembly{true, {}}; + Assembly assembly{{}, {}, true, {}}; for (char i = 1; i <= numImmutables; ++i) { assembly.setSourceLocation({10*i, 10*i + 3+i, assemblyName}); @@ -302,11 +303,11 @@ BOOST_AUTO_TEST_CASE(immutable) { "root.asm", 0 }, { "sub.asm", 1 } }; - Assembly _assembly{true, {}}; + Assembly _assembly{{}, {}, true, {}}; auto root_asm = make_shared("root.asm"); _assembly.setSourceLocation({1, 3, root_asm}); - Assembly _subAsm{false, {}}; + Assembly _subAsm{{}, {}, false, {}}; auto sub_asm = make_shared("sub.asm"); _subAsm.setSourceLocation({6, 8, sub_asm}); _subAsm.appendImmutable("someImmutable"); @@ -395,10 +396,10 @@ BOOST_AUTO_TEST_CASE(immutable) BOOST_AUTO_TEST_CASE(subobject_encode_decode) { - Assembly assembly{true, {}}; + Assembly assembly{{}, {}, true, {}}; - shared_ptr subAsmPtr = make_shared(false, string{}); - shared_ptr subSubAsmPtr = make_shared(false, string{}); + shared_ptr subAsmPtr = make_shared(langutil::EVMVersion{}, std::nullopt, false, string{}); + shared_ptr subSubAsmPtr = make_shared(langutil::EVMVersion{}, std::nullopt, false, string{}); assembly.appendSubroutine(subAsmPtr); subAsmPtr->appendSubroutine(subSubAsmPtr); diff --git a/test/libevmasm/Optimiser.cpp b/test/libevmasm/Optimiser.cpp index 52cc7d202..a72d18e5c 100644 --- a/test/libevmasm/Optimiser.cpp +++ b/test/libevmasm/Optimiser.cpp @@ -1250,8 +1250,8 @@ BOOST_AUTO_TEST_CASE(jumpdest_removal_subassemblies) // tag unifications (due to block deduplication) is also // visible at the super-assembly. - Assembly main{false, {}}; - AssemblyPointer sub = make_shared(true, string{}); + Assembly main{{}, {}, false, {}}; + AssemblyPointer sub = make_shared(langutil::EVMVersion(), nullopt, true, string{}); sub->append(u256(1)); auto t1 = sub->newTag(); diff --git a/test/libsolidity/Assembly.cpp b/test/libsolidity/Assembly.cpp index f12c12ca9..ebf3e6dc3 100644 --- a/test/libsolidity/Assembly.cpp +++ b/test/libsolidity/Assembly.cpp @@ -87,6 +87,7 @@ evmasm::AssemblyItems compileContract(std::shared_ptr _sourceCode) { Compiler compiler( solidity::test::CommonOptions::get().evmVersion(), + solidity::test::CommonOptions::get().eofVersion(), RevertStrings::Default, solidity::test::CommonOptions::get().optimize ? OptimiserSettings::standard() : OptimiserSettings::minimal() ); diff --git a/test/libsolidity/SolidityExpressionCompiler.cpp b/test/libsolidity/SolidityExpressionCompiler.cpp index 2741290fc..a9c8abdf5 100644 --- a/test/libsolidity/SolidityExpressionCompiler.cpp +++ b/test/libsolidity/SolidityExpressionCompiler.cpp @@ -144,6 +144,7 @@ bytes compileFirstExpression( CompilerContext context( solidity::test::CommonOptions::get().evmVersion(), + solidity::test::CommonOptions::get().eofVersion(), RevertStrings::Default ); context.resetVisitedNodes(contract); diff --git a/test/libyul/CompilabilityChecker.cpp b/test/libyul/CompilabilityChecker.cpp index b27f7ab54..2d5201286 100644 --- a/test/libyul/CompilabilityChecker.cpp +++ b/test/libyul/CompilabilityChecker.cpp @@ -39,7 +39,8 @@ string check(string const& _input) Object obj; std::tie(obj.code, obj.analysisInfo) = yul::test::parse(_input, false); BOOST_REQUIRE(obj.code); - auto functions = CompilabilityChecker(EVMDialect::strictAssemblyForEVM(solidity::test::CommonOptions::get().evmVersion()), obj, true).stackDeficit; + // TODO: maxSwap, maxDup + auto functions = CompilabilityChecker(EVMDialect::strictAssemblyForEVM(solidity::test::CommonOptions::get().evmVersion()), obj, true, 16u, 16u).stackDeficit; string out; for (auto const& function: functions) out += function.first.str() + ": " + to_string(function.second) + " "; diff --git a/test/libyul/EVMCodeTransformTest.cpp b/test/libyul/EVMCodeTransformTest.cpp index 744fa8c03..2c980b247 100644 --- a/test/libyul/EVMCodeTransformTest.cpp +++ b/test/libyul/EVMCodeTransformTest.cpp @@ -66,7 +66,7 @@ TestCase::TestResult EVMCodeTransformTest::run(ostream& _stream, string const& _ return TestResult::FatalError; } - evmasm::Assembly assembly{false, {}}; + evmasm::Assembly assembly{{}, {}, false, {}}; EthAssemblyAdapter adapter(assembly); EVMObjectCompiler::compile( *stack.parserResult(), diff --git a/test/libyul/StackLayoutGeneratorTest.cpp b/test/libyul/StackLayoutGeneratorTest.cpp index 70fda680e..35b70ef33 100644 --- a/test/libyul/StackLayoutGeneratorTest.cpp +++ b/test/libyul/StackLayoutGeneratorTest.cpp @@ -226,7 +226,8 @@ TestCase::TestResult StackLayoutGeneratorTest::run(ostream& _stream, string cons std::ostringstream output; std::unique_ptr cfg = ControlFlowGraphBuilder::build(*analysisInfo, *m_dialect, *object->code); - StackLayout stackLayout = StackLayoutGenerator::run(*cfg); + // TODO maxSwap, maxDup + StackLayout stackLayout = StackLayoutGenerator::run(*cfg, 16u, 16u); output << "digraph CFG {\nnodesep=0.7;\nnode[shape=box];\n\n"; StackLayoutPrinter printer{output, stackLayout}; diff --git a/test/libyul/YulOptimizerTestCommon.cpp b/test/libyul/YulOptimizerTestCommon.cpp index 7623efc12..dde637a4a 100644 --- a/test/libyul/YulOptimizerTestCommon.cpp +++ b/test/libyul/YulOptimizerTestCommon.cpp @@ -323,7 +323,8 @@ YulOptimizerTestCommon::YulOptimizerTestCommon( FunctionHoister::run(*m_context, *m_ast); FunctionGrouper::run(*m_context, *m_ast); size_t maxIterations = 16; - StackCompressor::run(*m_dialect, *m_object, true, maxIterations); + // TODO: maxSwap, maxDup + StackCompressor::run(*m_dialect, *m_object, true, maxIterations, 16u, 16u); BlockFlattener::run(*m_context, *m_ast); }}, {"wordSizeTransform", [&]() { @@ -333,6 +334,7 @@ YulOptimizerTestCommon::YulOptimizerTestCommon( }}, {"fullSuite", [&]() { GasMeter meter(dynamic_cast(*m_dialect), false, 200); + // TODO: maxSwap, maxDup OptimiserSuite::run( *m_dialect, &meter, @@ -340,15 +342,21 @@ YulOptimizerTestCommon::YulOptimizerTestCommon( true, frontend::OptimiserSettings::DefaultYulOptimiserSteps, frontend::OptimiserSettings::DefaultYulOptimiserCleanupSteps, - frontend::OptimiserSettings::standard().expectedExecutionsPerDeployment + frontend::OptimiserSettings::standard().expectedExecutionsPerDeployment, + {}, + 16u, + 16u ); }}, {"stackLimitEvader", [&]() { disambiguate(); + // TODO: maxSwap, maxDup StackLimitEvader::run(*m_context, *m_object, CompilabilityChecker{ *m_dialect, *m_object, - true + true, + 16u, + 16u }.unreachableVariables); }}, {"fakeStackLimitEvader", [&]() { diff --git a/test/tools/fuzzer_common.cpp b/test/tools/fuzzer_common.cpp index 25ad6986c..4643d364c 100644 --- a/test/tools/fuzzer_common.cpp +++ b/test/tools/fuzzer_common.cpp @@ -189,7 +189,8 @@ void FuzzerUtil::testConstantOptimizer(string const& _input, bool _quiet) for (bool isCreation: {false, true}) { - Assembly assembly{isCreation, {}}; + // TODO: versions + Assembly assembly{{}, {}, isCreation, {}}; for (u256 const& n: numbers) { if (!_quiet) diff --git a/test/tools/yulopti.cpp b/test/tools/yulopti.cpp index ad98ab9be..649566e87 100644 --- a/test/tools/yulopti.cpp +++ b/test/tools/yulopti.cpp @@ -222,7 +222,8 @@ public: { Object obj; obj.code = m_ast; - StackCompressor::run(m_dialect, obj, true, 16); + // TODO maxSwap maxDup + StackCompressor::run(m_dialect, obj, true, 16, 16u, 16u); break; } default: