diff options
author | Chandler Carruth <chandlerc@gmail.com> | 2013-11-23 00:38:42 +0000 |
---|---|---|
committer | Chandler Carruth <chandlerc@gmail.com> | 2013-11-23 00:38:42 +0000 |
commit | b88831b204bcc1645097dafee64efa2b6a91df2d (patch) | |
tree | 2323e483a8524cb8b208e0e043b851910b4f82e2 /include | |
parent | 43d67d01e2e32c51ec974e4f5c67343c6bf524a1 (diff) | |
download | llvm-b88831b204bcc1645097dafee64efa2b6a91df2d.tar.gz llvm-b88831b204bcc1645097dafee64efa2b6a91df2d.tar.bz2 llvm-b88831b204bcc1645097dafee64efa2b6a91df2d.tar.xz |
[PM] Add support to the analysis managers to query explicitly for cached
results.
This is the last piece of infrastructure needed to effectively support
querying *up* the analysis layers. The next step will be to introduce
a proxy which provides access to those layers with appropriate use of
const to direct queries to the safe interface.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@195525 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r-- | include/llvm/IR/PassManager.h | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/include/llvm/IR/PassManager.h b/include/llvm/IR/PassManager.h index 4d0c09234b..d6e97419de 100644 --- a/include/llvm/IR/PassManager.h +++ b/include/llvm/IR/PassManager.h @@ -460,6 +460,26 @@ public: return static_cast<const ResultModelT &>(ResultConcept).Result; } + /// \brief Get the cached result of an analysis pass for this module. + /// + /// This method never runs the analysis. + /// + /// \returns null if there is no cached result. + template <typename PassT> + const typename PassT::Result *getCachedResult(Module *M) const { + assert(ModuleAnalysisPasses.count(PassT::ID()) && + "This analysis pass was not registered prior to being queried"); + + const detail::AnalysisResultConcept<Module *> *ResultConcept = + getCachedResultImpl(PassT::ID(), M); + if (!ResultConcept) + return 0; + + typedef detail::AnalysisResultModel<Module *, PassT, typename PassT::Result> + ResultModelT; + return &static_cast<const ResultModelT *>(ResultConcept)->Result; + } + /// \brief Register an analysis pass with the manager. /// /// This provides an initialized and set-up analysis pass to the @@ -495,6 +515,10 @@ private: const detail::AnalysisResultConcept<Module *> &getResultImpl(void *PassID, Module *M); + /// \brief Get a cached module pass result or return null. + const detail::AnalysisResultConcept<Module *> * + getCachedResultImpl(void *PassID, Module *M) const; + /// \brief Invalidate a module pass result. void invalidateImpl(void *PassID, Module *M); @@ -537,6 +561,26 @@ public: return static_cast<const ResultModelT &>(ResultConcept).Result; } + /// \brief Get the cached result of an analysis pass for a function if + /// available. + /// + /// Does not run the analysis ever. + /// \returns null if a cached result is not available. + template <typename PassT> + const typename PassT::Result *getCachedResult(Function *F) { + assert(FunctionAnalysisPasses.count(PassT::ID()) && + "This analysis pass was not registered prior to being queried"); + + const detail::AnalysisResultConcept<Function *> *ResultConcept = + getCachedResultImpl(PassT::ID(), F); + if (!ResultConcept) + return 0; + + typedef detail::AnalysisResultModel<Function *, PassT, + typename PassT::Result> ResultModelT; + return &static_cast<const ResultModelT *>(ResultConcept)->Result; + } + /// \brief Register an analysis pass with the manager. /// /// This provides an initialized and set-up analysis pass to the @@ -583,6 +627,10 @@ private: const detail::AnalysisResultConcept<Function *> &getResultImpl(void *PassID, Function *F); + /// \brief Get a cached function pass result or return null. + const detail::AnalysisResultConcept<Function *> * + getCachedResultImpl(void *PassID, Function *F) const; + /// \brief Invalidate a function pass result. void invalidateImpl(void *PassID, Function *F); |