Fix removal of memory stores in inline assembly blocks.

This commit is contained in:
chriseth 2022-06-07 12:30:13 +02:00 committed by Daniel Kirchner
parent 14cdb76e4b
commit 51ef6a62da
4 changed files with 15 additions and 2 deletions
Changelog.md
libsolidity/codegen
libyul/optimiser
test/libsolidity/semanticTests/array/pop

View File

@ -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.

View File

@ -485,6 +485,7 @@ void CompilerContext::appendInlineAssembly(
obj.code = parserResult;
obj.analysisInfo = make_shared<yul::AsmAnalysisInfo>(analysisInfo);
solAssert(!dialect.providesObjectAccess());
optimizeYul(obj, dialect, _optimiserSettings, externallyUsedIdentifiers);
if (_system)

View File

@ -31,6 +31,8 @@
#include <libyul/ControlFlowSideEffectsCollector.h>
#include <libyul/AST.h>
#include <libyul/backends/evm/EVMDialect.h>
#include <libsolutil/CommonData.h>
#include <libevmasm/Instruction.h>
@ -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<EVMDialect const*>(&_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();

View File

@ -17,5 +17,5 @@ contract c {
// test() ->
// gas irOptimized: 142639
// gas legacy: 164430
// gas legacyOptimized: 157898
// gas legacyOptimized: 158513
// storageEmpty -> 1