[PM] Introduce CRTP mixin base classes to help define passes and

analyses in the new pass manager.

These just handle really basic stuff: turning a type name into a string
statically that is nice to print in logs, and getting a static unique ID
for each analysis.

Sadly, the format of passes in anonymous namespaces makes using their
names in tests really annoying so I've customized the names of the no-op
passes to keep tests sane to read.

This is the first of a few simplifying refactorings for the new pass
manager that should reduce boilerplate and confusion.

llvm-svn: 262004
This commit is contained in:
Chandler Carruth 2016-02-26 11:44:45 +00:00
parent 6456376fe9
commit 3a63435551
59 changed files with 123 additions and 454 deletions

View File

@ -979,16 +979,10 @@ bool isIdentifiedFunctionLocal(const Value *V);
/// This manager effectively wraps the AnalysisManager for registering alias
/// analyses. When you register your alias analysis with this manager, it will
/// ensure the analysis itself is registered with its AnalysisManager.
class AAManager {
class AAManager : public AnalysisBase<AAManager> {
public:
typedef AAResults Result;
/// \brief Opaque, unique identifier for this analysis pass.
static void *ID() { return (void *)&PassID; }
/// \brief Provide access to a name for this pass.
static StringRef name() { return "AAManager"; }
// This type hase value semantics. We have to spell these out because MSVC
// won't synthesize them.
AAManager() {}
@ -1018,8 +1012,6 @@ public:
}
private:
static char PassID;
SmallVector<void (*)(Function &F, AnalysisManager<Function> &AM,
AAResults &AAResults),
4> FunctionResultGetters;

View File

@ -26,7 +26,7 @@
namespace llvm {
class AAResults;
class AAEvaluator {
class AAEvaluator : public PassBase<AAEvaluator> {
int64_t FunctionCount;
int64_t NoAliasCount, MayAliasCount, PartialAliasCount, MustAliasCount;
int64_t NoModRefCount, ModCount, RefCount, ModRefCount;

View File

@ -93,18 +93,9 @@ public:
///
/// This analysis is intended for use with the new pass manager and will vend
/// assumption caches for a given function.
class AssumptionAnalysis {
static char PassID;
public:
struct AssumptionAnalysis : AnalysisBase<AssumptionAnalysis> {
typedef AssumptionCache Result;
/// \brief Opaque, unique identifier for this analysis pass.
static void *ID() { return (void *)&PassID; }
/// \brief Provide a name for the analysis for debugging and logging.
static StringRef name() { return "AssumptionAnalysis"; }
AssumptionAnalysis() {}
AssumptionAnalysis(const AssumptionAnalysis &Arg) {}
AssumptionAnalysis(AssumptionAnalysis &&Arg) {}
@ -115,7 +106,7 @@ public:
};
/// \brief Printer pass for the \c AssumptionAnalysis results.
class AssumptionPrinterPass {
class AssumptionPrinterPass : public PassBase<AssumptionPrinterPass> {
raw_ostream &OS;
public:

View File

@ -178,20 +178,10 @@ private:
};
/// Analysis pass providing a never-invalidated alias analysis result.
class BasicAA {
public:
struct BasicAA : AnalysisBase<BasicAA> {
typedef BasicAAResult Result;
/// \brief Opaque, unique identifier for this analysis pass.
static void *ID() { return (void *)&PassID; }
/// \brief Provide access to a name for this pass for debugging purposes.
static StringRef name() { return "BasicAA"; }
BasicAAResult run(Function &F, AnalysisManager<Function> *AM);
private:
static char PassID;
};
/// Legacy wrapper pass to provide the BasicAAResult object.

View File

@ -109,20 +109,10 @@ private:
///
/// FIXME: We really should refactor CFL to use the analysis more heavily, and
/// in particular to leverage invalidation to trigger re-computation of sets.
class CFLAA {
public:
struct CFLAA : AnalysisBase<CFLAA> {
typedef CFLAAResult Result;
/// \brief Opaque, unique identifier for this analysis pass.
static void *ID() { return (void *)&PassID; }
CFLAAResult run(Function &F, AnalysisManager<Function> *AM);
/// \brief Provide access to a name for this pass for debugging purposes.
static StringRef name() { return "CFLAA"; }
private:
static char PassID;
};
/// Legacy wrapper pass to provide the CFLAAResult object.

View File

@ -52,7 +52,8 @@ typedef AnalysisManager<LazyCallGraph::SCC> CGSCCAnalysisManager;
///
/// Note that the proxy's result is a move-only object and represents ownership
/// of the validity of the analyses in the \c CGSCCAnalysisManager it provides.
class CGSCCAnalysisManagerModuleProxy {
class CGSCCAnalysisManagerModuleProxy
: public AnalysisBase<CGSCCAnalysisManagerModuleProxy> {
public:
class Result {
public:
@ -92,10 +93,6 @@ public:
CGSCCAnalysisManager *CGAM;
};
static void *ID() { return (void *)&PassID; }
static StringRef name() { return "CGSCCAnalysisManagerModuleProxy"; }
explicit CGSCCAnalysisManagerModuleProxy(CGSCCAnalysisManager &CGAM)
: CGAM(&CGAM) {}
// We have to explicitly define all the special member functions because MSVC
@ -122,8 +119,6 @@ public:
Result run(Module &M);
private:
static char PassID;
CGSCCAnalysisManager *CGAM;
};
@ -139,7 +134,8 @@ private:
/// This proxy *doesn't* manage the invalidation in any way. That is handled by
/// the recursive return path of each layer of the pass manager and the
/// returned PreservedAnalysis set.
class ModuleAnalysisManagerCGSCCProxy {
class ModuleAnalysisManagerCGSCCProxy
: public AnalysisBase<ModuleAnalysisManagerCGSCCProxy> {
public:
/// \brief Result proxy object for \c ModuleAnalysisManagerCGSCCProxy.
class Result {
@ -163,10 +159,6 @@ public:
const ModuleAnalysisManager *MAM;
};
static void *ID() { return (void *)&PassID; }
static StringRef name() { return "ModuleAnalysisManagerCGSCCProxy"; }
ModuleAnalysisManagerCGSCCProxy(const ModuleAnalysisManager &MAM)
: MAM(&MAM) {}
// We have to explicitly define all the special member functions because MSVC
@ -187,8 +179,6 @@ public:
Result run(LazyCallGraph::SCC &) { return Result(*MAM); }
private:
static char PassID;
const ModuleAnalysisManager *MAM;
};
@ -201,7 +191,9 @@ private:
/// \c CGSCCAnalysisManagerModuleProxy analysis prior to running the CGSCC
/// pass over the module to enable a \c FunctionAnalysisManager to be used
/// within this run safely.
template <typename CGSCCPassT> class ModuleToPostOrderCGSCCPassAdaptor {
template <typename CGSCCPassT>
class ModuleToPostOrderCGSCCPassAdaptor
: public PassBase<ModuleToPostOrderCGSCCPassAdaptor<CGSCCPassT>> {
public:
explicit ModuleToPostOrderCGSCCPassAdaptor(CGSCCPassT Pass)
: Pass(std::move(Pass)) {}
@ -262,8 +254,6 @@ public:
return PA;
}
static StringRef name() { return "ModuleToPostOrderCGSCCPassAdaptor"; }
private:
CGSCCPassT Pass;
};
@ -288,7 +278,8 @@ createModuleToPostOrderCGSCCPassAdaptor(CGSCCPassT Pass) {
/// Note that the proxy's result is a move-only object and represents ownership
/// of the validity of the analyses in the \c FunctionAnalysisManager it
/// provides.
class FunctionAnalysisManagerCGSCCProxy {
class FunctionAnalysisManagerCGSCCProxy
: public AnalysisBase<FunctionAnalysisManagerCGSCCProxy> {
public:
class Result {
public:
@ -328,10 +319,6 @@ public:
FunctionAnalysisManager *FAM;
};
static void *ID() { return (void *)&PassID; }
static StringRef name() { return "FunctionAnalysisManagerCGSCCProxy"; }
explicit FunctionAnalysisManagerCGSCCProxy(FunctionAnalysisManager &FAM)
: FAM(&FAM) {}
// We have to explicitly define all the special member functions because MSVC
@ -359,8 +346,6 @@ public:
Result run(LazyCallGraph::SCC &C);
private:
static char PassID;
FunctionAnalysisManager *FAM;
};
@ -376,7 +361,8 @@ private:
/// This proxy *doesn't* manage the invalidation in any way. That is handled by
/// the recursive return path of each layer of the pass manager and the
/// returned PreservedAnalysis set.
class CGSCCAnalysisManagerFunctionProxy {
class CGSCCAnalysisManagerFunctionProxy
: public AnalysisBase<CGSCCAnalysisManagerFunctionProxy> {
public:
/// \brief Result proxy object for \c CGSCCAnalysisManagerFunctionProxy.
class Result {
@ -400,10 +386,6 @@ public:
const CGSCCAnalysisManager *CGAM;
};
static void *ID() { return (void *)&PassID; }
static StringRef name() { return "CGSCCAnalysisManagerFunctionProxy"; }
CGSCCAnalysisManagerFunctionProxy(const CGSCCAnalysisManager &CGAM)
: CGAM(&CGAM) {}
// We have to explicitly define all the special member functions because MSVC
@ -425,8 +407,6 @@ public:
Result run(Function &) { return Result(*CGAM); }
private:
static char PassID;
const CGSCCAnalysisManager *CGAM;
};
@ -438,7 +418,9 @@ private:
/// \c FunctionAnalysisManagerCGSCCProxy analysis prior to running the function
/// pass over the SCC to enable a \c FunctionAnalysisManager to be used
/// within this run safely.
template <typename FunctionPassT> class CGSCCToFunctionPassAdaptor {
template <typename FunctionPassT>
class CGSCCToFunctionPassAdaptor
: public PassBase<CGSCCToFunctionPassAdaptor<FunctionPassT>> {
public:
explicit CGSCCToFunctionPassAdaptor(FunctionPassT Pass)
: Pass(std::move(Pass)) {}
@ -492,8 +474,6 @@ public:
return PA;
}
static StringRef name() { return "CGSCCToFunctionPassAdaptor"; }
private:
FunctionPassT Pass;
};

View File

@ -57,6 +57,7 @@
#include "llvm/IR/CallSite.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/Intrinsics.h"
#include "llvm/IR/PassManager.h"
#include "llvm/IR/ValueHandle.h"
#include "llvm/Pass.h"
#include <map>
@ -294,20 +295,15 @@ private:
/// This class implements the concept of an analysis pass used by the \c
/// ModuleAnalysisManager to run an analysis over a module and cache the
/// resulting data.
class CallGraphAnalysis {
struct CallGraphAnalysis : AnalysisBase<CallGraphAnalysis> {
public:
/// \brief A formulaic typedef to inform clients of the result type.
typedef CallGraph Result;
static void *ID() { return (void *)&PassID; }
/// \brief Compute the \c CallGraph for the module \c M.
///
/// The real work here is done in the \c CallGraph constructor.
CallGraph run(Module *M) { return CallGraph(*M); }
private:
static char PassID;
};
/// \brief The \c ModulePass which wraps up a \c CallGraph and the logic to

View File

@ -168,33 +168,22 @@ extern template class DominanceFrontierBase<BasicBlock>;
extern template class ForwardDominanceFrontierBase<BasicBlock>;
/// \brief Analysis pass which computes a \c DominanceFrontier.
class DominanceFrontierAnalysis {
public:
struct DominanceFrontierAnalysis : AnalysisBase<DominanceFrontierAnalysis> {
/// \brief Provide the result typedef for this analysis pass.
typedef DominanceFrontier Result;
/// \brief Opaque, unique identifier for this analysis pass.
static void *ID() { return (void *)&PassID; }
/// \brief Run the analysis pass over a function and produce a dominator tree.
DominanceFrontier run(Function &F, AnalysisManager<Function> *AM);
/// \brief Provide access to a name for this pass for debugging purposes.
static StringRef name() { return "DominanceFrontierAnalysis"; }
private:
static char PassID;
};
/// \brief Printer pass for the \c DominanceFrontier.
class DominanceFrontierPrinterPass {
class DominanceFrontierPrinterPass
: public PassBase<DominanceFrontierPrinterPass> {
raw_ostream &OS;
public:
explicit DominanceFrontierPrinterPass(raw_ostream &OS);
PreservedAnalyses run(Function &F, AnalysisManager<Function> *AM);
static StringRef name() { return "DominanceFrontierAnalysis"; }
};
} // End llvm namespace

View File

@ -116,20 +116,10 @@ private:
};
/// Analysis pass providing a never-invalidated alias analysis result.
class GlobalsAA {
public:
struct GlobalsAA : AnalysisBase<GlobalsAA> {
typedef GlobalsAAResult Result;
/// \brief Opaque, unique identifier for this analysis pass.
static void *ID() { return (void *)&PassID; }
GlobalsAAResult run(Module &M, AnalysisManager<Module> *AM);
/// \brief Provide access to a name for this pass for debugging purposes.
static StringRef name() { return "GlobalsAA"; }
private:
static char PassID;
};
/// Legacy wrapper pass to provide the GlobalsAAResult object.

View File

@ -895,37 +895,27 @@ template <> struct GraphTraits<LazyCallGraph *> {
};
/// An analysis pass which computes the call graph for a module.
class LazyCallGraphAnalysis {
public:
struct LazyCallGraphAnalysis : AnalysisBase<LazyCallGraphAnalysis> {
/// Inform generic clients of the result type.
typedef LazyCallGraph Result;
static void *ID() { return (void *)&PassID; }
static StringRef name() { return "Lazy CallGraph Analysis"; }
/// Compute the \c LazyCallGraph for the module \c M.
///
/// This just builds the set of entry points to the call graph. The rest is
/// built lazily as it is walked.
LazyCallGraph run(Module &M) { return LazyCallGraph(M); }
private:
static char PassID;
};
/// A pass which prints the call graph to a \c raw_ostream.
///
/// This is primarily useful for testing the analysis.
class LazyCallGraphPrinterPass {
class LazyCallGraphPrinterPass : public PassBase<LazyCallGraphPrinterPass> {
raw_ostream &OS;
public:
explicit LazyCallGraphPrinterPass(raw_ostream &OS);
PreservedAnalyses run(Module &M, ModuleAnalysisManager *AM);
static StringRef name() { return "LazyCallGraphPrinterPass"; }
};
}

View File

@ -787,30 +787,19 @@ template <> struct GraphTraits<Loop*> {
};
/// \brief Analysis pass that exposes the \c LoopInfo for a function.
class LoopAnalysis {
static char PassID;
public:
struct LoopAnalysis : AnalysisBase<LoopAnalysis> {
typedef LoopInfo Result;
/// \brief Opaque, unique identifier for this analysis pass.
static void *ID() { return (void *)&PassID; }
/// \brief Provide a name for the analysis for debugging and logging.
static StringRef name() { return "LoopAnalysis"; }
LoopInfo run(Function &F, AnalysisManager<Function> *AM);
};
/// \brief Printer pass for the \c LoopAnalysis results.
class LoopPrinterPass {
class LoopPrinterPass : public PassBase<LoopPrinterPass> {
raw_ostream &OS;
public:
explicit LoopPrinterPass(raw_ostream &OS) : OS(OS) {}
PreservedAnalyses run(Function &F, AnalysisManager<Function> *AM);
static StringRef name() { return "LoopPrinterPass"; }
};
/// \brief The legacy pass manager's analysis pass to compute loop information.
@ -840,7 +829,7 @@ public:
};
/// \brief Pass for printing a loop's contents as LLVM's text IR assembly.
class PrintLoopPass {
class PrintLoopPass : public PassBase<PrintLoopPass> {
raw_ostream &OS;
std::string Banner;
@ -849,7 +838,6 @@ public:
PrintLoopPass(raw_ostream &OS, const std::string &Banner = "");
PreservedAnalyses run(Loop &L);
static StringRef name() { return "PrintLoopPass"; }
};
} // End llvm namespace

View File

@ -44,7 +44,8 @@ typedef AnalysisManager<Loop> LoopAnalysisManager;
/// never use a loop analysis manager from within (transitively) a function
/// pass manager unless your parent function pass has received a proxy result
/// object for it.
class LoopAnalysisManagerFunctionProxy {
class LoopAnalysisManagerFunctionProxy
: public AnalysisBase<LoopAnalysisManagerFunctionProxy> {
public:
class Result {
public:
@ -77,10 +78,6 @@ public:
LoopAnalysisManager *LAM;
};
static void *ID() { return (void *)&PassID; }
static StringRef name() { return "LoopAnalysisManagerFunctionProxy"; }
explicit LoopAnalysisManagerFunctionProxy(LoopAnalysisManager &LAM)
: LAM(&LAM) {}
// We have to explicitly define all the special member functions because MSVC
@ -107,8 +104,6 @@ public:
Result run(Function &F);
private:
static char PassID;
LoopAnalysisManager *LAM;
};
@ -124,7 +119,8 @@ private:
/// This proxy *doesn't* manage the invalidation in any way. That is handled by
/// the recursive return path of each layer of the pass manager and the
/// returned PreservedAnalysis set.
class FunctionAnalysisManagerLoopProxy {
class FunctionAnalysisManagerLoopProxy
: public AnalysisBase<FunctionAnalysisManagerLoopProxy> {
public:
/// \brief Result proxy object for \c FunctionAnalysisManagerLoopProxy.
class Result {
@ -148,10 +144,6 @@ public:
const FunctionAnalysisManager *FAM;
};
static void *ID() { return (void *)&PassID; }
static StringRef name() { return "FunctionAnalysisManagerLoopProxy"; }
FunctionAnalysisManagerLoopProxy(const FunctionAnalysisManager &FAM)
: FAM(&FAM) {}
// We have to explicitly define all the special member functions because MSVC
@ -172,8 +164,6 @@ public:
Result run(Loop &) { return Result(*FAM); }
private:
static char PassID;
const FunctionAnalysisManager *FAM;
};
@ -184,7 +174,9 @@ private:
/// FunctionAnalysisManager it will run the \c LoopAnalysisManagerFunctionProxy
/// analysis prior to running the loop passes over the function to enable a \c
/// LoopAnalysisManager to be used within this run safely.
template <typename LoopPassT> class FunctionToLoopPassAdaptor {
template <typename LoopPassT>
class FunctionToLoopPassAdaptor
: public PassBase<FunctionToLoopPassAdaptor<LoopPassT>> {
public:
explicit FunctionToLoopPassAdaptor(LoopPassT Pass)
: Pass(std::move(Pass)) {}
@ -250,8 +242,6 @@ public:
return PA;
}
static StringRef name() { return "FunctionToLoopPassAdaptor"; }
private:
LoopPassT Pass;
};

View File

@ -63,20 +63,10 @@ public:
};
/// Analysis pass providing a never-invalidated alias analysis result.
class ObjCARCAA {
public:
struct ObjCARCAA : AnalysisBase<ObjCARCAA> {
typedef ObjCARCAAResult Result;
/// \brief Opaque, unique identifier for this analysis pass.
static void *ID() { return (void *)&PassID; }
ObjCARCAAResult run(Function &F, AnalysisManager<Function> *AM);
/// \brief Provide access to a name for this pass for debugging purposes.
static StringRef name() { return "ObjCARCAA"; }
private:
static char PassID;
};
/// Legacy wrapper pass to provide the ObjCARCAAResult object.

View File

@ -37,34 +37,23 @@ struct PostDominatorTree : public DominatorTreeBase<BasicBlock> {
};
/// \brief Analysis pass which computes a \c PostDominatorTree.
class PostDominatorTreeAnalysis {
public:
struct PostDominatorTreeAnalysis : AnalysisBase<PostDominatorTreeAnalysis> {
/// \brief Provide the result typedef for this analysis pass.
typedef PostDominatorTree Result;
/// \brief Opaque, unique identifier for this analysis pass.
static void *ID() { return (void *)&PassID; }
/// \brief Run the analysis pass over a function and produce a post dominator
/// tree.
PostDominatorTree run(Function &F);
/// \brief Provide access to a name for this pass for debugging purposes.
static StringRef name() { return "PostDominatorTreeAnalysis"; }
private:
static char PassID;
};
/// \brief Printer pass for the \c PostDominatorTree.
class PostDominatorTreePrinterPass {
class PostDominatorTreePrinterPass
: public PassBase<PostDominatorTreePrinterPass> {
raw_ostream &OS;
public:
explicit PostDominatorTreePrinterPass(raw_ostream &OS);
PreservedAnalyses run(Function &F, AnalysisManager<Function> *AM);
static StringRef name() { return "PostDominatorTreePrinterPass"; }
};
struct PostDominatorTreeWrapperPass : public FunctionPass {

View File

@ -923,37 +923,24 @@ public:
};
/// \brief Analysis pass that exposes the \c RegionInfo for a function.
class RegionInfoAnalysis {
static char PassID;
public:
struct RegionInfoAnalysis : AnalysisBase<RegionInfoAnalysis> {
typedef RegionInfo Result;
/// \brief Opaque, unique identifier for this analysis pass.
static void *ID() { return (void *)&PassID; }
/// \brief Provide a name for the analysis for debugging and logging.
static StringRef name() { return "RegionInfoAnalysis"; }
RegionInfo run(Function &F, AnalysisManager<Function> *AM);
};
/// \brief Printer pass for the \c RegionInfo.
class RegionInfoPrinterPass {
class RegionInfoPrinterPass : public PassBase<RegionInfoPrinterPass> {
raw_ostream &OS;
public:
explicit RegionInfoPrinterPass(raw_ostream &OS);
PreservedAnalyses run(Function &F, AnalysisManager<Function> *AM);
static StringRef name() { return "RegionInfoPrinterPass"; }
};
/// \brief Verifier pass for the \c RegionInfo.
struct RegionInfoVerifierPass {
struct RegionInfoVerifierPass : PassBase<RegionInfoVerifierPass> {
PreservedAnalyses run(Function &F, AnalysisManager<Function> *AM);
static StringRef name() { return "RegionInfoVerifierPass"; }
};
template <>

View File

@ -1415,30 +1415,20 @@ namespace llvm {
};
/// \brief Analysis pass that exposes the \c ScalarEvolution for a function.
class ScalarEvolutionAnalysis {
static char PassID;
public:
struct ScalarEvolutionAnalysis : AnalysisBase<ScalarEvolutionAnalysis> {
typedef ScalarEvolution Result;
/// \brief Opaque, unique identifier for this analysis pass.
static void *ID() { return (void *)&PassID; }
/// \brief Provide a name for the analysis for debugging and logging.
static StringRef name() { return "ScalarEvolutionAnalysis"; }
ScalarEvolution run(Function &F, AnalysisManager<Function> *AM);
};
/// \brief Printer pass for the \c ScalarEvolutionAnalysis results.
class ScalarEvolutionPrinterPass {
class ScalarEvolutionPrinterPass
: public PassBase<ScalarEvolutionPrinterPass> {
raw_ostream &OS;
public:
explicit ScalarEvolutionPrinterPass(raw_ostream &OS) : OS(OS) {}
PreservedAnalyses run(Function &F, AnalysisManager<Function> *AM);
static StringRef name() { return "ScalarEvolutionPrinterPass"; }
};
class ScalarEvolutionWrapperPass : public FunctionPass {

View File

@ -39,20 +39,10 @@ private:
};
/// Analysis pass providing a never-invalidated alias analysis result.
class SCEVAA {
public:
struct SCEVAA : AnalysisBase<SCEVAA> {
typedef SCEVAAResult Result;
/// \brief Opaque, unique identifier for this analysis pass.
static void *ID() { return (void *)&PassID; }
SCEVAAResult run(Function &F, AnalysisManager<Function> *AM);
/// \brief Provide access to a name for this pass for debugging purposes.
static StringRef name() { return "SCEVAA"; }
private:
static char PassID;
};
/// Legacy wrapper pass to provide the SCEVAAResult object.

View File

@ -48,20 +48,10 @@ private:
};
/// Analysis pass providing a never-invalidated alias analysis result.
class ScopedNoAliasAA {
public:
struct ScopedNoAliasAA : AnalysisBase<ScopedNoAliasAA> {
typedef ScopedNoAliasAAResult Result;
/// \brief Opaque, unique identifier for this analysis pass.
static void *ID() { return (void *)&PassID; }
ScopedNoAliasAAResult run(Function &F, AnalysisManager<Function> *AM);
/// \brief Provide access to a name for this pass for debugging purposes.
static StringRef name() { return "ScopedNoAliasAA"; }
private:
static char PassID;
};
/// Legacy wrapper pass to provide the ScopedNoAliasAAResult object.

View File

@ -16,6 +16,7 @@
#include "llvm/ADT/Triple.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/Module.h"
#include "llvm/IR/PassManager.h"
#include "llvm/Pass.h"
namespace llvm {
@ -27,7 +28,6 @@ struct VecDesc {
const char *VectorFnName;
unsigned VectorizationFactor;
};
class PreservedAnalyses;
namespace LibFunc {
enum Func {
@ -262,13 +262,10 @@ public:
///
/// Note that this pass's result cannot be invalidated, it is immutable for the
/// life of the module.
class TargetLibraryAnalysis {
class TargetLibraryAnalysis : public AnalysisBase<TargetLibraryAnalysis> {
public:
typedef TargetLibraryInfo Result;
/// \brief Opaque, unique identifier for this analysis pass.
static void *ID() { return (void *)&PassID; }
/// \brief Default construct the library analysis.
///
/// This will use the module's triple to construct the library info for that
@ -294,12 +291,7 @@ public:
TargetLibraryInfo run(Module &M);
TargetLibraryInfo run(Function &F);
/// \brief Provide access to a name for this pass for debugging purposes.
static StringRef name() { return "TargetLibraryAnalysis"; }
private:
static char PassID;
Optional<TargetLibraryInfoImpl> PresetInfoImpl;
StringMap<std::unique_ptr<TargetLibraryInfoImpl>> Impls;

View File

@ -25,6 +25,7 @@
#include "llvm/ADT/Optional.h"
#include "llvm/IR/IntrinsicInst.h"
#include "llvm/IR/Intrinsics.h"
#include "llvm/IR/PassManager.h"
#include "llvm/Pass.h"
#include "llvm/Support/DataTypes.h"
#include <functional>
@ -34,7 +35,6 @@ namespace llvm {
class Function;
class GlobalValue;
class Loop;
class PreservedAnalyses;
class Type;
class User;
class Value;
@ -889,16 +889,10 @@ TargetTransformInfo::TargetTransformInfo(T Impl)
/// is done in a subtarget specific way and LLVM supports compiling different
/// functions targeting different subtargets in order to support runtime
/// dispatch according to the observed subtarget.
class TargetIRAnalysis {
class TargetIRAnalysis : public AnalysisBase<TargetIRAnalysis> {
public:
typedef TargetTransformInfo Result;
/// \brief Opaque, unique identifier for this analysis pass.
static void *ID() { return (void *)&PassID; }
/// \brief Provide access to a name for this pass for debugging purposes.
static StringRef name() { return "TargetIRAnalysis"; }
/// \brief Default construct a target IR analysis.
///
/// This will use the module's datalayout to construct a baseline
@ -928,8 +922,6 @@ public:
Result run(const Function &F);
private:
static char PassID;
/// \brief The callback used to produce a result.
///
/// We use a completely opaque callback so that targets can provide whatever

View File

@ -49,20 +49,10 @@ private:
};
/// Analysis pass providing a never-invalidated alias analysis result.
class TypeBasedAA {
public:
struct TypeBasedAA : AnalysisBase<TypeBasedAA> {
typedef TypeBasedAAResult Result;
/// \brief Opaque, unique identifier for this analysis pass.
static void *ID() { return (void *)&PassID; }
TypeBasedAAResult run(Function &F, AnalysisManager<Function> *AM);
/// \brief Provide access to a name for this pass for debugging purposes.
static StringRef name() { return "TypeBasedAA"; }
private:
static char PassID;
};
/// Legacy wrapper pass to provide the TypeBasedAAResult object.

View File

@ -182,40 +182,26 @@ template <> struct GraphTraits<DominatorTree*>
};
/// \brief Analysis pass which computes a \c DominatorTree.
class DominatorTreeAnalysis {
public:
struct DominatorTreeAnalysis : AnalysisBase<DominatorTreeAnalysis> {
/// \brief Provide the result typedef for this analysis pass.
typedef DominatorTree Result;
/// \brief Opaque, unique identifier for this analysis pass.
static void *ID() { return (void *)&PassID; }
/// \brief Run the analysis pass over a function and produce a dominator tree.
DominatorTree run(Function &F);
/// \brief Provide access to a name for this pass for debugging purposes.
static StringRef name() { return "DominatorTreeAnalysis"; }
private:
static char PassID;
};
/// \brief Printer pass for the \c DominatorTree.
class DominatorTreePrinterPass {
class DominatorTreePrinterPass : public PassBase<DominatorTreePrinterPass> {
raw_ostream &OS;
public:
explicit DominatorTreePrinterPass(raw_ostream &OS);
PreservedAnalyses run(Function &F, AnalysisManager<Function> *AM);
static StringRef name() { return "DominatorTreePrinterPass"; }
};
/// \brief Verifier pass for the \c DominatorTree.
struct DominatorTreeVerifierPass {
struct DominatorTreeVerifierPass : PassBase<DominatorTreeVerifierPass> {
PreservedAnalyses run(Function &F, AnalysisManager<Function> *AM);
static StringRef name() { return "DominatorTreeVerifierPass"; }
};
/// \brief Legacy analysis pass which computes a \c DominatorTree.

View File

@ -167,6 +167,33 @@ private:
// Forward declare the analysis manager template.
template <typename IRUnitT> class AnalysisManager;
/// A CRTP mix-in base class to help define types that are valid passes.
///
/// This provides some boiler plate for types that are passes.
template <typename DerivedT> struct PassBase {
/// Returns the name of the derived pass type.
static StringRef name() {
StringRef Name = getTypeName<DerivedT>();
if (Name.startswith("llvm::"))
Name = Name.drop_front(strlen("llvm::"));
return Name;
}
};
/// A CRTP mix-in base class to help define types that are valid analyses.
///
/// This provides some boiler plate for types that are analysis passes.
template <typename DerivedT> class AnalysisBase : public PassBase<DerivedT> {
static char PassID;
public:
/// Returns an opaque, unique ID for this pass type.
static void *ID() { return (void *)&PassID; }
};
/// Private static data to provide unique ID.
template <typename DerivedT> char AnalysisBase<DerivedT>::PassID;
/// \brief Manages a sequence of passes over units of IR.
///
/// A pass manager contains a sequence of passes to run over units of IR. It is
@ -178,7 +205,8 @@ template <typename IRUnitT> class AnalysisManager;
/// that analysis manager to each pass it runs, as well as calling the analysis
/// manager's invalidation routine with the PreservedAnalyses of each pass it
/// runs.
template <typename IRUnitT> class PassManager {
template <typename IRUnitT>
class PassManager : public PassBase<PassManager<IRUnitT>> {
public:
/// \brief Construct a pass manager.
///
@ -623,14 +651,11 @@ typedef AnalysisManager<Function> FunctionAnalysisManager;
/// Note that the proxy's result is a move-only object and represents ownership
/// of the validity of the analyses in the \c FunctionAnalysisManager it
/// provides.
class FunctionAnalysisManagerModuleProxy {
class FunctionAnalysisManagerModuleProxy
: public AnalysisBase<FunctionAnalysisManagerModuleProxy> {
public:
class Result;
static void *ID() { return (void *)&PassID; }
static StringRef name() { return "FunctionAnalysisManagerModuleProxy"; }
explicit FunctionAnalysisManagerModuleProxy(FunctionAnalysisManager &FAM)
: FAM(&FAM) {}
// We have to explicitly define all the special member functions because MSVC
@ -658,8 +683,6 @@ public:
Result run(Module &M);
private:
static char PassID;
FunctionAnalysisManager *FAM;
};
@ -717,7 +740,8 @@ private:
/// This proxy *doesn't* manage the invalidation in any way. That is handled by
/// the recursive return path of each layer of the pass manager and the
/// returned PreservedAnalysis set.
class ModuleAnalysisManagerFunctionProxy {
class ModuleAnalysisManagerFunctionProxy
: public AnalysisBase<ModuleAnalysisManagerFunctionProxy> {
public:
/// \brief Result proxy object for \c ModuleAnalysisManagerFunctionProxy.
class Result {
@ -741,10 +765,6 @@ public:
const ModuleAnalysisManager *MAM;
};
static void *ID() { return (void *)&PassID; }
static StringRef name() { return "ModuleAnalysisManagerFunctionProxy"; }
ModuleAnalysisManagerFunctionProxy(const ModuleAnalysisManager &MAM)
: MAM(&MAM) {}
// We have to explicitly define all the special member functions because MSVC
@ -766,8 +786,6 @@ public:
Result run(Function &) { return Result(*MAM); }
private:
static char PassID;
const ModuleAnalysisManager *MAM;
};
@ -793,7 +811,9 @@ private:
/// module.
/// FIXME: Make the above true for all of LLVM's actual passes, some still
/// violate this principle.
template <typename FunctionPassT> class ModuleToFunctionPassAdaptor {
template <typename FunctionPassT>
class ModuleToFunctionPassAdaptor
: public PassBase<ModuleToFunctionPassAdaptor<FunctionPassT>> {
public:
explicit ModuleToFunctionPassAdaptor(FunctionPassT Pass)
: Pass(std::move(Pass)) {}
@ -848,8 +868,6 @@ public:
return PA;
}
static StringRef name() { return "ModuleToFunctionPassAdaptor"; }
private:
FunctionPassT Pass;
};
@ -866,7 +884,8 @@ createModuleToFunctionPassAdaptor(FunctionPassT Pass) {
///
/// This is a no-op pass which simply forces a specific analysis pass's result
/// to be available when it is run.
template <typename AnalysisT> struct RequireAnalysisPass {
template <typename AnalysisT>
struct RequireAnalysisPass : PassBase<RequireAnalysisPass<AnalysisT>> {
/// \brief Run this pass over some unit of IR.
///
/// This pass can be run over any unit of IR and use any analysis manager
@ -880,8 +899,6 @@ template <typename AnalysisT> struct RequireAnalysisPass {
return PreservedAnalyses::all();
}
static StringRef name() { return "RequireAnalysisPass"; }
};
/// \brief A template utility pass to force an analysis result to be
@ -889,7 +906,8 @@ template <typename AnalysisT> struct RequireAnalysisPass {
///
/// This is a no-op pass which simply forces a specific analysis result to be
/// invalidated when it is run.
template <typename AnalysisT> struct InvalidateAnalysisPass {
template <typename AnalysisT>
struct InvalidateAnalysisPass : PassBase<InvalidateAnalysisPass<AnalysisT>> {
/// \brief Run this pass over some unit of IR.
///
/// This pass can be run over any unit of IR and use any analysis manager
@ -905,21 +923,17 @@ template <typename AnalysisT> struct InvalidateAnalysisPass {
return PreservedAnalyses::all();
}
static StringRef name() { return "InvalidateAnalysisPass"; }
};
/// \brief A utility pass that does nothing but preserves no analyses.
///
/// As a consequence fo not preserving any analyses, this pass will force all
/// analysis passes to be re-run to produce fresh results if any are needed.
struct InvalidateAllAnalysesPass {
struct InvalidateAllAnalysesPass : PassBase<InvalidateAllAnalysesPass> {
/// \brief Run this pass over some unit of IR.
template <typename IRUnitT> PreservedAnalyses run(IRUnitT &Arg) {
return PreservedAnalyses::none();
}
static StringRef name() { return "InvalidateAllAnalysesPass"; }
};
}

View File

@ -22,6 +22,7 @@
#define LLVM_IR_VERIFIER_H
#include "llvm/ADT/StringRef.h"
#include "llvm/IR/PassManager.h"
#include <string>
namespace llvm {
@ -30,7 +31,6 @@ class Function;
class FunctionPass;
class ModulePass;
class Module;
class PreservedAnalyses;
class raw_ostream;
/// \brief Check a function for errors, useful for use when debugging a
@ -60,7 +60,7 @@ bool verifyModule(const Module &M, raw_ostream *OS = nullptr);
/// nothing to do with \c VerifierPass.
FunctionPass *createVerifierPass(bool FatalErrors = true);
class VerifierPass {
class VerifierPass : public PassBase<VerifierPass> {
bool FatalErrors;
public:
@ -68,8 +68,6 @@ public:
PreservedAnalyses run(Module &M);
PreservedAnalyses run(Function &F);
static StringRef name() { return "VerifierPass"; }
};
} // End llvm namespace

View File

@ -21,9 +21,7 @@ namespace llvm {
/// Pass which forces specific function attributes into the IR, primarily as
/// a debugging tool.
class ForceFunctionAttrsPass {
public:
static StringRef name() { return "ForceFunctionAttrsPass"; }
struct ForceFunctionAttrsPass : PassBase<ForceFunctionAttrsPass> {
PreservedAnalyses run(Module &M);
};

View File

@ -29,10 +29,7 @@ namespace llvm {
/// access memory, or only read memory, and give them the readnone/readonly
/// attribute. It also discovers function arguments that are not captured by
/// the function and marks them with the nocapture attribute.
class PostOrderFunctionAttrsPass {
public:
static StringRef name() { return "PostOrderFunctionAttrsPass"; }
struct PostOrderFunctionAttrsPass : PassBase<PostOrderFunctionAttrsPass> {
PreservedAnalyses run(LazyCallGraph::SCC &C, CGSCCAnalysisManager *AM);
};

View File

@ -23,9 +23,7 @@ namespace llvm {
/// A pass which infers function attributes from the names and signatures of
/// function declarations in a module.
class InferFunctionAttrsPass {
public:
static StringRef name() { return "InferFunctionAttrsPass"; }
struct InferFunctionAttrsPass : PassBase<InferFunctionAttrsPass> {
PreservedAnalyses run(Module &M, AnalysisManager<Module> *AM);
};

View File

@ -23,9 +23,7 @@
namespace llvm {
/// Pass to remove unused function declarations.
class StripDeadPrototypesPass {
public:
static StringRef name() { return "StripDeadPrototypesPass"; }
struct StripDeadPrototypesPass : PassBase<StripDeadPrototypesPass> {
PreservedAnalyses run(Module &M);
};

View File

@ -24,7 +24,7 @@
namespace llvm {
class InstCombinePass {
class InstCombinePass : public PassBase<InstCombinePass> {
InstCombineWorklist Worklist;
public:

View File

@ -28,9 +28,7 @@ namespace llvm {
/// instructions are dead until proven otherwise. This allows it to eliminate
/// dead computations that other DCE passes do not catch, particularly involving
/// loop computations.
class ADCEPass {
public:
static StringRef name() { return "ADCEPass"; }
struct ADCEPass : PassBase<ADCEPass> {
PreservedAnalyses run(Function &F);
};
}

View File

@ -26,10 +26,7 @@ namespace llvm {
/// canonicalize things as it goes. It is intended to be fast and catch obvious
/// cases so that instcombine and other passes are more effective. It is
/// expected that a later pass of GVN will catch the interesting/hard cases.
class EarlyCSEPass {
public:
static StringRef name() { return "EarlyCSEPass"; }
struct EarlyCSEPass : PassBase<EarlyCSEPass> {
/// \brief Run the pass over the function.
PreservedAnalyses run(Function &F, AnalysisManager<Function> *AM);
};

View File

@ -21,10 +21,7 @@
namespace llvm {
class LowerExpectIntrinsicPass {
public:
static StringRef name() { return "LowerExpectIntrinsicPass"; }
struct LowerExpectIntrinsicPass : PassBase<LowerExpectIntrinsicPass> {
/// \brief Run the pass over the function.
///
/// This will lower all of th expect intrinsic calls in this function into

View File

@ -51,7 +51,7 @@ class SROALegacyPass;
/// onto insert and extract operations on a vector value, and convert them to
/// this form. By doing so, it will enable promotion of vector aggregates to
/// SSA vector values.
class SROA {
class SROA : public PassBase<SROA> {
LLVMContext *C;
DominatorTree *DT;
AssumptionCache *AC;
@ -101,8 +101,6 @@ class SROA {
public:
SROA() : C(nullptr), DT(nullptr), AC(nullptr) {}
static StringRef name() { return "SROA"; }
/// \brief Run the pass over the function.
PreservedAnalyses run(Function &F, AnalysisManager<Function> *AM);

View File

@ -25,12 +25,10 @@ namespace llvm {
/// This pass iteratively simplifies the entire CFG of a function, removing
/// unnecessary control flows and bringing it into the canonical form expected
/// by the rest of the mid-level optimizer.
class SimplifyCFGPass {
class SimplifyCFGPass : public PassBase<SimplifyCFGPass> {
int BonusInstThreshold;
public:
static StringRef name() { return "SimplifyCFGPass"; }
/// \brief Construct a pass with the default thresholds.
SimplifyCFGPass();

View File

@ -390,9 +390,6 @@ bool AAResults::canInstructionRangeModRef(const Instruction &I1,
// Provide a definition for the root virtual destructor.
AAResults::Concept::~Concept() {}
// Provide a definition for the static object used to identify passes.
char AAManager::PassID;
namespace {
/// A wrapper pass for external alias analyses. This just squirrels away the
/// callback used to run any analyses and register their results.

View File

@ -74,8 +74,6 @@ void AssumptionCache::registerAssumption(CallInst *CI) {
#endif
}
char AssumptionAnalysis::PassID;
PreservedAnalyses AssumptionPrinterPass::run(Function &F,
AnalysisManager<Function> *AM) {
AssumptionCache &AC = AM->getResult<AssumptionAnalysis>(F);

View File

@ -1586,8 +1586,6 @@ bool BasicAAResult::constantOffsetHeuristic(
// BasicAliasAnalysis Pass
//===----------------------------------------------------------------------===//
char BasicAA::PassID;
BasicAAResult BasicAA::run(Function &F, AnalysisManager<Function> *AM) {
return BasicAAResult(F.getParent()->getDataLayout(),
AM->getResult<TargetLibraryAnalysis>(F),

View File

@ -1093,8 +1093,6 @@ CFLAAResult CFLAA::run(Function &F, AnalysisManager<Function> *AM) {
return CFLAAResult(AM->getResult<TargetLibraryAnalysis>(F));
}
char CFLAA::PassID;
char CFLAAWrapperPass::ID = 0;
INITIALIZE_PASS_BEGIN(CFLAAWrapperPass, "cfl-aa", "CFL-Based Alias Analysis",
false, true)

View File

@ -13,8 +13,6 @@
using namespace llvm;
char CGSCCAnalysisManagerModuleProxy::PassID;
CGSCCAnalysisManagerModuleProxy::Result
CGSCCAnalysisManagerModuleProxy::run(Module &M) {
assert(CGAM->empty() && "CGSCC analyses ran prior to the module proxy!");
@ -44,10 +42,6 @@ bool CGSCCAnalysisManagerModuleProxy::Result::invalidate(
return false;
}
char ModuleAnalysisManagerCGSCCProxy::PassID;
char FunctionAnalysisManagerCGSCCProxy::PassID;
FunctionAnalysisManagerCGSCCProxy::Result
FunctionAnalysisManagerCGSCCProxy::run(LazyCallGraph::SCC &C) {
return Result(*FAM);
@ -75,5 +69,3 @@ bool FunctionAnalysisManagerCGSCCProxy::Result::invalidate(
// Return false to indicate that this result is still a valid proxy.
return false;
}
char CGSCCAnalysisManagerFunctionProxy::PassID;

View File

@ -263,8 +263,6 @@ void CallGraphNode::replaceCallEdge(CallSite CS,
// Out-of-line definitions of CallGraphAnalysis class members.
//
char CallGraphAnalysis::PassID;
//===----------------------------------------------------------------------===//
// Implementations of the CallGraphWrapperPass class methods.
//

View File

@ -56,8 +56,6 @@ LLVM_DUMP_METHOD void DominanceFrontierWrapperPass::dump() const {
}
#endif
char DominanceFrontierAnalysis::PassID;
DominanceFrontier DominanceFrontierAnalysis::run(Function &F,
FunctionAnalysisManager *AM) {
DominanceFrontier DF;

View File

@ -940,8 +940,6 @@ GlobalsAAResult GlobalsAA::run(Module &M, AnalysisManager<Module> *AM) {
AM->getResult<CallGraphAnalysis>(M));
}
char GlobalsAA::PassID;
char GlobalsAAWrapperPass::ID = 0;
INITIALIZE_PASS_BEGIN(GlobalsAAWrapperPass, "globals-aa",
"Globals Alias Analysis", false, true)

View File

@ -1499,8 +1499,6 @@ LazyCallGraph::RefSCC *LazyCallGraph::getNextRefSCCInPostOrder() {
}
}
char LazyCallGraphAnalysis::PassID;
LazyCallGraphPrinterPass::LazyCallGraphPrinterPass(raw_ostream &OS) : OS(OS) {}
static void printNode(raw_ostream &OS, LazyCallGraph::Node &N) {

View File

@ -641,8 +641,6 @@ void LoopInfo::markAsRemoved(Loop *Unloop) {
}
}
char LoopAnalysis::PassID;
LoopInfo LoopAnalysis::run(Function &F, AnalysisManager<Function> *AM) {
// FIXME: Currently we create a LoopInfo from scratch for every function.
// This may prove to be too wasteful due to deallocating and re-allocating

View File

@ -11,8 +11,6 @@
using namespace llvm;
char LoopAnalysisManagerFunctionProxy::PassID;
LoopAnalysisManagerFunctionProxy::Result
LoopAnalysisManagerFunctionProxy::run(Function &F) {
// TODO: In FunctionAnalysisManagerModuleProxy we assert that the
@ -41,5 +39,3 @@ bool LoopAnalysisManagerFunctionProxy::Result::invalidate(
// Return false to indicate that this result is still a valid proxy.
return false;
}
char FunctionAnalysisManagerLoopProxy::PassID;

View File

@ -136,8 +136,6 @@ ObjCARCAAResult ObjCARCAA::run(Function &F, AnalysisManager<Function> *AM) {
AM->getResult<TargetLibraryAnalysis>(F));
}
char ObjCARCAA::PassID;
char ObjCARCAAWrapperPass::ID = 0;
INITIALIZE_PASS_BEGIN(ObjCARCAAWrapperPass, "objc-arc-aa",
"ObjC-ARC-Based Alias Analysis", false, true)

View File

@ -44,8 +44,6 @@ FunctionPass* llvm::createPostDomTree() {
return new PostDominatorTreeWrapperPass();
}
char PostDominatorTreeAnalysis::PassID;
PostDominatorTree PostDominatorTreeAnalysis::run(Function &F) {
PostDominatorTree PDT;
PDT.recalculate(F);

View File

@ -185,8 +185,6 @@ namespace llvm {
// RegionInfoAnalysis implementation
//
char RegionInfoAnalysis::PassID;
RegionInfo RegionInfoAnalysis::run(Function &F, AnalysisManager<Function> *AM) {
RegionInfo RI;
auto *DT = &AM->getResult<DominatorTreeAnalysis>(F);

View File

@ -9554,8 +9554,6 @@ void ScalarEvolution::verify() const {
// TODO: Verify more things.
}
char ScalarEvolutionAnalysis::PassID;
ScalarEvolution ScalarEvolutionAnalysis::run(Function &F,
AnalysisManager<Function> *AM) {
return ScalarEvolution(F, AM->getResult<TargetLibraryAnalysis>(F),

View File

@ -116,8 +116,6 @@ SCEVAAResult SCEVAA::run(Function &F, AnalysisManager<Function> *AM) {
AM->getResult<ScalarEvolutionAnalysis>(F));
}
char SCEVAA::PassID;
char SCEVAAWrapperPass::ID = 0;
INITIALIZE_PASS_BEGIN(SCEVAAWrapperPass, "scev-aa",
"ScalarEvolution-based Alias Analysis", false, true)

View File

@ -178,8 +178,6 @@ ScopedNoAliasAAResult ScopedNoAliasAA::run(Function &F,
return ScopedNoAliasAAResult(AM->getResult<TargetLibraryAnalysis>(F));
}
char ScopedNoAliasAA::PassID;
char ScopedNoAliasAAWrapperPass::ID = 0;
INITIALIZE_PASS_BEGIN(ScopedNoAliasAAWrapperPass, "scoped-noalias",
"Scoped NoAlias Alias Analysis", false, true)

View File

@ -636,8 +636,6 @@ TargetLibraryInfoWrapperPass::TargetLibraryInfoWrapperPass(
initializeTargetLibraryInfoWrapperPassPass(*PassRegistry::getPassRegistry());
}
char TargetLibraryAnalysis::PassID;
// Register the basic pass.
INITIALIZE_PASS(TargetLibraryInfoWrapperPass, "targetlibinfo",
"Target Library Information", false, true)

View File

@ -377,8 +377,6 @@ TargetIRAnalysis::Result TargetIRAnalysis::run(const Function &F) {
return TTICallback(F);
}
char TargetIRAnalysis::PassID;
TargetIRAnalysis::Result TargetIRAnalysis::getDefaultTTI(const Function &F) {
return Result(F.getParent()->getDataLayout());
}

View File

@ -588,8 +588,6 @@ TypeBasedAAResult TypeBasedAA::run(Function &F, AnalysisManager<Function> *AM) {
return TypeBasedAAResult(AM->getResult<TargetLibraryAnalysis>(F));
}
char TypeBasedAA::PassID;
char TypeBasedAAWrapperPass::ID = 0;
INITIALIZE_PASS_BEGIN(TypeBasedAAWrapperPass, "tbaa",
"Type-Based Alias Analysis", false, true)

View File

@ -308,8 +308,6 @@ DominatorTree DominatorTreeAnalysis::run(Function &F) {
return DT;
}
char DominatorTreeAnalysis::PassID;
DominatorTreePrinterPass::DominatorTreePrinterPass(raw_ostream &OS) : OS(OS) {}
PreservedAnalyses DominatorTreePrinterPass::run(Function &F,

View File

@ -13,8 +13,6 @@
using namespace llvm;
char FunctionAnalysisManagerModuleProxy::PassID;
FunctionAnalysisManagerModuleProxy::Result
FunctionAnalysisManagerModuleProxy::run(Module &M) {
assert(FAM->empty() && "Function analyses ran prior to the module proxy!");
@ -43,5 +41,3 @@ bool FunctionAnalysisManagerModuleProxy::Result::invalidate(
// Return false to indicate that this result is still a valid proxy.
return false;
}
char ModuleAnalysisManagerFunctionProxy::PassID;

View File

@ -61,17 +61,12 @@ struct NoOpModulePass {
};
/// \brief No-op module analysis.
struct NoOpModuleAnalysis {
struct NoOpModuleAnalysis : AnalysisBase<NoOpModuleAnalysis> {
struct Result {};
Result run(Module &) { return Result(); }
static StringRef name() { return "NoOpModuleAnalysis"; }
static void *ID() { return (void *)&PassID; }
private:
static char PassID;
};
char NoOpModuleAnalysis::PassID;
/// \brief No-op CGSCC pass which does nothing.
struct NoOpCGSCCPass {
PreservedAnalyses run(LazyCallGraph::SCC &C) {
@ -81,17 +76,12 @@ struct NoOpCGSCCPass {
};
/// \brief No-op CGSCC analysis.
struct NoOpCGSCCAnalysis {
struct NoOpCGSCCAnalysis : AnalysisBase<NoOpCGSCCAnalysis> {
struct Result {};
Result run(LazyCallGraph::SCC &) { return Result(); }
static StringRef name() { return "NoOpCGSCCAnalysis"; }
static void *ID() { return (void *)&PassID; }
private:
static char PassID;
};
char NoOpCGSCCAnalysis::PassID;
/// \brief No-op function pass which does nothing.
struct NoOpFunctionPass {
PreservedAnalyses run(Function &F) { return PreservedAnalyses::all(); }
@ -99,17 +89,12 @@ struct NoOpFunctionPass {
};
/// \brief No-op function analysis.
struct NoOpFunctionAnalysis {
struct NoOpFunctionAnalysis : AnalysisBase<NoOpFunctionAnalysis> {
struct Result {};
Result run(Function &) { return Result(); }
static StringRef name() { return "NoOpFunctionAnalysis"; }
static void *ID() { return (void *)&PassID; }
private:
static char PassID;
};
char NoOpFunctionAnalysis::PassID;
/// \brief No-op loop pass which does nothing.
struct NoOpLoopPass {
PreservedAnalyses run(Loop &L) { return PreservedAnalyses::all(); }
@ -117,17 +102,12 @@ struct NoOpLoopPass {
};
/// \brief No-op loop analysis.
struct NoOpLoopAnalysis {
struct NoOpLoopAnalysis : AnalysisBase<NoOpLoopAnalysis> {
struct Result {};
Result run(Loop &) { return Result(); }
static StringRef name() { return "NoOpLoopAnalysis"; }
static void *ID() { return (void *)&PassID; }
private:
static char PassID;
};
char NoOpLoopAnalysis::PassID;
} // End anonymous namespace.
void PassBuilder::registerModuleAnalyses(ModuleAnalysisManager &MAM) {

View File

@ -21,7 +21,7 @@
; CHECK-CGSCC-PASS: Starting llvm::Module pass manager run
; CHECK-CGSCC-PASS-NEXT: Running pass: ModuleToPostOrderCGSCCPassAdaptor
; CHECK-CGSCC-PASS-NEXT: Running analysis: CGSCCAnalysisManagerModuleProxy
; CHECK-CGSCC-PASS-NEXT: Running analysis: Lazy CallGraph Analysis
; CHECK-CGSCC-PASS-NEXT: Running analysis: LazyCallGraphAnalysis
; CHECK-CGSCC-PASS-NEXT: Starting llvm::LazyCallGraph::SCC pass manager run
; CHECK-CGSCC-PASS-NEXT: Running pass: NoOpCGSCCPass
; CHECK-CGSCC-PASS-NEXT: Finished llvm::LazyCallGraph::SCC pass manager run

View File

@ -19,19 +19,13 @@ using namespace llvm;
namespace {
class TestFunctionAnalysis {
class TestFunctionAnalysis : public AnalysisBase<TestFunctionAnalysis> {
public:
struct Result {
Result(int Count) : InstructionCount(Count) {}
int InstructionCount;
};
/// \brief Returns an opaque, unique ID for this pass type.
static void *ID() { return (void *)&PassID; }
/// \brief Returns the name of the analysis.
static StringRef name() { return "TestFunctionAnalysis"; }
TestFunctionAnalysis(int &Runs) : Runs(Runs) {}
/// \brief Run the analysis pass over the function and return a result.
@ -46,25 +40,16 @@ public:
}
private:
/// \brief Private static data to provide unique ID.
static char PassID;
int &Runs;
};
char TestFunctionAnalysis::PassID;
class TestModuleAnalysis {
class TestModuleAnalysis : public AnalysisBase<TestModuleAnalysis> {
public:
struct Result {
Result(int Count) : FunctionCount(Count) {}
int FunctionCount;
};
static void *ID() { return (void *)&PassID; }
static StringRef name() { return "TestModuleAnalysis"; }
TestModuleAnalysis(int &Runs) : Runs(Runs) {}
Result run(Module &M, ModuleAnalysisManager *AM) {
@ -76,14 +61,10 @@ public:
}
private:
static char PassID;
int &Runs;
};
char TestModuleAnalysis::PassID;
struct TestModulePass {
struct TestModulePass : PassBase<TestModulePass> {
TestModulePass(int &RunCount) : RunCount(RunCount) {}
PreservedAnalyses run(Module &M) {
@ -91,18 +72,14 @@ struct TestModulePass {
return PreservedAnalyses::none();
}
static StringRef name() { return "TestModulePass"; }
int &RunCount;
};
struct TestPreservingModulePass {
struct TestPreservingModulePass : PassBase<TestPreservingModulePass> {
PreservedAnalyses run(Module &M) { return PreservedAnalyses::all(); }
static StringRef name() { return "TestPreservingModulePass"; }
};
struct TestMinPreservingModulePass {
struct TestMinPreservingModulePass : PassBase<TestMinPreservingModulePass> {
PreservedAnalyses run(Module &M, ModuleAnalysisManager *AM) {
PreservedAnalyses PA;
@ -112,11 +89,9 @@ struct TestMinPreservingModulePass {
PA.preserve<FunctionAnalysisManagerModuleProxy>();
return PA;
}
static StringRef name() { return "TestMinPreservingModulePass"; }
};
struct TestFunctionPass {
struct TestFunctionPass : PassBase<TestFunctionPass> {
TestFunctionPass(int &RunCount, int &AnalyzedInstrCount,
int &AnalyzedFunctionCount,
bool OnlyUseCachedResults = false)
@ -147,8 +122,6 @@ struct TestFunctionPass {
return PreservedAnalyses::all();
}
static StringRef name() { return "TestFunctionPass"; }
int &RunCount;
int &AnalyzedInstrCount;
int &AnalyzedFunctionCount;
@ -157,7 +130,7 @@ struct TestFunctionPass {
// A test function pass that invalidates all function analyses for a function
// with a specific name.
struct TestInvalidationFunctionPass {
struct TestInvalidationFunctionPass : PassBase<TestInvalidationFunctionPass> {
TestInvalidationFunctionPass(StringRef FunctionName) : Name(FunctionName) {}
PreservedAnalyses run(Function &F) {
@ -165,8 +138,6 @@ struct TestInvalidationFunctionPass {
: PreservedAnalyses::all();
}
static StringRef name() { return "TestInvalidationFunctionPass"; }
StringRef Name;
};