Skip to content

Commit 4263b89

Browse files
authored
Merge pull request #12672 from ethereum/redundantStoreEliminatorLimited
Redundant store eliminator limited
2 parents 921c4fd + 4f02be1 commit 4263b89

File tree

86 files changed

+1272
-157
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

86 files changed

+1272
-157
lines changed

Changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ Language Features:
77
Compiler Features:
88
* JSON-AST: Added selector field for errors and events.
99
* Peephole Optimizer: Optimize comparisons in front of conditional jumps and conditional jumps across a single unconditional jump.
10+
* Yul Optimizer: Remove ``sstore`` and ``mstore`` operations that are never read from.
1011

1112
Bugfixes:
1213
* Yul IR Code Generation: Optimize embedded creation code with correct settings. This fixes potential mismatches between the constructor code of a contract compiled in isolation and the bytecode in ``type(C).creationCode``, resp. the bytecode used for ``new C(...)``.

libevmasm/SemanticInformation.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,9 @@ vector<SemanticInformation::Operation> SemanticInformation::readWriteOperations(
121121
Location::Memory,
122122
Effect::Write,
123123
paramCount - 2,
124-
paramCount - 1,
124+
// Length is in paramCount - 1, but it is only a max length,
125+
// there is no guarantee that the full area is written to.
126+
{},
125127
{}
126128
});
127129
return operations;

libsolidity/interface/OptimiserSettings.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ struct OptimiserSettings
5555
"xa[rul]" // Prune a bit more in SSA
5656
"xa[r]cL" // Turn into SSA again and simplify
5757
"gvif" // Run full inliner
58-
"CTUca[r]LsTFOtfDnca[r]Iulc" // SSA plus simplify
58+
"CTUca[r]LSsTFOtfDnca[r]Iulc" // SSA plus simplify
5959
"]"
6060
"jmul[jul] VcTOcul jmul"; // Make source short and pretty
6161

libyul/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,8 @@ add_library(yul
179179
optimiser/UnusedAssignEliminator.h
180180
optimiser/UnusedStoreBase.cpp
181181
optimiser/UnusedStoreBase.h
182+
optimiser/UnusedStoreEliminator.cpp
183+
optimiser/UnusedStoreEliminator.h
182184
optimiser/Rematerialiser.cpp
183185
optimiser/Rematerialiser.h
184186
optimiser/SMTSolver.cpp

libyul/optimiser/Suite.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
#include <libyul/optimiser/StructuralSimplifier.h>
5858
#include <libyul/optimiser/SyntacticalEquality.h>
5959
#include <libyul/optimiser/UnusedAssignEliminator.h>
60+
#include <libyul/optimiser/UnusedStoreEliminator.h>
6061
#include <libyul/optimiser/VarNameCleaner.h>
6162
#include <libyul/optimiser/LoadResolver.h>
6263
#include <libyul/optimiser/LoopInvariantCodeMotion.h>
@@ -222,6 +223,7 @@ map<string, unique_ptr<OptimiserStep>> const& OptimiserSuite::allSteps()
222223
LoadResolver,
223224
LoopInvariantCodeMotion,
224225
UnusedAssignEliminator,
226+
UnusedStoreEliminator,
225227
ReasoningBasedSimplifier,
226228
Rematerialiser,
227229
SSAReverser,
@@ -264,6 +266,7 @@ map<string, char> const& OptimiserSuite::stepNameToAbbreviationMap()
264266
{LoopInvariantCodeMotion::name, 'M'},
265267
{ReasoningBasedSimplifier::name, 'R'},
266268
{UnusedAssignEliminator::name, 'r'},
269+
{UnusedStoreEliminator::name, 'S'},
267270
{Rematerialiser::name, 'm'},
268271
{SSAReverser::name, 'V'},
269272
{SSATransform::name, 'a'},

0 commit comments

Comments
 (0)