aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2003-03-21 21:41:02 +0000
committerChris Lattner <sabre@nondot.org>2003-03-21 21:41:02 +0000
commitf1ab454b71efae1a5cee7f9285d91b75ead6a8a7 (patch)
tree12aebcb9e185b5faa5fa8fc41e3f74be39e95641
parent6f2ec7f59daa76df2bd98c4dda3d46cd20c66d37 (diff)
Add helper method
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@5753 91177308-0d34-0410-b5e6-96231b3b80d8
-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";