Initialize Pass with PassID.

The passID is not currently stored in Pass but this avoids the unused variable warning. The passID is used to uniquely identify passes, currently this is only stored/used in PassInfo.

PiperOrigin-RevId: 220485662
This commit is contained in:
Jacques Pienaar 2018-11-07 10:24:03 -08:00 committed by jpienaar
parent a150e0b33d
commit cc9a6ed09d
15 changed files with 26 additions and 9 deletions

View File

@ -40,6 +40,7 @@ struct LLVM_NODISCARD PassResult {
class Pass { class Pass {
public: public:
explicit Pass(const void *passID) {}
virtual ~Pass() = default; virtual ~Pass() = default;
virtual PassResult runOnModule(Module *m) = 0; virtual PassResult runOnModule(Module *m) = 0;
@ -54,6 +55,8 @@ private:
class ModulePass : public Pass { class ModulePass : public Pass {
public: public:
explicit ModulePass(const void *passID) : Pass(passID) {}
virtual PassResult runOnModule(Module *m) override = 0; virtual PassResult runOnModule(Module *m) override = 0;
private: private:
@ -69,6 +72,8 @@ private:
/// module. /// module.
class FunctionPass : public Pass { class FunctionPass : public Pass {
public: public:
explicit FunctionPass(const void *passID) : Pass(passID) {}
/// Implement this function to be run on every function in the module. If you /// Implement this function to be run on every function in the module. If you
/// do not implement this, the default implementation will dispatch to /// do not implement this, the default implementation will dispatch to
/// runOnCFGFunction or runOnMLFunction. /// runOnCFGFunction or runOnMLFunction.

View File

@ -38,7 +38,7 @@ namespace {
/// Checks for out of bound memef access subscripts.. /// Checks for out of bound memef access subscripts..
struct MemRefBoundCheck : public FunctionPass, StmtWalker<MemRefBoundCheck> { struct MemRefBoundCheck : public FunctionPass, StmtWalker<MemRefBoundCheck> {
explicit MemRefBoundCheck() {} explicit MemRefBoundCheck() : FunctionPass(&MemRefBoundCheck::passID) {}
PassResult runOnMLFunction(MLFunction *f) override; PassResult runOnMLFunction(MLFunction *f) override;
// Not applicable to CFG functions. // Not applicable to CFG functions.

View File

@ -40,7 +40,8 @@ namespace {
struct MemRefDependenceCheck : public FunctionPass, struct MemRefDependenceCheck : public FunctionPass,
StmtWalker<MemRefDependenceCheck> { StmtWalker<MemRefDependenceCheck> {
SmallVector<OperationStmt *, 4> loadsAndStores; SmallVector<OperationStmt *, 4> loadsAndStores;
explicit MemRefDependenceCheck() {} explicit MemRefDependenceCheck()
: FunctionPass(&MemRefDependenceCheck::passID) {}
PassResult runOnMLFunction(MLFunction *f) override; PassResult runOnMLFunction(MLFunction *f) override;
// Not applicable to CFG functions. // Not applicable to CFG functions.

View File

@ -76,7 +76,8 @@ namespace {
struct PrintCFGPass : public FunctionPass { struct PrintCFGPass : public FunctionPass {
PrintCFGPass(llvm::raw_ostream &os = llvm::errs(), bool shortNames = false, PrintCFGPass(llvm::raw_ostream &os = llvm::errs(), bool shortNames = false,
const llvm::Twine &title = "") const llvm::Twine &title = "")
: os(os), shortNames(shortNames), title(title) {} : FunctionPass(&PrintCFGPass::passID), os(os), shortNames(shortNames),
title(title) {}
PassResult runOnCFGFunction(CFGFunction *function) override { PassResult runOnCFGFunction(CFGFunction *function) override {
mlir::writeGraph(os, function, shortNames, title); mlir::writeGraph(os, function, shortNames, title);
return success(); return success();

View File

@ -34,6 +34,7 @@ namespace {
/// Canonicalize operations in functions. /// Canonicalize operations in functions.
struct Canonicalizer : public FunctionPass { struct Canonicalizer : public FunctionPass {
Canonicalizer() : FunctionPass(&Canonicalizer::passID) {}
PassResult runOnFunction(Function *fn) override; PassResult runOnFunction(Function *fn) override;
static char passID; static char passID;

View File

@ -44,7 +44,7 @@ namespace {
struct ComposeAffineMaps : public FunctionPass, StmtWalker<ComposeAffineMaps> { struct ComposeAffineMaps : public FunctionPass, StmtWalker<ComposeAffineMaps> {
std::vector<OperationStmt *> affineApplyOpsToErase; std::vector<OperationStmt *> affineApplyOpsToErase;
explicit ComposeAffineMaps() {} explicit ComposeAffineMaps() : FunctionPass(&ComposeAffineMaps::passID) {}
using StmtListType = llvm::iplist<Statement>; using StmtListType = llvm::iplist<Statement>;
void walk(StmtListType::iterator Start, StmtListType::iterator End); void walk(StmtListType::iterator Start, StmtListType::iterator End);
void visitOperationStmt(OperationStmt *stmt); void visitOperationStmt(OperationStmt *stmt);

View File

@ -27,6 +27,8 @@ using namespace mlir;
namespace { namespace {
/// Simple constant folding pass. /// Simple constant folding pass.
struct ConstantFold : public FunctionPass, StmtWalker<ConstantFold> { struct ConstantFold : public FunctionPass, StmtWalker<ConstantFold> {
ConstantFold() : FunctionPass(&ConstantFold::passID) {}
// All constants in the function post folding. // All constants in the function post folding.
SmallVector<SSAValue *, 8> existingConstants; SmallVector<SSAValue *, 8> existingConstants;
// Operation statements that were folded and that need to be erased. // Operation statements that were folded and that need to be erased.

View File

@ -66,7 +66,7 @@ namespace {
// ModuleConverter class does CFG conversion for the whole module. // ModuleConverter class does CFG conversion for the whole module.
class ModuleConverter : public ModulePass { class ModuleConverter : public ModulePass {
public: public:
explicit ModuleConverter() {} explicit ModuleConverter() : ModulePass(&ModuleConverter::passID) {}
PassResult runOnModule(Module *m) override; PassResult runOnModule(Module *m) override;

View File

@ -42,7 +42,7 @@ namespace {
// TODO(andydavis) Extend this pass to check for fusion preventing dependences, // TODO(andydavis) Extend this pass to check for fusion preventing dependences,
// and add support for more general loop fusion algorithms. // and add support for more general loop fusion algorithms.
struct LoopFusion : public FunctionPass { struct LoopFusion : public FunctionPass {
LoopFusion() {} LoopFusion() : FunctionPass(&LoopFusion::passID) {}
PassResult runOnMLFunction(MLFunction *f) override; PassResult runOnMLFunction(MLFunction *f) override;
static char passID; static char passID;

View File

@ -40,6 +40,7 @@ namespace {
/// A pass to perform loop tiling on all suitable loop nests of an MLFunction. /// A pass to perform loop tiling on all suitable loop nests of an MLFunction.
struct LoopTiling : public FunctionPass { struct LoopTiling : public FunctionPass {
LoopTiling() : FunctionPass(&LoopTiling::passID) {}
PassResult runOnMLFunction(MLFunction *f) override; PassResult runOnMLFunction(MLFunction *f) override;
constexpr static unsigned kDefaultTileSize = 32; constexpr static unsigned kDefaultTileSize = 32;

View File

@ -58,7 +58,8 @@ struct LoopUnroll : public FunctionPass {
explicit LoopUnroll(Optional<unsigned> unrollFactor = None, explicit LoopUnroll(Optional<unsigned> unrollFactor = None,
Optional<bool> unrollFull = None) Optional<bool> unrollFull = None)
: unrollFactor(unrollFactor), unrollFull(unrollFull) {} : FunctionPass(&LoopUnroll::passID), unrollFactor(unrollFactor),
unrollFull(unrollFull) {}
PassResult runOnMLFunction(MLFunction *f) override; PassResult runOnMLFunction(MLFunction *f) override;

View File

@ -71,7 +71,8 @@ struct LoopUnrollAndJam : public FunctionPass {
static const unsigned kDefaultUnrollJamFactor = 4; static const unsigned kDefaultUnrollJamFactor = 4;
explicit LoopUnrollAndJam(Optional<unsigned> unrollJamFactor = None) explicit LoopUnrollAndJam(Optional<unsigned> unrollJamFactor = None)
: unrollJamFactor(unrollJamFactor) {} : FunctionPass(&LoopUnrollAndJam::passID),
unrollJamFactor(unrollJamFactor) {}
PassResult runOnMLFunction(MLFunction *f) override; PassResult runOnMLFunction(MLFunction *f) override;
bool runOnForStmt(ForStmt *forStmt); bool runOnForStmt(ForStmt *forStmt);

View File

@ -41,6 +41,7 @@ namespace {
struct PipelineDataTransfer : public FunctionPass, struct PipelineDataTransfer : public FunctionPass,
StmtWalker<PipelineDataTransfer> { StmtWalker<PipelineDataTransfer> {
PipelineDataTransfer() : FunctionPass(&PipelineDataTransfer::passID) {}
PassResult runOnMLFunction(MLFunction *f) override; PassResult runOnMLFunction(MLFunction *f) override;
PassResult runOnForStmt(ForStmt *forStmt); PassResult runOnForStmt(ForStmt *forStmt);

View File

@ -38,7 +38,8 @@ namespace {
// ML functions and CFG functions. // ML functions and CFG functions.
struct SimplifyAffineStructures : public FunctionPass, struct SimplifyAffineStructures : public FunctionPass,
StmtWalker<SimplifyAffineStructures> { StmtWalker<SimplifyAffineStructures> {
explicit SimplifyAffineStructures() {} explicit SimplifyAffineStructures()
: FunctionPass(&SimplifyAffineStructures::passID) {}
PassResult runOnMLFunction(MLFunction *f) override; PassResult runOnMLFunction(MLFunction *f) override;
// Does nothing on CFG functions for now. No reusable walkers/visitors exist // Does nothing on CFG functions for now. No reusable walkers/visitors exist

View File

@ -195,6 +195,8 @@ static std::vector<MLFunctionMatcher> makePatterns() {
namespace { namespace {
struct Vectorize : public FunctionPass { struct Vectorize : public FunctionPass {
Vectorize() : FunctionPass(&Vectorize::passID) {}
PassResult runOnMLFunction(MLFunction *f) override; PassResult runOnMLFunction(MLFunction *f) override;
// Thread-safe RAII contexts local to pass, BumpPtrAllocator freed on exit. // Thread-safe RAII contexts local to pass, BumpPtrAllocator freed on exit.