Skip to content

Commit

Permalink
[Polly] Mark classes as final by default. NFC.
Browse files Browse the repository at this point in the history
This make is obivious that a class was not intended to be derived from.

NPM analysis pass can unfortunately not marked as final because they are
derived from a llvm::Checker<T> template internally by the NPM.

Also normalize the use of classes/structs
 * NPM passes are structs
 * Legacy passes are classes
 * structs that have methods and are not a visitor pattern are classes
 * structs have public inheritance by default, remove "public" keyword
 * Use typedef'ed type instead of inline forward declaration
  • Loading branch information
Meinersbur committed May 17, 2022
1 parent d92cec4 commit bd93df9
Show file tree
Hide file tree
Showing 66 changed files with 209 additions and 212 deletions.
8 changes: 4 additions & 4 deletions llvm/include/llvm/Analysis/DOTGraphTraitsPass.h
Expand Up @@ -41,8 +41,8 @@ template <typename AnalysisT, bool IsSimple,
typename AnalysisGraphTraitsT =
DefaultAnalysisGraphTraits<typename AnalysisT::Result &, GraphT>>
struct DOTGraphTraitsViewer
: public PassInfoMixin<DOTGraphTraitsViewer<AnalysisT, IsSimple, GraphT,
AnalysisGraphTraitsT>> {
: PassInfoMixin<DOTGraphTraitsViewer<AnalysisT, IsSimple, GraphT,
AnalysisGraphTraitsT>> {
DOTGraphTraitsViewer(StringRef GraphName) : Name(GraphName) {}
virtual ~DOTGraphTraitsViewer() {}

Expand Down Expand Up @@ -96,8 +96,8 @@ template <typename AnalysisT, bool IsSimple,
typename AnalysisGraphTraitsT =
DefaultAnalysisGraphTraits<typename AnalysisT::Result &, GraphT>>
struct DOTGraphTraitsPrinter
: public PassInfoMixin<DOTGraphTraitsPrinter<AnalysisT, IsSimple, GraphT,
AnalysisGraphTraitsT>> {
: PassInfoMixin<DOTGraphTraitsPrinter<AnalysisT, IsSimple, GraphT,
AnalysisGraphTraitsT>> {
DOTGraphTraitsPrinter(StringRef GraphName) : Name(GraphName) {}
virtual ~DOTGraphTraitsPrinter() {}

Expand Down
4 changes: 2 additions & 2 deletions polly/include/polly/CodeGen/BlockGenerators.h
Expand Up @@ -625,7 +625,7 @@ class BlockGenerator {
/// Generate a new vector basic block for a polyhedral statement.
///
/// The only public function exposed is generate().
class VectorBlockGenerator : BlockGenerator {
class VectorBlockGenerator final : BlockGenerator {
public:
/// Generate a new vector basic block for a ScoPStmt.
///
Expand Down Expand Up @@ -803,7 +803,7 @@ class VectorBlockGenerator : BlockGenerator {
};

/// Generator for new versions of polyhedral region statements.
class RegionGenerator : public BlockGenerator {
class RegionGenerator final : BlockGenerator {
public:
/// Create a generator for regions.
///
Expand Down
2 changes: 1 addition & 1 deletion polly/include/polly/CodeGen/CodeGeneration.h
Expand Up @@ -28,7 +28,7 @@ extern VectorizerChoice PollyVectorizerChoice;
/// UnreachableInst.
void markBlockUnreachable(BasicBlock &Block, PollyIRBuilder &Builder);

struct CodeGenerationPass : public PassInfoMixin<CodeGenerationPass> {
struct CodeGenerationPass final : PassInfoMixin<CodeGenerationPass> {
PreservedAnalyses run(Scop &S, ScopAnalysisManager &SAM,
ScopStandardAnalysisResults &AR, SPMUpdater &U);
};
Expand Down
4 changes: 2 additions & 2 deletions polly/include/polly/CodeGen/IRBuilder.h
Expand Up @@ -120,7 +120,7 @@ class ScopAnnotator {
class IRInserter final : public llvm::IRBuilderDefaultInserter {
public:
IRInserter() = default;
IRInserter(class ScopAnnotator &A) : Annotator(&A) {}
IRInserter(ScopAnnotator &A) : Annotator(&A) {}

void InsertHelper(llvm::Instruction *I, const llvm::Twine &Name,
llvm::BasicBlock *BB,
Expand All @@ -131,7 +131,7 @@ class IRInserter final : public llvm::IRBuilderDefaultInserter {
}

private:
class ScopAnnotator *Annotator = nullptr;
ScopAnnotator *Annotator = nullptr;
};

// TODO: We should not name instructions in NDEBUG builds.
Expand Down
10 changes: 5 additions & 5 deletions polly/include/polly/CodeGen/IslAst.h
Expand Up @@ -29,9 +29,9 @@
namespace polly {
using llvm::SmallPtrSet;

struct Dependences;
class Dependences;

class IslAst {
class IslAst final {
public:
IslAst(const IslAst &) = delete;
IslAst &operator=(const IslAst &) = delete;
Expand Down Expand Up @@ -163,7 +163,7 @@ class IslAstInfo {
///}
};

struct IslAstAnalysis : public AnalysisInfoMixin<IslAstAnalysis> {
struct IslAstAnalysis : AnalysisInfoMixin<IslAstAnalysis> {
static AnalysisKey Key;

using Result = IslAstInfo;
Expand All @@ -172,7 +172,7 @@ struct IslAstAnalysis : public AnalysisInfoMixin<IslAstAnalysis> {
ScopStandardAnalysisResults &SAR);
};

class IslAstInfoWrapperPass : public ScopPass {
class IslAstInfoWrapperPass final : public ScopPass {
std::unique_ptr<IslAstInfo> Ast;

public:
Expand All @@ -199,7 +199,7 @@ class IslAstInfoWrapperPass : public ScopPass {
llvm::Pass *createIslAstInfoWrapperPassPass();
llvm::Pass *createIslAstInfoPrinterLegacyPass(llvm::raw_ostream &OS);

struct IslAstPrinterPass : public PassInfoMixin<IslAstPrinterPass> {
struct IslAstPrinterPass final : PassInfoMixin<IslAstPrinterPass> {
IslAstPrinterPass(raw_ostream &OS) : OS(OS) {}

PreservedAnalyses run(Scop &S, ScopAnalysisManager &SAM,
Expand Down
2 changes: 1 addition & 1 deletion polly/include/polly/CodeGen/IslExprBuilder.h
Expand Up @@ -78,7 +78,7 @@ class ScopArrayInfo;
/// to use this information in our IslAstGenerator. Preliminary patches are
/// available, but have not been committed yet.
///
class IslExprBuilder {
class IslExprBuilder final {
public:
/// A map from isl_ids to llvm::Values.
typedef llvm::MapVector<isl_id *, llvm::AssertingVH<llvm::Value>> IDToValueTy;
Expand Down
2 changes: 1 addition & 1 deletion polly/include/polly/CodeGen/LoopGeneratorsGOMP.h
Expand Up @@ -22,7 +22,7 @@ namespace polly {

/// This ParallelLoopGenerator subclass handles the generation of parallelized
/// code, utilizing the GNU OpenMP library.
class ParallelLoopGeneratorGOMP : public ParallelLoopGenerator {
class ParallelLoopGeneratorGOMP final : public ParallelLoopGenerator {
public:
/// Create a parallel loop generator for the current function.
ParallelLoopGeneratorGOMP(PollyIRBuilder &Builder, LoopInfo &LI,
Expand Down
2 changes: 1 addition & 1 deletion polly/include/polly/CodeGen/LoopGeneratorsKMP.h
Expand Up @@ -24,7 +24,7 @@ using llvm::GlobalVariable;

/// This ParallelLoopGenerator subclass handles the generation of parallelized
/// code, utilizing the LLVM OpenMP library.
class ParallelLoopGeneratorKMP : public ParallelLoopGenerator {
class ParallelLoopGeneratorKMP final : public ParallelLoopGenerator {
public:
/// Create a parallel loop generator for the current function.
ParallelLoopGeneratorKMP(PollyIRBuilder &Builder, LoopInfo &LI,
Expand Down
2 changes: 1 addition & 1 deletion polly/include/polly/CodeGen/PerfMonitor.h
Expand Up @@ -13,7 +13,7 @@

namespace polly {

class PerfMonitor {
class PerfMonitor final {
public:
/// Create a new performance monitor.
///
Expand Down
2 changes: 1 addition & 1 deletion polly/include/polly/CodePreparation.h
Expand Up @@ -16,7 +16,7 @@
#include "llvm/IR/PassManager.h"

namespace polly {
struct CodePreparationPass : public llvm::PassInfoMixin<CodePreparationPass> {
struct CodePreparationPass final : llvm::PassInfoMixin<CodePreparationPass> {
llvm::PreservedAnalyses run(llvm::Function &F,
llvm::FunctionAnalysisManager &FAM);
};
Expand Down
4 changes: 2 additions & 2 deletions polly/include/polly/DeLICM.h
Expand Up @@ -31,14 +31,14 @@ namespace polly {
llvm::Pass *createDeLICMWrapperPass();
llvm::Pass *createDeLICMPrinterLegacyPass(llvm::raw_ostream &OS);

struct DeLICMPass : llvm::PassInfoMixin<DeLICMPass> {
struct DeLICMPass final : llvm::PassInfoMixin<DeLICMPass> {
DeLICMPass() {}

llvm::PreservedAnalyses run(Scop &S, ScopAnalysisManager &SAM,
ScopStandardAnalysisResults &SAR, SPMUpdater &U);
};

struct DeLICMPrinterPass : llvm::PassInfoMixin<DeLICMPrinterPass> {
struct DeLICMPrinterPass final : llvm::PassInfoMixin<DeLICMPrinterPass> {
DeLICMPrinterPass(raw_ostream &OS) : OS(OS) {}

PreservedAnalyses run(Scop &S, ScopAnalysisManager &,
Expand Down
2 changes: 1 addition & 1 deletion polly/include/polly/DeadCodeElimination.h
Expand Up @@ -24,7 +24,7 @@ class raw_ostream;
namespace polly {
llvm::Pass *createDeadCodeElimWrapperPass();

struct DeadCodeElimPass : llvm::PassInfoMixin<DeadCodeElimPass> {
struct DeadCodeElimPass final : llvm::PassInfoMixin<DeadCodeElimPass> {
DeadCodeElimPass() {}

llvm::PreservedAnalyses run(Scop &S, ScopAnalysisManager &SAM,
Expand Down
13 changes: 7 additions & 6 deletions polly/include/polly/DependenceInfo.h
Expand Up @@ -33,7 +33,8 @@ namespace polly {
/// The Dependences struct holds all dependence information we collect and
/// compute for one SCoP. It also offers an interface that allows users to
/// query only specific parts.
struct Dependences {
class Dependences final {
public:
// Granularities of the current dependence analysis
enum AnalysisLevel {
AL_Statement = 0,
Expand Down Expand Up @@ -191,7 +192,7 @@ struct Dependences {
const AnalysisLevel Level;
};

struct DependenceAnalysis : public AnalysisInfoMixin<DependenceAnalysis> {
struct DependenceAnalysis final : public AnalysisInfoMixin<DependenceAnalysis> {
static AnalysisKey Key;
struct Result {
Scop &S;
Expand All @@ -212,8 +213,8 @@ struct DependenceAnalysis : public AnalysisInfoMixin<DependenceAnalysis> {
ScopStandardAnalysisResults &SAR);
};

struct DependenceInfoPrinterPass
: public PassInfoMixin<DependenceInfoPrinterPass> {
struct DependenceInfoPrinterPass final
: PassInfoMixin<DependenceInfoPrinterPass> {
DependenceInfoPrinterPass(raw_ostream &OS) : OS(OS) {}

PreservedAnalyses run(Scop &S, ScopAnalysisManager &,
Expand All @@ -222,7 +223,7 @@ struct DependenceInfoPrinterPass
raw_ostream &OS;
};

class DependenceInfo : public ScopPass {
class DependenceInfo final : public ScopPass {
public:
static char ID;

Expand Down Expand Up @@ -266,7 +267,7 @@ llvm::Pass *createDependenceInfoPass();
llvm::Pass *createDependenceInfoPrinterLegacyPass(llvm::raw_ostream &OS);

/// Construct a new DependenceInfoWrapper pass.
class DependenceInfoWrapperPass : public FunctionPass {
class DependenceInfoWrapperPass final : public FunctionPass {
public:
static char ID;

Expand Down
4 changes: 2 additions & 2 deletions polly/include/polly/ForwardOpTree.h
Expand Up @@ -23,14 +23,14 @@ namespace polly {
llvm::Pass *createForwardOpTreeWrapperPass();
llvm::Pass *createForwardOpTreePrinterLegacyPass(llvm::raw_ostream &OS);

struct ForwardOpTreePass : llvm::PassInfoMixin<ForwardOpTreePass> {
struct ForwardOpTreePass final : llvm::PassInfoMixin<ForwardOpTreePass> {
ForwardOpTreePass() {}

llvm::PreservedAnalyses run(Scop &S, ScopAnalysisManager &SAM,
ScopStandardAnalysisResults &SAR, SPMUpdater &U);
};

struct ForwardOpTreePrinterPass
struct ForwardOpTreePrinterPass final
: llvm::PassInfoMixin<ForwardOpTreePrinterPass> {
ForwardOpTreePrinterPass(raw_ostream &OS) : OS(OS) {}

Expand Down
4 changes: 2 additions & 2 deletions polly/include/polly/JSONExporter.h
Expand Up @@ -19,14 +19,14 @@ llvm::Pass *createJSONImporterPrinterLegacyPass(llvm::raw_ostream &OS);

/// This pass exports a scop to a jscop file. The filename is generated from the
/// concatenation of the function and scop name.
struct JSONExportPass : public llvm::PassInfoMixin<JSONExportPass> {
struct JSONExportPass final : llvm::PassInfoMixin<JSONExportPass> {
llvm::PreservedAnalyses run(Scop &, ScopAnalysisManager &,
ScopStandardAnalysisResults &, SPMUpdater &);
};

/// This pass imports a scop from a jscop file. The filename is deduced from the
/// concatenation of the function and scop name.
struct JSONImportPass : public llvm::PassInfoMixin<JSONExportPass> {
struct JSONImportPass final : llvm::PassInfoMixin<JSONExportPass> {
llvm::PreservedAnalyses run(Scop &, ScopAnalysisManager &,
ScopStandardAnalysisResults &, SPMUpdater &);
};
Expand Down
2 changes: 1 addition & 1 deletion polly/include/polly/ManualOptimizer.h
Expand Up @@ -21,7 +21,7 @@ class OptimizationRemarkEmitter;

namespace polly {
class Scop;
struct Dependences;
class Dependences;

/// Apply loop-transformation metadata.
///
Expand Down
2 changes: 1 addition & 1 deletion polly/include/polly/MatmulOptimizer.h
Expand Up @@ -16,7 +16,7 @@ class TargetTransformInfo;
}

namespace polly {
struct Dependences;
class Dependences;

/// Apply the BLIS matmul optimization pattern if possible.
///
Expand Down
2 changes: 1 addition & 1 deletion polly/include/polly/PolyhedralInfo.h
Expand Up @@ -31,7 +31,7 @@ class Scop;
class ScopInfo;
class DependenceInfoWrapperPass;

class PolyhedralInfo : public llvm::FunctionPass {
class PolyhedralInfo final : public llvm::FunctionPass {
public:
static char ID; // Pass identification, replacement for typeid

Expand Down
3 changes: 2 additions & 1 deletion polly/include/polly/PruneUnprofitable.h
Expand Up @@ -23,7 +23,8 @@ class PassRegistry;
namespace polly {
llvm::Pass *createPruneUnprofitableWrapperPass();

struct PruneUnprofitablePass : llvm::PassInfoMixin<PruneUnprofitablePass> {
struct PruneUnprofitablePass final
: llvm::PassInfoMixin<PruneUnprofitablePass> {
PruneUnprofitablePass() {}

llvm::PreservedAnalyses run(Scop &S, ScopAnalysisManager &SAM,
Expand Down
4 changes: 2 additions & 2 deletions polly/include/polly/ScheduleOptimizer.h
Expand Up @@ -20,15 +20,15 @@ namespace polly {
llvm::Pass *createIslScheduleOptimizerWrapperPass();
llvm::Pass *createIslScheduleOptimizerPrinterLegacyPass(llvm::raw_ostream &OS);

struct IslScheduleOptimizerPass
struct IslScheduleOptimizerPass final
: llvm::PassInfoMixin<IslScheduleOptimizerPass> {
IslScheduleOptimizerPass() {}

llvm::PreservedAnalyses run(Scop &S, ScopAnalysisManager &SAM,
ScopStandardAnalysisResults &SAR, SPMUpdater &U);
};

struct IslScheduleOptimizerPrinterPass
struct IslScheduleOptimizerPrinterPass final
: llvm::PassInfoMixin<IslScheduleOptimizerPrinterPass> {
IslScheduleOptimizerPrinterPass(raw_ostream &OS) : OS(OS) {}

Expand Down
2 changes: 1 addition & 1 deletion polly/include/polly/ScheduleTreeTransform.h
Expand Up @@ -126,7 +126,7 @@ struct ScheduleTreeVisitor {
/// Recursively visit all nodes of a schedule tree.
template <typename Derived, typename RetTy = void, typename... Args>
struct RecursiveScheduleTreeVisitor
: public ScheduleTreeVisitor<Derived, RetTy, Args...> {
: ScheduleTreeVisitor<Derived, RetTy, Args...> {
using BaseTy = ScheduleTreeVisitor<Derived, RetTy, Args...>;
BaseTy &getBase() { return *this; }
const BaseTy &getBase() const { return *this; }
Expand Down
2 changes: 1 addition & 1 deletion polly/include/polly/ScopBuilder.h
Expand Up @@ -30,7 +30,7 @@ class ScopDetection;
extern bool ModelReadOnlyScalars;

/// Build the Polly IR (Scop and ScopStmt) on a Region.
class ScopBuilder {
class ScopBuilder final {

/// The AAResults to build AliasSetTracker.
AAResults &AA;
Expand Down
13 changes: 7 additions & 6 deletions polly/include/polly/ScopDetection.h
Expand Up @@ -627,7 +627,7 @@ class ScopDetection {
OptimizationRemarkEmitter &ORE;
};

struct ScopAnalysis : public AnalysisInfoMixin<ScopAnalysis> {
struct ScopAnalysis : AnalysisInfoMixin<ScopAnalysis> {
static AnalysisKey Key;

using Result = ScopDetection;
Expand All @@ -637,27 +637,28 @@ struct ScopAnalysis : public AnalysisInfoMixin<ScopAnalysis> {
Result run(Function &F, FunctionAnalysisManager &FAM);
};

struct ScopAnalysisPrinterPass : public PassInfoMixin<ScopAnalysisPrinterPass> {
struct ScopAnalysisPrinterPass final : PassInfoMixin<ScopAnalysisPrinterPass> {
ScopAnalysisPrinterPass(raw_ostream &OS) : OS(OS) {}

PreservedAnalyses run(Function &F, FunctionAnalysisManager &FAM);

raw_ostream &OS;
};

struct ScopDetectionWrapperPass : public FunctionPass {
static char ID;
class ScopDetectionWrapperPass final : public FunctionPass {
std::unique_ptr<ScopDetection> Result;

public:
ScopDetectionWrapperPass();

/// @name FunctionPass interface
//@{
///@{
static char ID;
void getAnalysisUsage(AnalysisUsage &AU) const override;
void releaseMemory() override;
bool runOnFunction(Function &F) override;
void print(raw_ostream &OS, const Module *M = nullptr) const override;
//@}
///@}

ScopDetection &getSD() const { return *Result; }
};
Expand Down

0 comments on commit bd93df9

Please sign in to comment.