Skip to content

Commit 9f9e9ae

Browse files
Add a superclass typedef to WalkerPass to simplify overrides (#1211)
1 parent 7c49199 commit 9f9e9ae

12 files changed

+17
-14
lines changed

src/pass.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,9 @@ template <typename WalkerType>
213213
class WalkerPass : public Pass, public WalkerType {
214214
PassRunner *runner;
215215

216+
protected:
217+
typedef WalkerPass<WalkerType> super;
218+
216219
public:
217220
void run(PassRunner* runner, Module* module) override {
218221
setPassRunner(runner);

src/passes/CoalesceLocals.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ void CoalesceLocals::doWalkFunction(Function* func) {
271271
totalCopies.resize(numLocals);
272272
std::fill(totalCopies.begin(), totalCopies.end(), 0);
273273
// collect initial liveness info
274-
WalkerPass<CFGWalker<CoalesceLocals, Visitor<CoalesceLocals>, Liveness>>::doWalkFunction(func);
274+
super::doWalkFunction(func);
275275
// ignore links to dead blocks, so they don't confuse us and we can see their stores are all ineffective
276276
liveBlocks = findLiveBlocks();
277277
unlinkDeadBlocks(liveBlocks);

src/passes/CodeFolding.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ struct CodeFolding : public WalkerPass<ControlFlowWalker<CodeFolding>> {
221221
anotherPass = true;
222222
while (anotherPass) {
223223
anotherPass = false;
224-
WalkerPass<ControlFlowWalker<CodeFolding>>::doWalkFunction(func);
224+
super::doWalkFunction(func);
225225
optimizeTerminatingTails(unreachableTails);
226226
// optimize returns at the end, so we can benefit from a fallthrough if there is a value TODO: separate passes for them?
227227
optimizeTerminatingTails(returnTails);

src/passes/DeadCodeElimination.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ struct DeadCodeElimination : public WalkerPass<PostWalker<DeadCodeElimination>>
4949
Expression* replaceCurrent(Expression* expression) {
5050
auto* old = getCurrent();
5151
if (old == expression) return expression;
52-
WalkerPass<PostWalker<DeadCodeElimination>>::replaceCurrent(expression);
52+
super::replaceCurrent(expression);
5353
// also update the type updater
5454
typeUpdater.noteReplacement(old, expression);
5555
return expression;
@@ -270,7 +270,7 @@ struct DeadCodeElimination : public WalkerPass<PostWalker<DeadCodeElimination>>
270270
self->pushTask(DeadCodeElimination::doAfterIfCondition, currp);
271271
self->pushTask(DeadCodeElimination::scan, &curr->cast<If>()->condition);
272272
} else {
273-
WalkerPass<PostWalker<DeadCodeElimination>>::scan(self, currp);
273+
super::scan(self, currp);
274274
}
275275
}
276276

src/passes/LocalCSE.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ struct LocalCSE : public WalkerPass<LinearExecutionWalker<LocalCSE>> {
109109
static void scan(LocalCSE* self, Expression** currp) {
110110
self->pushTask(visitPost, currp);
111111

112-
WalkerPass<LinearExecutionWalker<LocalCSE>>::scan(self, currp);
112+
super::scan(self, currp);
113113

114114
self->pushTask(visitPre, currp);
115115
}

src/passes/OptimizeInstructions.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ struct OptimizeInstructions : public WalkerPass<PostWalker<OptimizeInstructions,
364364
scanner.walkFunction(func);
365365
}
366366
// main walk
367-
WalkerPass<PostWalker<OptimizeInstructions, UnifiedExpressionVisitor<OptimizeInstructions>>>::doWalkFunction(func);
367+
super::doWalkFunction(func);
368368
}
369369

370370
void visitExpression(Expression* curr) {

src/passes/Precompute.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ struct Precompute : public WalkerPass<PostWalker<Precompute, UnifiedExpressionVi
117117
optimizeLocals(func, getModule());
118118
}
119119
// do the main and final walk over everything
120-
WalkerPass<PostWalker<Precompute, UnifiedExpressionVisitor<Precompute>>>::doWalkFunction(func);
120+
super::doWalkFunction(func);
121121
}
122122

123123
void visitExpression(Expression* curr) {

src/passes/RelooperJumpThreading.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ struct RelooperJumpThreading : public WalkerPass<ExpressionStackWalker<RelooperJ
145145
labelIndex = func->getLocalIndex(LABEL);
146146
LabelUseFinder finder(labelIndex, labelChecks, labelSets);
147147
finder.walk(func->body);
148-
WalkerPass<ExpressionStackWalker<RelooperJumpThreading>>::doWalkFunction(func);
148+
super::doWalkFunction(func);
149149
}
150150
}
151151

src/passes/RemoveUnusedBrs.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ struct RemoveUnusedBrs : public WalkerPass<PostWalker<RemoveUnusedBrs>> {
207207
self->pushTask(clear, currp); // clear all flow after the condition
208208
self->pushTask(scan, &iff->condition);
209209
} else {
210-
WalkerPass<PostWalker<RemoveUnusedBrs>>::scan(self, currp);
210+
super::scan(self, currp);
211211
}
212212
}
213213

@@ -343,7 +343,7 @@ struct RemoveUnusedBrs : public WalkerPass<PostWalker<RemoveUnusedBrs>> {
343343
bool worked = false;
344344
do {
345345
anotherCycle = false;
346-
WalkerPass<PostWalker<RemoveUnusedBrs>>::doWalkFunction(func);
346+
super::doWalkFunction(func);
347347
assert(ifStack.empty());
348348
// flows may contain returns, which are flowing out and so can be optimized
349349
for (size_t i = 0; i < flows.size(); i++) {

src/passes/SimplifyLocals.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ struct SimplifyLocals : public WalkerPass<LinearExecutionWalker<SimplifyLocals>>
432432
self->pushTask(SimplifyLocals::doNoteIfElseCondition, currp);
433433
self->pushTask(SimplifyLocals::scan, &curr->cast<If>()->condition);
434434
} else {
435-
WalkerPass<LinearExecutionWalker<SimplifyLocals>>::scan(self, currp);
435+
super::scan(self, currp);
436436
}
437437

438438
self->pushTask(visitPre, currp);
@@ -454,7 +454,7 @@ struct SimplifyLocals : public WalkerPass<LinearExecutionWalker<SimplifyLocals>>
454454
do {
455455
anotherCycle = false;
456456
// main operation
457-
WalkerPass<LinearExecutionWalker<SimplifyLocals>>::doWalkFunction(func);
457+
super::doWalkFunction(func);
458458
// enlarge blocks that were marked, for the next round
459459
if (blocksToEnlarge.size() > 0) {
460460
for (auto* block : blocksToEnlarge) {

src/passes/TrapMode.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ struct TrapModePass : public WalkerPass<PostWalker<TrapModePass>> {
297297

298298
void doWalkModule(Module* module) {
299299
trappingFunctions = make_unique<TrappingFunctionContainer>(mode, *module);
300-
WalkerPass<PostWalker<TrapModePass>>::doWalkModule(module);
300+
super::doWalkModule(module);
301301
}
302302

303303
private:

src/passes/Vacuum.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ struct Vacuum : public WalkerPass<PostWalker<Vacuum>> {
3636

3737
Expression* replaceCurrent(Expression* expression) {
3838
auto* old = getCurrent();
39-
WalkerPass<PostWalker<Vacuum>>::replaceCurrent(expression);
39+
super::replaceCurrent(expression);
4040
// also update the type updater
4141
typeUpdater.noteReplacement(old, expression);
4242
return expression;

0 commit comments

Comments
 (0)