diff --git a/Changelog.md b/Changelog.md index 9828220bf..6205e72b1 100644 --- a/Changelog.md +++ b/Changelog.md @@ -10,6 +10,7 @@ Compiler Features: * Optimizer: Re-implement simplified version of UnusedAssignEliminator and UnusedStoreEliminator. It can correctly remove some unused assignments in deeply nested loops that were ignored by the old version. * SMTChecker: Properties that are proved safe are now reported explicitly at the end of the analysis. By default, only the number of safe properties is shown. The CLI option ``--model-checker-show-proved-safe`` and the JSON option ``settings.modelChecker.showProvedSafe`` can be enabled to show the full list of safe properties. * SMTChecker: Group all messages about unsupported language features in a single warning. The CLI option ``--model-checker-show-unsupported`` and the JSON option ``settings.modelChecker.showUnsupported`` can be enabled to show the full list. + * Yul EVM Code Transform: If available, use ``push0`` instead of ``codesize`` to produce an arbitrary value on stack in order to create equal stack heights between branches. Bugfixes: diff --git a/libyul/backends/evm/AbstractAssembly.h b/libyul/backends/evm/AbstractAssembly.h index c64669abe..fe4500896 100644 --- a/libyul/backends/evm/AbstractAssembly.h +++ b/libyul/backends/evm/AbstractAssembly.h @@ -117,6 +117,9 @@ public: /// Mark this assembly as invalid. Any attempt to request bytecode from it should throw. virtual void markAsInvalid() = 0; + + /// @returns the EVM version the assembly targets. + virtual langutil::EVMVersion evmVersion() const = 0; }; enum class IdentifierContext { LValue, RValue, VariableDeclaration, NonExternal }; diff --git a/libyul/backends/evm/EthAssemblyAdapter.cpp b/libyul/backends/evm/EthAssemblyAdapter.cpp index 28a4e4ae2..9cbd6e00d 100644 --- a/libyul/backends/evm/EthAssemblyAdapter.cpp +++ b/libyul/backends/evm/EthAssemblyAdapter.cpp @@ -181,6 +181,11 @@ void EthAssemblyAdapter::markAsInvalid() m_assembly.markAsInvalid(); } +langutil::EVMVersion EthAssemblyAdapter::evmVersion() const +{ + return m_assembly.evmVersion(); +} + EthAssemblyAdapter::LabelID EthAssemblyAdapter::assemblyTagToIdentifier(evmasm::AssemblyItem const& _tag) { u256 id = _tag.data(); diff --git a/libyul/backends/evm/EthAssemblyAdapter.h b/libyul/backends/evm/EthAssemblyAdapter.h index 87047ccbf..011081ded 100644 --- a/libyul/backends/evm/EthAssemblyAdapter.h +++ b/libyul/backends/evm/EthAssemblyAdapter.h @@ -67,6 +67,9 @@ public: void markAsInvalid() override; + langutil::EVMVersion evmVersion() const override; + + private: static LabelID assemblyTagToIdentifier(evmasm::AssemblyItem const& _tag); void appendJumpInstruction(evmasm::Instruction _instruction, JumpType _jumpType); diff --git a/libyul/backends/evm/NoOutputAssembly.h b/libyul/backends/evm/NoOutputAssembly.h index eeb00039c..8d7dda0bb 100644 --- a/libyul/backends/evm/NoOutputAssembly.h +++ b/libyul/backends/evm/NoOutputAssembly.h @@ -77,6 +77,8 @@ public: void markAsInvalid() override {} + langutil::EVMVersion evmVersion() const override { return m_evmVersion; } + private: int m_stackHeight = 0; langutil::EVMVersion m_evmVersion; diff --git a/libyul/backends/evm/OptimizedEVMCodeTransform.cpp b/libyul/backends/evm/OptimizedEVMCodeTransform.cpp index fd3a572e0..8e126a49a 100644 --- a/libyul/backends/evm/OptimizedEVMCodeTransform.cpp +++ b/libyul/backends/evm/OptimizedEVMCodeTransform.cpp @@ -351,7 +351,10 @@ void OptimizedEVMCodeTransform::createStackLayout(std::shared_ptr