diff --git a/llvm/include/llvm/IR/PassManager.h b/llvm/include/llvm/IR/PassManager.h index 151f1a533a3a..c997f3a46909 100644 --- a/llvm/include/llvm/IR/PassManager.h +++ b/llvm/include/llvm/IR/PassManager.h @@ -238,7 +238,7 @@ template struct AnalysisResultConcept { /// took care to update or preserve the analysis result in some way. /// /// \returns true if the result is indeed invalid (the default). - virtual bool invalidate(IRUnitT *IR, const PreservedAnalyses &PA) = 0; + virtual bool invalidate(IRUnitT IR, const PreservedAnalyses &PA) = 0; }; /// \brief SFINAE metafunction for computing whether \c ResultT provides an @@ -247,7 +247,7 @@ template class ResultHasInvalidateMethod { typedef char SmallType; struct BigType { char a, b; }; - template + template struct Checker; template static SmallType f(Checker *); @@ -283,7 +283,7 @@ struct AnalysisResultModel struct AnalysisPassConcept { /// \brief Method to run this analysis over a unit of IR. /// \returns The analysis result object to be queried by users, the caller /// takes ownership. - virtual AnalysisResultConcept *run(IRUnitT *IR) = 0; + virtual AnalysisResultConcept *run(IRUnitT IR) = 0; }; /// \brief Wrapper to model the analysis pass concept. @@ -342,7 +342,7 @@ struct AnalysisPassModel : AnalysisPassConcept { /// \brief The model delegates to the \c PassT::run method. /// /// The return is wrapped in an \c AnalysisResultModel. - virtual ResultModelT *run(IRUnitT *IR) { + virtual ResultModelT *run(IRUnitT IR) { return new ResultModelT(Pass.run(IR)); } @@ -418,14 +418,14 @@ 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), + 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"); - const detail::AnalysisResultConcept &ResultConcept = + const detail::AnalysisResultConcept &ResultConcept = getResultImpl(PassT::ID(), M); - typedef detail::AnalysisResultModel + typedef detail::AnalysisResultModel ResultModelT; return static_cast(ResultConcept).Result; } @@ -438,7 +438,7 @@ public: /// populate /// the manager with all of the analysis passes available. template void registerPass(PassT Pass) { - LLVM_STATIC_ASSERT((is_same::value), + 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!"); @@ -450,7 +450,7 @@ public: /// /// Note that the analysis result can disregard invalidation. template void invalidate(Module *M) { - LLVM_STATIC_ASSERT((is_same::value), + 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"); @@ -465,15 +465,15 @@ public: private: /// \brief Get a module pass result, running the pass if necessary. - const detail::AnalysisResultConcept &getResultImpl(void *PassID, - Module *M); + const detail::AnalysisResultConcept &getResultImpl(void *PassID, + Module *M); /// \brief Invalidate a module pass result. void invalidateImpl(void *PassID, Module *M); /// \brief Map type from module analysis pass ID to pass concept pointer. typedef DenseMap > > + polymorphic_ptr > > ModuleAnalysisPassMapT; /// \brief Collection of module analysis passes, indexed by ID. @@ -481,7 +481,7 @@ private: /// \brief Map type from module analysis pass ID to pass result concept pointer. typedef DenseMap > > + polymorphic_ptr > > ModuleAnalysisResultMapT; /// \brief Cache of computed module analysis results for this module. @@ -500,15 +500,15 @@ public: /// re-run the analysis to produce a valid result. template const typename PassT::Result &getResult(Function *F) { - LLVM_STATIC_ASSERT((is_same::value), + 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"); - const detail::AnalysisResultConcept &ResultConcept = + const detail::AnalysisResultConcept &ResultConcept = getResultImpl(PassT::ID(), F); - typedef detail::AnalysisResultModel - ResultModelT; + typedef detail::AnalysisResultModel ResultModelT; return static_cast(ResultConcept).Result; } @@ -520,7 +520,7 @@ public: /// populate /// the manager with all of the analysis passes available. template void registerPass(PassT Pass) { - LLVM_STATIC_ASSERT((is_same::value), + 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!"); @@ -532,7 +532,7 @@ public: /// /// Note that the analysis result can disregard invalidation. template void invalidate(Function *F) { - LLVM_STATIC_ASSERT((is_same::value), + 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"); @@ -559,15 +559,15 @@ public: private: /// \brief Get a function pass result, running the pass if necessary. - const detail::AnalysisResultConcept &getResultImpl(void *PassID, - Function *F); + const detail::AnalysisResultConcept &getResultImpl(void *PassID, + Function *F); /// \brief Invalidate a function pass result. void invalidateImpl(void *PassID, Function *F); /// \brief Map type from function analysis pass ID to pass concept pointer. typedef DenseMap > > + polymorphic_ptr > > FunctionAnalysisPassMapT; /// \brief Collection of function analysis passes, indexed by ID. @@ -579,7 +579,7 @@ private: /// erases. Provides both the pass ID and concept pointer such that it is /// half of a bijection and provides storage for the actual result concept. typedef std::list > > > + void *, polymorphic_ptr > > > FunctionAnalysisResultListT; /// \brief Map type from function pointer to our custom list type. @@ -617,7 +617,7 @@ private: /// pass. class FunctionAnalysisManagerModuleProxy { public: - typedef Module IRUnitT; + typedef Module *IRUnitT; class Result; static void *ID() { return (void *)&PassID; } diff --git a/llvm/lib/IR/PassManager.cpp b/llvm/lib/IR/PassManager.cpp index c4c2d1471f76..f2d0cd99e619 100644 --- a/llvm/lib/IR/PassManager.cpp +++ b/llvm/lib/IR/PassManager.cpp @@ -33,12 +33,12 @@ void ModuleAnalysisManager::invalidate(Module *M, const PreservedAnalyses &PA) { ModuleAnalysisResults.erase(I); } -const detail::AnalysisResultConcept & +const detail::AnalysisResultConcept & ModuleAnalysisManager::getResultImpl(void *PassID, Module *M) { ModuleAnalysisResultMapT::iterator RI; bool Inserted; llvm::tie(RI, Inserted) = ModuleAnalysisResults.insert(std::make_pair( - PassID, polymorphic_ptr >())); + PassID, polymorphic_ptr >())); if (Inserted) { // We don't have a cached result for this result. Look up the pass and run @@ -100,7 +100,7 @@ void FunctionAnalysisManager::clear() { FunctionAnalysisResultLists.clear(); } -const detail::AnalysisResultConcept & +const detail::AnalysisResultConcept & FunctionAnalysisManager::getResultImpl(void *PassID, Function *F) { FunctionAnalysisResultMapT::iterator RI; bool Inserted; diff --git a/llvm/unittests/IR/PassManagerTest.cpp b/llvm/unittests/IR/PassManagerTest.cpp index 94fe99a3aa05..d5f5f27b4522 100644 --- a/llvm/unittests/IR/PassManagerTest.cpp +++ b/llvm/unittests/IR/PassManagerTest.cpp @@ -21,7 +21,7 @@ namespace { class TestAnalysisPass { public: - typedef Function IRUnitT; + typedef Function *IRUnitT; struct Result { Result(int Count) : InstructionCount(Count) {}