summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/llvm/Pass.h7
-rw-r--r--include/llvm/PassAnalysisSupport.h16
2 files changed, 17 insertions, 6 deletions
diff --git a/include/llvm/Pass.h b/include/llvm/Pass.h
index a0fa060fbf..9e43b5e0a3 100644
--- a/include/llvm/Pass.h
+++ b/include/llvm/Pass.h
@@ -136,12 +136,7 @@ public:
/// automatically as the transform is performed.
///
template<typename AnalysisType>
- AnalysisType *getAnalysisToUpdate() const {
- assert(Resolver && "Pass not resident in a PassManager object!");
- const PassInfo *PI = getClassPassInfo<AnalysisType>();
- if (PI == 0) return 0;
- return dynamic_cast<AnalysisType*>(Resolver->getAnalysisToUpdate(PI));
- }
+ AnalysisType *getAnalysisToUpdate() const; // Defined in PassAnalysisSupport.h
/// mustPreserveAnalysisID - This method serves the same function as
/// getAnalysisToUpdate, but works if you just have an AnalysisID. This
diff --git a/include/llvm/PassAnalysisSupport.h b/include/llvm/PassAnalysisSupport.h
index 97588c3ae3..d27d669649 100644
--- a/include/llvm/PassAnalysisSupport.h
+++ b/include/llvm/PassAnalysisSupport.h
@@ -110,4 +110,20 @@ protected:
void setAnalysisResolver(Pass *P, AnalysisResolver *AR);
};
+/// getAnalysisToUpdate<AnalysisType>() - This function is used by subclasses
+/// to get to the analysis information that might be around that needs to be
+/// updated. This is different than getAnalysis in that it can fail (ie the
+/// analysis results haven't been computed), so should only be used if you
+/// provide the capability to update an analysis that exists. This method is
+/// often used by transformation APIs to update analysis results for a pass
+/// automatically as the transform is performed.
+///
+template<typename AnalysisType>
+AnalysisType *Pass::getAnalysisToUpdate() const {
+ assert(Resolver && "Pass not resident in a PassManager object!");
+ const PassInfo *PI = getClassPassInfo<AnalysisType>();
+ if (PI == 0) return 0;
+ return dynamic_cast<AnalysisType*>(Resolver->getAnalysisToUpdate(PI));
+}
+
#endif