forked from OSchip/llvm-project
[PM] Move the analysis registry into the Passes.cpp file and provide
a normal interface for it in Passes.h. This gives us essentially a single interface for running pass managers which are provided from the bottom of the LLVM stack through interfaces at the top of the LLVM stack that populate them with all of the different analyses available throughout. It also means there is a single blob of code that needs to include all of the pass headers and needs to deal with the registry of passes and parsing names. No functionality changed intended, should just be cleanup. llvm-svn: 225237
This commit is contained in:
parent
628503e4d4
commit
b70f673490
|
@ -17,7 +17,6 @@
|
||||||
#include "Passes.h"
|
#include "Passes.h"
|
||||||
#include "llvm/ADT/StringRef.h"
|
#include "llvm/ADT/StringRef.h"
|
||||||
#include "llvm/Analysis/CGSCCPassManager.h"
|
#include "llvm/Analysis/CGSCCPassManager.h"
|
||||||
#include "llvm/Analysis/LazyCallGraph.h"
|
|
||||||
#include "llvm/Bitcode/BitcodeWriterPass.h"
|
#include "llvm/Bitcode/BitcodeWriterPass.h"
|
||||||
#include "llvm/IR/IRPrintingPasses.h"
|
#include "llvm/IR/IRPrintingPasses.h"
|
||||||
#include "llvm/IR/LLVMContext.h"
|
#include "llvm/IR/LLVMContext.h"
|
||||||
|
@ -38,17 +37,10 @@ bool llvm::runPassPipeline(StringRef Arg0, LLVMContext &Context, Module &M,
|
||||||
CGSCCAnalysisManager CGAM;
|
CGSCCAnalysisManager CGAM;
|
||||||
ModuleAnalysisManager MAM;
|
ModuleAnalysisManager MAM;
|
||||||
|
|
||||||
#define MODULE_ANALYSIS(NAME, CREATE_PASS) \
|
// Register all the basic analyses with the managers.
|
||||||
MAM.registerPass(CREATE_PASS);
|
registerModuleAnalyses(MAM);
|
||||||
#include "PassRegistry.def"
|
registerCGSCCAnalyses(CGAM);
|
||||||
|
registerFunctionAnalyses(FAM);
|
||||||
#define CGSCC_ANALYSIS(NAME, CREATE_PASS) \
|
|
||||||
CGAM.registerPass(CREATE_PASS);
|
|
||||||
#include "PassRegistry.def"
|
|
||||||
|
|
||||||
#define FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
|
|
||||||
FAM.registerPass(CREATE_PASS);
|
|
||||||
#include "PassRegistry.def"
|
|
||||||
|
|
||||||
// Cross register the analysis managers through their proxies.
|
// Cross register the analysis managers through their proxies.
|
||||||
MAM.registerPass(FunctionAnalysisManagerModuleProxy(FAM));
|
MAM.registerPass(FunctionAnalysisManagerModuleProxy(FAM));
|
||||||
|
|
|
@ -48,6 +48,24 @@ struct NoOpFunctionPass {
|
||||||
|
|
||||||
} // End anonymous namespace.
|
} // End anonymous namespace.
|
||||||
|
|
||||||
|
void llvm::registerModuleAnalyses(ModuleAnalysisManager &MAM) {
|
||||||
|
#define MODULE_ANALYSIS(NAME, CREATE_PASS) \
|
||||||
|
MAM.registerPass(CREATE_PASS);
|
||||||
|
#include "PassRegistry.def"
|
||||||
|
}
|
||||||
|
|
||||||
|
void llvm::registerCGSCCAnalyses(CGSCCAnalysisManager &CGAM) {
|
||||||
|
#define CGSCC_ANALYSIS(NAME, CREATE_PASS) \
|
||||||
|
CGAM.registerPass(CREATE_PASS);
|
||||||
|
#include "PassRegistry.def"
|
||||||
|
}
|
||||||
|
|
||||||
|
void llvm::registerFunctionAnalyses(FunctionAnalysisManager &FAM) {
|
||||||
|
#define FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
|
||||||
|
FAM.registerPass(CREATE_PASS);
|
||||||
|
#include "PassRegistry.def"
|
||||||
|
}
|
||||||
|
|
||||||
static bool isModulePassName(StringRef Name) {
|
static bool isModulePassName(StringRef Name) {
|
||||||
if (Name == "no-op-module") return true;
|
if (Name == "no-op-module") return true;
|
||||||
|
|
||||||
|
|
|
@ -19,8 +19,32 @@
|
||||||
#include "llvm/ADT/StringRef.h"
|
#include "llvm/ADT/StringRef.h"
|
||||||
|
|
||||||
namespace llvm {
|
namespace llvm {
|
||||||
|
class CGSCCAnalysisManager;
|
||||||
|
class FunctionAnalysisManager;
|
||||||
|
class ModuleAnalysisManager;
|
||||||
class ModulePassManager;
|
class ModulePassManager;
|
||||||
|
|
||||||
|
/// \brief Registers all available module analysis passes.
|
||||||
|
///
|
||||||
|
/// This is an interface that can be used to populate a \c
|
||||||
|
/// ModuleAnalysisManager with all registered module analyses. Callers can
|
||||||
|
/// still manually register any additional analyses.
|
||||||
|
void registerModuleAnalyses(ModuleAnalysisManager &MAM);
|
||||||
|
|
||||||
|
/// \brief Registers all available CGSCC analysis passes.
|
||||||
|
///
|
||||||
|
/// This is an interface that can be used to populate a \c CGSCCAnalysisManager
|
||||||
|
/// with all registered CGSCC analyses. Callers can still manually register any
|
||||||
|
/// additional analyses.
|
||||||
|
void registerCGSCCAnalyses(CGSCCAnalysisManager &CGAM);
|
||||||
|
|
||||||
|
/// \brief Registers all available function analysis passes.
|
||||||
|
///
|
||||||
|
/// This is an interface that can be used to populate a \c
|
||||||
|
/// FunctionAnalysisManager with all registered function analyses. Callers can
|
||||||
|
/// still manually register any additional analyses.
|
||||||
|
void registerFunctionAnalyses(FunctionAnalysisManager &FAM);
|
||||||
|
|
||||||
/// \brief Parse a textual pass pipeline description into a \c ModulePassManager.
|
/// \brief Parse a textual pass pipeline description into a \c ModulePassManager.
|
||||||
///
|
///
|
||||||
/// The format of the textual pass pipeline description looks something like:
|
/// The format of the textual pass pipeline description looks something like:
|
||||||
|
|
Loading…
Reference in New Issue