Skip to content

Commit 9c18f0d

Browse files
committed
Rename RedundantAssignEliminator to UnusedAssignEliminator.
1 parent defc74c commit 9c18f0d

38 files changed

+52
-52
lines changed

libyul/CMakeLists.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -173,10 +173,10 @@ add_library(yul
173173
optimiser/OptimizerUtilities.h
174174
optimiser/ReasoningBasedSimplifier.cpp
175175
optimiser/ReasoningBasedSimplifier.h
176-
optimiser/RedundantAssignEliminator.cpp
177-
optimiser/RedundantAssignEliminator.h
178-
optimiser/RedundantStoreBase.cpp
179-
optimiser/RedundantStoreBase.h
176+
optimiser/UnusedAssignEliminator.cpp
177+
optimiser/UnusedAssignEliminator.h
178+
optimiser/UnusedStoreBase.cpp
179+
optimiser/UnusedStoreBase.h
180180
optimiser/Rematerialiser.cpp
181181
optimiser/Rematerialiser.h
182182
optimiser/SMTSolver.cpp

libyul/optimiser/SSATransform.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ class NameDispenser;
7070
* variable references can use the SSA variable. The only exception to this rule are
7171
* for loop conditions, as we cannot insert a variable declaration there.
7272
*
73-
* After this stage, redundantAssignmentRemover is recommended to remove the unnecessary
73+
* After this stage, UnusedAssignmentEliminator is recommended to remove the unnecessary
7474
* intermediate assignments.
7575
*
7676
* This stage provides best results if CSE is run right before it, because

libyul/optimiser/Suite.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
#include <libyul/optimiser/StackLimitEvader.h>
5656
#include <libyul/optimiser/StructuralSimplifier.h>
5757
#include <libyul/optimiser/SyntacticalEquality.h>
58-
#include <libyul/optimiser/RedundantAssignEliminator.h>
58+
#include <libyul/optimiser/UnusedAssignEliminator.h>
5959
#include <libyul/optimiser/VarNameCleaner.h>
6060
#include <libyul/optimiser/LoadResolver.h>
6161
#include <libyul/optimiser/LoopInvariantCodeMotion.h>
@@ -219,7 +219,7 @@ map<string, unique_ptr<OptimiserStep>> const& OptimiserSuite::allSteps()
219219
LiteralRematerialiser,
220220
LoadResolver,
221221
LoopInvariantCodeMotion,
222-
RedundantAssignEliminator,
222+
UnusedAssignEliminator,
223223
ReasoningBasedSimplifier,
224224
Rematerialiser,
225225
SSAReverser,
@@ -260,7 +260,7 @@ map<string, char> const& OptimiserSuite::stepNameToAbbreviationMap()
260260
{LoadResolver::name, 'L'},
261261
{LoopInvariantCodeMotion::name, 'M'},
262262
{ReasoningBasedSimplifier::name, 'R'},
263-
{RedundantAssignEliminator::name, 'r'},
263+
{UnusedAssignEliminator::name, 'r'},
264264
{Rematerialiser::name, 'm'},
265265
{SSAReverser::name, 'V'},
266266
{SSATransform::name, 'a'},

libyul/optimiser/RedundantAssignEliminator.cpp renamed to libyul/optimiser/UnusedAssignEliminator.cpp

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
* until they go out of scope or are re-assigned.
2121
*/
2222

23-
#include <libyul/optimiser/RedundantAssignEliminator.h>
23+
#include <libyul/optimiser/UnusedAssignEliminator.h>
2424

2525
#include <libyul/optimiser/Semantics.h>
2626
#include <libyul/AST.h>
@@ -33,73 +33,73 @@ using namespace std;
3333
using namespace solidity;
3434
using namespace solidity::yul;
3535

36-
void RedundantAssignEliminator::run(OptimiserStepContext& _context, Block& _ast)
36+
void UnusedAssignEliminator::run(OptimiserStepContext& _context, Block& _ast)
3737
{
38-
RedundantAssignEliminator rae{_context.dialect};
38+
UnusedAssignEliminator rae{_context.dialect};
3939
rae(_ast);
4040

4141
StatementRemover remover{rae.m_pendingRemovals};
4242
remover(_ast);
4343
}
4444

45-
void RedundantAssignEliminator::operator()(Identifier const& _identifier)
45+
void UnusedAssignEliminator::operator()(Identifier const& _identifier)
4646
{
4747
changeUndecidedTo(_identifier.name, State::Used);
4848
}
4949

50-
void RedundantAssignEliminator::operator()(VariableDeclaration const& _variableDeclaration)
50+
void UnusedAssignEliminator::operator()(VariableDeclaration const& _variableDeclaration)
5151
{
52-
RedundantStoreBase::operator()(_variableDeclaration);
52+
UnusedStoreBase::operator()(_variableDeclaration);
5353

5454
for (auto const& var: _variableDeclaration.variables)
5555
m_declaredVariables.emplace(var.name);
5656
}
5757

58-
void RedundantAssignEliminator::operator()(Assignment const& _assignment)
58+
void UnusedAssignEliminator::operator()(Assignment const& _assignment)
5959
{
6060
visit(*_assignment.value);
6161
for (auto const& var: _assignment.variableNames)
6262
changeUndecidedTo(var.name, State::Unused);
6363
}
6464

65-
void RedundantAssignEliminator::operator()(FunctionDefinition const& _functionDefinition)
65+
void UnusedAssignEliminator::operator()(FunctionDefinition const& _functionDefinition)
6666
{
6767
ScopedSaveAndRestore outerDeclaredVariables(m_declaredVariables, {});
6868
ScopedSaveAndRestore outerReturnVariables(m_returnVariables, {});
6969

7070
for (auto const& retParam: _functionDefinition.returnVariables)
7171
m_returnVariables.insert(retParam.name);
7272

73-
RedundantStoreBase::operator()(_functionDefinition);
73+
UnusedStoreBase::operator()(_functionDefinition);
7474
}
7575

76-
void RedundantAssignEliminator::operator()(Leave const&)
76+
void UnusedAssignEliminator::operator()(Leave const&)
7777
{
7878
for (YulString name: m_returnVariables)
7979
changeUndecidedTo(name, State::Used);
8080
}
8181

82-
void RedundantAssignEliminator::operator()(Block const& _block)
82+
void UnusedAssignEliminator::operator()(Block const& _block)
8383
{
8484
ScopedSaveAndRestore outerDeclaredVariables(m_declaredVariables, {});
8585

86-
RedundantStoreBase::operator()(_block);
86+
UnusedStoreBase::operator()(_block);
8787

8888
for (auto const& var: m_declaredVariables)
8989
finalize(var, State::Unused);
9090
}
9191

92-
void RedundantAssignEliminator::visit(Statement const& _statement)
92+
void UnusedAssignEliminator::visit(Statement const& _statement)
9393
{
94-
RedundantStoreBase::visit(_statement);
94+
UnusedStoreBase::visit(_statement);
9595

9696
if (auto const* assignment = get_if<Assignment>(&_statement))
9797
if (assignment->variableNames.size() == 1)
9898
// Default-construct it in "Undecided" state if it does not yet exist.
9999
m_stores[assignment->variableNames.front().name][&_statement];
100100
}
101101

102-
void RedundantAssignEliminator::shortcutNestedLoop(TrackedStores const& _zeroRuns)
102+
void UnusedAssignEliminator::shortcutNestedLoop(TrackedStores const& _zeroRuns)
103103
{
104104
// Shortcut to avoid horrible runtime:
105105
// Change all assignments that were newly introduced in the for loop to "used".
@@ -116,22 +116,22 @@ void RedundantAssignEliminator::shortcutNestedLoop(TrackedStores const& _zeroRun
116116
}
117117
}
118118

119-
void RedundantAssignEliminator::finalizeFunctionDefinition(FunctionDefinition const& _functionDefinition)
119+
void UnusedAssignEliminator::finalizeFunctionDefinition(FunctionDefinition const& _functionDefinition)
120120
{
121121
for (auto const& param: _functionDefinition.parameters)
122122
finalize(param.name, State::Unused);
123123
for (auto const& retParam: _functionDefinition.returnVariables)
124124
finalize(retParam.name, State::Used);
125125
}
126126

127-
void RedundantAssignEliminator::changeUndecidedTo(YulString _variable, RedundantAssignEliminator::State _newState)
127+
void UnusedAssignEliminator::changeUndecidedTo(YulString _variable, UnusedAssignEliminator::State _newState)
128128
{
129129
for (auto& assignment: m_stores[_variable])
130130
if (assignment.second == State::Undecided)
131131
assignment.second = _newState;
132132
}
133133

134-
void RedundantAssignEliminator::finalize(YulString _variable, RedundantAssignEliminator::State _finalState)
134+
void UnusedAssignEliminator::finalize(YulString _variable, UnusedAssignEliminator::State _finalState)
135135
{
136136
std::map<Statement const*, State> stores = std::move(m_stores[_variable]);
137137
m_stores.erase(_variable);

libyul/optimiser/RedundantAssignEliminator.h renamed to libyul/optimiser/UnusedAssignEliminator.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
#include <libyul/ASTForward.h>
2626
#include <libyul/optimiser/ASTWalker.h>
2727
#include <libyul/optimiser/OptimiserStep.h>
28-
#include <libyul/optimiser/RedundantStoreBase.h>
28+
#include <libyul/optimiser/UnusedStoreBase.h>
2929

3030
#include <map>
3131
#include <vector>
@@ -107,13 +107,13 @@ struct Dialect;
107107
*
108108
* Prerequisite: Disambiguator, ForLoopInitRewriter.
109109
*/
110-
class RedundantAssignEliminator: public RedundantStoreBase
110+
class UnusedAssignEliminator: public UnusedStoreBase
111111
{
112112
public:
113-
static constexpr char const* name{"RedundantAssignEliminator"};
113+
static constexpr char const* name{"UnusedAssignEliminator"};
114114
static void run(OptimiserStepContext&, Block& _ast);
115115

116-
explicit RedundantAssignEliminator(Dialect const& _dialect): RedundantStoreBase(_dialect) {}
116+
explicit UnusedAssignEliminator(Dialect const& _dialect): UnusedStoreBase(_dialect) {}
117117

118118
void operator()(Identifier const& _identifier) override;
119119
void operator()(VariableDeclaration const& _variableDeclaration) override;
@@ -122,7 +122,7 @@ class RedundantAssignEliminator: public RedundantStoreBase
122122
void operator()(Leave const&) override;
123123
void operator()(Block const& _block) override;
124124

125-
using RedundantStoreBase::visit;
125+
using UnusedStoreBase::visit;
126126
void visit(Statement const& _statement) override;
127127

128128
private:

libyul/optimiser/RedundantStoreBase.cpp renamed to libyul/optimiser/UnusedStoreBase.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@
1616
*/
1717
// SPDX-License-Identifier: GPL-3.0
1818
/**
19-
* Base class for both RedundantAssignEliminator and RedundantStoreEliminator.
19+
* Base class for both UnusedAssignEliminator and UnusedStoreEliminator.
2020
*/
2121

22-
#include <libyul/optimiser/RedundantStoreBase.h>
22+
#include <libyul/optimiser/UnusedStoreBase.h>
2323

2424
#include <libyul/optimiser/Semantics.h>
2525
#include <libyul/optimiser/OptimiserStep.h>
@@ -33,7 +33,7 @@ using namespace std;
3333
using namespace solidity;
3434
using namespace solidity::yul;
3535

36-
void RedundantStoreBase::operator()(If const& _if)
36+
void UnusedStoreBase::operator()(If const& _if)
3737
{
3838
visit(*_if.condition);
3939

@@ -43,7 +43,7 @@ void RedundantStoreBase::operator()(If const& _if)
4343
merge(m_stores, move(skipBranch));
4444
}
4545

46-
void RedundantStoreBase::operator()(Switch const& _switch)
46+
void UnusedStoreBase::operator()(Switch const& _switch)
4747
{
4848
visit(*_switch.expression);
4949

@@ -69,7 +69,7 @@ void RedundantStoreBase::operator()(Switch const& _switch)
6969
merge(m_stores, move(branch));
7070
}
7171

72-
void RedundantStoreBase::operator()(FunctionDefinition const& _functionDefinition)
72+
void UnusedStoreBase::operator()(FunctionDefinition const& _functionDefinition)
7373
{
7474
ScopedSaveAndRestore outerAssignments(m_stores, {});
7575
ScopedSaveAndRestore forLoopInfo(m_forLoopInfo, {});
@@ -79,7 +79,7 @@ void RedundantStoreBase::operator()(FunctionDefinition const& _functionDefinitio
7979
finalizeFunctionDefinition(_functionDefinition);
8080
}
8181

82-
void RedundantStoreBase::operator()(ForLoop const& _forLoop)
82+
void UnusedStoreBase::operator()(ForLoop const& _forLoop)
8383
{
8484
ScopedSaveAndRestore outerForLoopInfo(m_forLoopInfo, {});
8585
ScopedSaveAndRestore forLoopNestingDepth(m_forLoopNestingDepth, m_forLoopNestingDepth + 1);
@@ -127,19 +127,19 @@ void RedundantStoreBase::operator()(ForLoop const& _forLoop)
127127
m_forLoopInfo.pendingBreakStmts.clear();
128128
}
129129

130-
void RedundantStoreBase::operator()(Break const&)
130+
void UnusedStoreBase::operator()(Break const&)
131131
{
132132
m_forLoopInfo.pendingBreakStmts.emplace_back(move(m_stores));
133133
m_stores.clear();
134134
}
135135

136-
void RedundantStoreBase::operator()(Continue const&)
136+
void UnusedStoreBase::operator()(Continue const&)
137137
{
138138
m_forLoopInfo.pendingContinueStmts.emplace_back(move(m_stores));
139139
m_stores.clear();
140140
}
141141

142-
void RedundantStoreBase::merge(TrackedStores& _target, TrackedStores&& _other)
142+
void UnusedStoreBase::merge(TrackedStores& _target, TrackedStores&& _other)
143143
{
144144
util::joinMap(_target, move(_other), [](
145145
map<Statement const*, State>& _assignmentHere,
@@ -150,7 +150,7 @@ void RedundantStoreBase::merge(TrackedStores& _target, TrackedStores&& _other)
150150
});
151151
}
152152

153-
void RedundantStoreBase::merge(TrackedStores& _target, vector<TrackedStores>&& _source)
153+
void UnusedStoreBase::merge(TrackedStores& _target, vector<TrackedStores>&& _source)
154154
{
155155
for (TrackedStores& ts: _source)
156156
merge(_target, move(ts));

libyul/optimiser/RedundantStoreBase.h renamed to libyul/optimiser/UnusedStoreBase.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
*/
1717
// SPDX-License-Identifier: GPL-3.0
1818
/**
19-
* Base class for both RedundantAssignEliminator and RedundantStoreEliminator.
19+
* Base class for both UnusedAssignEliminator and UnusedStoreEliminator.
2020
*/
2121

2222
#pragma once
@@ -34,14 +34,14 @@ namespace solidity::yul
3434
struct Dialect;
3535

3636
/**
37-
* Base class for both RedundantAssignEliminator and RedundantStoreEliminator.
37+
* Base class for both UnusedAssignEliminator and UnusedStoreEliminator.
3838
*
3939
* Prerequisite: Disambiguator, ForLoopInitRewriter.
4040
*/
41-
class RedundantStoreBase: public ASTWalker
41+
class UnusedStoreBase: public ASTWalker
4242
{
4343
public:
44-
explicit RedundantStoreBase(Dialect const& _dialect): m_dialect(_dialect) {}
44+
explicit UnusedStoreBase(Dialect const& _dialect): m_dialect(_dialect) {}
4545

4646
using ASTWalker::operator();
4747
void operator()(If const& _if) override;

test/libyul/YulOptimizerTestCommon.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
#include <libyul/optimiser/SSAReverser.h>
5353
#include <libyul/optimiser/SSATransform.h>
5454
#include <libyul/optimiser/Semantics.h>
55-
#include <libyul/optimiser/RedundantAssignEliminator.h>
55+
#include <libyul/optimiser/UnusedAssignEliminator.h>
5656
#include <libyul/optimiser/StructuralSimplifier.h>
5757
#include <libyul/optimiser/StackCompressor.h>
5858
#include <libyul/optimiser/Suite.h>
@@ -231,16 +231,16 @@ YulOptimizerTestCommon::YulOptimizerTestCommon(
231231
ForLoopInitRewriter::run(*m_context, *m_ast);
232232
SSATransform::run(*m_context, *m_ast);
233233
}},
234-
{"redundantAssignEliminator", [&]() {
234+
{"unusedAssignEliminator", [&]() {
235235
disambiguate();
236236
ForLoopInitRewriter::run(*m_context, *m_ast);
237-
RedundantAssignEliminator::run(*m_context, *m_ast);
237+
UnusedAssignEliminator::run(*m_context, *m_ast);
238238
}},
239239
{"ssaPlusCleanup", [&]() {
240240
disambiguate();
241241
ForLoopInitRewriter::run(*m_context, *m_ast);
242242
SSATransform::run(*m_context, *m_ast);
243-
RedundantAssignEliminator::run(*m_context, *m_ast);
243+
UnusedAssignEliminator::run(*m_context, *m_ast);
244244
}},
245245
{"loadResolver", [&]() {
246246
disambiguate();
@@ -293,7 +293,7 @@ YulOptimizerTestCommon::YulOptimizerTestCommon(
293293
ForLoopInitRewriter::run(*m_context, *m_ast);
294294
// apply SSA
295295
SSATransform::run(*m_context, *m_ast);
296-
RedundantAssignEliminator::run(*m_context, *m_ast);
296+
UnusedAssignEliminator::run(*m_context, *m_ast);
297297
// reverse SSA
298298
SSAReverser::run(*m_context, *m_ast);
299299
FunctionHoister::run(*m_context, *m_ast);

0 commit comments

Comments
 (0)