From 4d3682bda5d737183f188d2b58e0ff8c837d241f Mon Sep 17 00:00:00 2001 From: Chandler Carruth Date: Mon, 21 Apr 2014 08:20:10 +0000 Subject: [PM] Wire the analysis passes (such as they are) into the registry, and teach the opt driver to use it rather than a manual list. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@206739 91177308-0d34-0410-b5e6-96231b3b80d8 --- tools/opt/NewPMDriver.cpp | 10 +++++++--- tools/opt/PassRegistry.def | 11 +++++++++++ 2 files changed, 18 insertions(+), 3 deletions(-) (limited to 'tools') diff --git a/tools/opt/NewPMDriver.cpp b/tools/opt/NewPMDriver.cpp index fc4a1bf76c..39a6579356 100644 --- a/tools/opt/NewPMDriver.cpp +++ b/tools/opt/NewPMDriver.cpp @@ -36,9 +36,13 @@ bool llvm::runPassPipeline(StringRef Arg0, LLVMContext &Context, Module &M, FunctionAnalysisManager FAM; ModuleAnalysisManager MAM; - // FIXME: Lift this registration of analysis passes into a .def file adjacent - // to the one used to associate names with passes. - MAM.registerPass(LazyCallGraphAnalysis()); +#define MODULE_ANALYSIS(NAME, CREATE_PASS) \ + MAM.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. MAM.registerPass(FunctionAnalysisManagerModuleProxy(FAM)); diff --git a/tools/opt/PassRegistry.def b/tools/opt/PassRegistry.def index 6b507f7755..92ab2d932f 100644 --- a/tools/opt/PassRegistry.def +++ b/tools/opt/PassRegistry.def @@ -16,6 +16,12 @@ // NOTE: NO INCLUDE GUARD DESIRED! +#ifndef MODULE_ANALYSIS +#define MODULE_ANALYSIS(NAME, CREATE_PASS) +#endif +MODULE_ANALYSIS("lcg", LazyCallGraphAnalysis()) +#undef MODULE_ANALYSIS + #ifndef MODULE_PASS #define MODULE_PASS(NAME, CREATE_PASS) #endif @@ -23,6 +29,11 @@ MODULE_PASS("print", PrintModulePass(dbgs())) MODULE_PASS("print-cg", LazyCallGraphPrinterPass(dbgs())) #undef MODULE_PASS +#ifndef FUNCTION_ANALYSIS +#define FUNCTION_ANALYSIS(NAME, CREATE_PASS) +#endif +#undef FUNCTION_ANALYSIS + #ifndef FUNCTION_PASS #define FUNCTION_PASS(NAME, CREATE_PASS) #endif -- cgit v1.2.3