diff --git a/Changelog.md b/Changelog.md index 4151d533a..2a3f34bbd 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,5 +1,9 @@ ### 0.8.15 (unreleased) +Important Bugfixes: + * Yul Optimizer: Keep all memory side-effects of inline assembly blocks. + + Language Features: * Add `E.selector` for a non-anonymous event `E` to access the 32-byte selector topic. * Errors and Events allow qualified access from other contracts. diff --git a/libsolidity/codegen/CompilerContext.cpp b/libsolidity/codegen/CompilerContext.cpp index 55089dde1..dbd1a1730 100644 --- a/libsolidity/codegen/CompilerContext.cpp +++ b/libsolidity/codegen/CompilerContext.cpp @@ -485,6 +485,7 @@ void CompilerContext::appendInlineAssembly( obj.code = parserResult; obj.analysisInfo = make_shared(analysisInfo); + solAssert(!dialect.providesObjectAccess()); optimizeYul(obj, dialect, _optimiserSettings, externallyUsedIdentifiers); if (_system) diff --git a/libyul/optimiser/UnusedStoreEliminator.cpp b/libyul/optimiser/UnusedStoreEliminator.cpp index 976c8c842..0e6acdeea 100644 --- a/libyul/optimiser/UnusedStoreEliminator.cpp +++ b/libyul/optimiser/UnusedStoreEliminator.cpp @@ -31,6 +31,8 @@ #include #include +#include + #include #include @@ -76,7 +78,13 @@ void UnusedStoreEliminator::run(OptimiserStepContext& _context, Block& _ast) ignoreMemory }; rse(_ast); - rse.changeUndecidedTo(State::Unused, Location::Memory); + if ( + auto evmDialect = dynamic_cast(&_context.dialect); + evmDialect && evmDialect->providesObjectAccess() + ) + rse.changeUndecidedTo(State::Unused, Location::Memory); + else + rse.changeUndecidedTo(State::Used, Location::Memory); rse.changeUndecidedTo(State::Used, Location::Storage); rse.scheduleUnusedForDeletion(); diff --git a/test/libsolidity/semanticTests/array/pop/byte_array_pop_long_storage_empty_garbage_ref.sol b/test/libsolidity/semanticTests/array/pop/byte_array_pop_long_storage_empty_garbage_ref.sol index bef07f55b..66fb16775 100644 --- a/test/libsolidity/semanticTests/array/pop/byte_array_pop_long_storage_empty_garbage_ref.sol +++ b/test/libsolidity/semanticTests/array/pop/byte_array_pop_long_storage_empty_garbage_ref.sol @@ -17,5 +17,5 @@ contract c { // test() -> // gas irOptimized: 142639 // gas legacy: 164430 -// gas legacyOptimized: 157898 +// gas legacyOptimized: 158513 // storageEmpty -> 1