From: Chandler Carruth Date: Fri, 22 Nov 2013 11:46:33 +0000 (+0000) Subject: [PM] Remove the IRUnitT typedef requirement for analysis passes. X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=d984cdc17ea0b2b8aa638b512eb27059721d9662;p=oota-llvm.git [PM] Remove the IRUnitT typedef requirement for analysis passes. Since the analysis managers were split into explicit function and module analysis managers, it is now completely trivial to specify this when building up the concept and model types explicitly, and it is impossible to end up with a type error at run time. We instantiate a template when registering a pass that will enforce the requirement at a type-system level, and we produce a dynamic error on all the other query paths to the analysis manager if the pass in question isn't registered. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@195447 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/llvm/IR/PassManager.h b/include/llvm/IR/PassManager.h index c997f3a4690..39dbc98179d 100644 --- a/include/llvm/IR/PassManager.h +++ b/include/llvm/IR/PassManager.h @@ -327,14 +327,11 @@ template struct AnalysisPassConcept { /// Can wrap any type which implements a suitable \c run method. The method /// must accept the IRUnitT as an argument and produce an object which can be /// wrapped in a \c AnalysisResultModel. -template -struct AnalysisPassModel : AnalysisPassConcept { +template +struct AnalysisPassModel : AnalysisPassConcept { AnalysisPassModel(PassT Pass) : Pass(llvm_move(Pass)) {} virtual AnalysisPassModel *clone() { return new AnalysisPassModel(Pass); } - // FIXME: Replace PassT::IRUnitT with type traits when we use C++11. - typedef typename PassT::IRUnitT IRUnitT; - // FIXME: Replace PassT::Result with type traits when we use C++11. typedef AnalysisResultModel ResultModelT; @@ -418,8 +415,6 @@ public: /// If there is not a valid cached result in the manager already, this will /// re-run the analysis to produce a valid result. template const typename PassT::Result &getResult(Module *M) { - LLVM_STATIC_ASSERT((is_same::value), - "The analysis pass must be over a Module."); assert(ModuleAnalysisPasses.count(PassT::ID()) && "This analysis pass was not registered prior to being queried"); @@ -438,20 +433,16 @@ public: /// populate /// the manager with all of the analysis passes available. template void registerPass(PassT Pass) { - LLVM_STATIC_ASSERT((is_same::value), - "The analysis pass must be over a Module."); assert(!ModuleAnalysisPasses.count(PassT::ID()) && "Registered the same analysis pass twice!"); ModuleAnalysisPasses[PassT::ID()] = - new detail::AnalysisPassModel(llvm_move(Pass)); + new detail::AnalysisPassModel(llvm_move(Pass)); } /// \brief Invalidate a specific analysis pass for an IR module. /// /// Note that the analysis result can disregard invalidation. template void invalidate(Module *M) { - LLVM_STATIC_ASSERT((is_same::value), - "The analysis pass must be over a Module."); assert(ModuleAnalysisPasses.count(PassT::ID()) && "This analysis pass was not registered prior to being invalidated"); invalidateImpl(PassT::ID(), M); @@ -500,8 +491,6 @@ public: /// re-run the analysis to produce a valid result. template const typename PassT::Result &getResult(Function *F) { - LLVM_STATIC_ASSERT((is_same::value), - "The analysis pass must be over a Function."); assert(FunctionAnalysisPasses.count(PassT::ID()) && "This analysis pass was not registered prior to being queried"); @@ -520,20 +509,16 @@ public: /// populate /// the manager with all of the analysis passes available. template void registerPass(PassT Pass) { - LLVM_STATIC_ASSERT((is_same::value), - "The analysis pass must be over a Function."); assert(!FunctionAnalysisPasses.count(PassT::ID()) && "Registered the same analysis pass twice!"); FunctionAnalysisPasses[PassT::ID()] = - new detail::AnalysisPassModel(llvm_move(Pass)); + new detail::AnalysisPassModel(llvm_move(Pass)); } /// \brief Invalidate a specific analysis pass for an IR module. /// /// Note that the analysis result can disregard invalidation. template void invalidate(Function *F) { - LLVM_STATIC_ASSERT((is_same::value), - "The analysis pass must be over a Function."); assert(FunctionAnalysisPasses.count(PassT::ID()) && "This analysis pass was not registered prior to being invalidated"); invalidateImpl(PassT::ID(), F); @@ -617,7 +602,6 @@ private: /// pass. class FunctionAnalysisManagerModuleProxy { public: - typedef Module *IRUnitT; class Result; static void *ID() { return (void *)&PassID; } diff --git a/unittests/IR/PassManagerTest.cpp b/unittests/IR/PassManagerTest.cpp index d5f5f27b452..b0d4cbe0318 100644 --- a/unittests/IR/PassManagerTest.cpp +++ b/unittests/IR/PassManagerTest.cpp @@ -21,8 +21,6 @@ namespace { class TestAnalysisPass { public: - typedef Function *IRUnitT; - struct Result { Result(int Count) : InstructionCount(Count) {} int InstructionCount;