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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -27,6 +27,8 @@ using namespace mlir;
namespace {
/// Simple constant folding pass.
struct ConstantFold : public FunctionPass, StmtWalker<ConstantFold> {
ConstantFold() : FunctionPass(&ConstantFold::passID) {}
// All constants in the function post folding.
SmallVector<SSAValue *, 8> existingConstants;
// 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.
class ModuleConverter : public ModulePass {
public:
explicit ModuleConverter() {}
explicit ModuleConverter() : ModulePass(&ModuleConverter::passID) {}
PassResult runOnModule(Module *m) override;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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