From 9f9e9ae0fc94825c7db4edc8a2e6aa1190f39fc7 Mon Sep 17 00:00:00 2001 From: jgravelle-google Date: Wed, 4 Oct 2017 10:14:36 -0700 Subject: Add a superclass typedef to WalkerPass to simplify overrides (#1211) --- src/pass.h | 3 +++ src/passes/CoalesceLocals.cpp | 2 +- src/passes/CodeFolding.cpp | 2 +- src/passes/DeadCodeElimination.cpp | 4 ++-- src/passes/LocalCSE.cpp | 2 +- src/passes/OptimizeInstructions.cpp | 2 +- src/passes/Precompute.cpp | 2 +- src/passes/RelooperJumpThreading.cpp | 2 +- src/passes/RemoveUnusedBrs.cpp | 4 ++-- src/passes/SimplifyLocals.cpp | 4 ++-- src/passes/TrapMode.cpp | 2 +- src/passes/Vacuum.cpp | 2 +- 12 files changed, 17 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/pass.h b/src/pass.h index 2f3bca078..1c37bea40 100644 --- a/src/pass.h +++ b/src/pass.h @@ -213,6 +213,9 @@ template class WalkerPass : public Pass, public WalkerType { PassRunner *runner; +protected: + typedef WalkerPass super; + public: void run(PassRunner* runner, Module* module) override { setPassRunner(runner); diff --git a/src/passes/CoalesceLocals.cpp b/src/passes/CoalesceLocals.cpp index 5ab68da23..af25f3fbe 100644 --- a/src/passes/CoalesceLocals.cpp +++ b/src/passes/CoalesceLocals.cpp @@ -271,7 +271,7 @@ void CoalesceLocals::doWalkFunction(Function* func) { totalCopies.resize(numLocals); std::fill(totalCopies.begin(), totalCopies.end(), 0); // collect initial liveness info - WalkerPass, Liveness>>::doWalkFunction(func); + super::doWalkFunction(func); // ignore links to dead blocks, so they don't confuse us and we can see their stores are all ineffective liveBlocks = findLiveBlocks(); unlinkDeadBlocks(liveBlocks); diff --git a/src/passes/CodeFolding.cpp b/src/passes/CodeFolding.cpp index 047eee452..105232676 100644 --- a/src/passes/CodeFolding.cpp +++ b/src/passes/CodeFolding.cpp @@ -221,7 +221,7 @@ struct CodeFolding : public WalkerPass> { anotherPass = true; while (anotherPass) { anotherPass = false; - WalkerPass>::doWalkFunction(func); + super::doWalkFunction(func); optimizeTerminatingTails(unreachableTails); // optimize returns at the end, so we can benefit from a fallthrough if there is a value TODO: separate passes for them? optimizeTerminatingTails(returnTails); diff --git a/src/passes/DeadCodeElimination.cpp b/src/passes/DeadCodeElimination.cpp index bca898e25..e5673a0cc 100644 --- a/src/passes/DeadCodeElimination.cpp +++ b/src/passes/DeadCodeElimination.cpp @@ -49,7 +49,7 @@ struct DeadCodeElimination : public WalkerPass> Expression* replaceCurrent(Expression* expression) { auto* old = getCurrent(); if (old == expression) return expression; - WalkerPass>::replaceCurrent(expression); + super::replaceCurrent(expression); // also update the type updater typeUpdater.noteReplacement(old, expression); return expression; @@ -270,7 +270,7 @@ struct DeadCodeElimination : public WalkerPass> self->pushTask(DeadCodeElimination::doAfterIfCondition, currp); self->pushTask(DeadCodeElimination::scan, &curr->cast()->condition); } else { - WalkerPass>::scan(self, currp); + super::scan(self, currp); } } diff --git a/src/passes/LocalCSE.cpp b/src/passes/LocalCSE.cpp index a3e0dff76..609caf43a 100644 --- a/src/passes/LocalCSE.cpp +++ b/src/passes/LocalCSE.cpp @@ -109,7 +109,7 @@ struct LocalCSE : public WalkerPass> { static void scan(LocalCSE* self, Expression** currp) { self->pushTask(visitPost, currp); - WalkerPass>::scan(self, currp); + super::scan(self, currp); self->pushTask(visitPre, currp); } diff --git a/src/passes/OptimizeInstructions.cpp b/src/passes/OptimizeInstructions.cpp index b59b41b6a..27b573c0d 100644 --- a/src/passes/OptimizeInstructions.cpp +++ b/src/passes/OptimizeInstructions.cpp @@ -364,7 +364,7 @@ struct OptimizeInstructions : public WalkerPass>>::doWalkFunction(func); + super::doWalkFunction(func); } void visitExpression(Expression* curr) { diff --git a/src/passes/Precompute.cpp b/src/passes/Precompute.cpp index 72292c730..ab114fa14 100644 --- a/src/passes/Precompute.cpp +++ b/src/passes/Precompute.cpp @@ -117,7 +117,7 @@ struct Precompute : public WalkerPass>>::doWalkFunction(func); + super::doWalkFunction(func); } void visitExpression(Expression* curr) { diff --git a/src/passes/RelooperJumpThreading.cpp b/src/passes/RelooperJumpThreading.cpp index 3656b5523..ad7582fb4 100644 --- a/src/passes/RelooperJumpThreading.cpp +++ b/src/passes/RelooperJumpThreading.cpp @@ -145,7 +145,7 @@ struct RelooperJumpThreading : public WalkerPassgetLocalIndex(LABEL); LabelUseFinder finder(labelIndex, labelChecks, labelSets); finder.walk(func->body); - WalkerPass>::doWalkFunction(func); + super::doWalkFunction(func); } } diff --git a/src/passes/RemoveUnusedBrs.cpp b/src/passes/RemoveUnusedBrs.cpp index 7e122b806..7903534b6 100644 --- a/src/passes/RemoveUnusedBrs.cpp +++ b/src/passes/RemoveUnusedBrs.cpp @@ -207,7 +207,7 @@ struct RemoveUnusedBrs : public WalkerPass> { self->pushTask(clear, currp); // clear all flow after the condition self->pushTask(scan, &iff->condition); } else { - WalkerPass>::scan(self, currp); + super::scan(self, currp); } } @@ -343,7 +343,7 @@ struct RemoveUnusedBrs : public WalkerPass> { bool worked = false; do { anotherCycle = false; - WalkerPass>::doWalkFunction(func); + super::doWalkFunction(func); assert(ifStack.empty()); // flows may contain returns, which are flowing out and so can be optimized for (size_t i = 0; i < flows.size(); i++) { diff --git a/src/passes/SimplifyLocals.cpp b/src/passes/SimplifyLocals.cpp index 618f8dead..cc74220df 100644 --- a/src/passes/SimplifyLocals.cpp +++ b/src/passes/SimplifyLocals.cpp @@ -432,7 +432,7 @@ struct SimplifyLocals : public WalkerPass> self->pushTask(SimplifyLocals::doNoteIfElseCondition, currp); self->pushTask(SimplifyLocals::scan, &curr->cast()->condition); } else { - WalkerPass>::scan(self, currp); + super::scan(self, currp); } self->pushTask(visitPre, currp); @@ -454,7 +454,7 @@ struct SimplifyLocals : public WalkerPass> do { anotherCycle = false; // main operation - WalkerPass>::doWalkFunction(func); + super::doWalkFunction(func); // enlarge blocks that were marked, for the next round if (blocksToEnlarge.size() > 0) { for (auto* block : blocksToEnlarge) { diff --git a/src/passes/TrapMode.cpp b/src/passes/TrapMode.cpp index e648f66a5..2cb7b2f6b 100644 --- a/src/passes/TrapMode.cpp +++ b/src/passes/TrapMode.cpp @@ -297,7 +297,7 @@ public: void doWalkModule(Module* module) { trappingFunctions = make_unique(mode, *module); - WalkerPass>::doWalkModule(module); + super::doWalkModule(module); } private: diff --git a/src/passes/Vacuum.cpp b/src/passes/Vacuum.cpp index 30b28a75d..ea2377679 100644 --- a/src/passes/Vacuum.cpp +++ b/src/passes/Vacuum.cpp @@ -36,7 +36,7 @@ struct Vacuum : public WalkerPass> { Expression* replaceCurrent(Expression* expression) { auto* old = getCurrent(); - WalkerPass>::replaceCurrent(expression); + super::replaceCurrent(expression); // also update the type updater typeUpdater.noteReplacement(old, expression); return expression; -- cgit v1.2.3