aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/llvm/Pass.h8
-rw-r--r--lib/VMCore/Pass.cpp4
2 files changed, 12 insertions, 0 deletions
diff --git a/include/llvm/Pass.h b/include/llvm/Pass.h
index 7138fadef5..9e8976e4de 100644
--- a/include/llvm/Pass.h
+++ b/include/llvm/Pass.h
@@ -142,6 +142,14 @@ public:
return dynamic_cast<AnalysisType*>(Resolver->getAnalysisToUpdate(PI));
}
+ /// mustPreserveAnalysisID - This method serves the same function as
+ /// getAnalysisToUpdate, but works if you just have an AnalysisID. This
+ /// obviously cannot give you a properly typed instance of the class if you
+ /// don't have the class name available (use getAnalysisToUpdate if you do),
+ /// but it can tell you if you need to preserve the pass at least.
+ ///
+ bool mustPreserveAnalysisID(const PassInfo *AnalysisID) const;
+
/// getAnalysis<AnalysisType>() - This function is used by subclasses to get
/// to the analysis information that they claim to use by overriding the
/// getAnalysisUsage function.
diff --git a/lib/VMCore/Pass.cpp b/lib/VMCore/Pass.cpp
index 96a4a3c02b..ca55b0da0a 100644
--- a/lib/VMCore/Pass.cpp
+++ b/lib/VMCore/Pass.cpp
@@ -142,6 +142,10 @@ void Pass::addToPassManager(PassManagerT<Module> *PM, AnalysisUsage &AU) {
PM->addPass(this, AU);
}
+bool Pass::mustPreserveAnalysisID(const PassInfo *AnalysisID) const {
+ return Resolver->getAnalysisToUpdate(AnalysisID) != 0;
+}
+
// dumpPassStructure - Implement the -debug-passes=Structure option
void Pass::dumpPassStructure(unsigned Offset) {
std::cerr << std::string(Offset*2, ' ') << getPassName() << "\n";