From f1ab454b71efae1a5cee7f9285d91b75ead6a8a7 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Fri, 21 Mar 2003 21:41:02 +0000 Subject: [PATCH] Add helper method git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@5753 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Pass.h | 8 ++++++++ lib/VMCore/Pass.cpp | 4 ++++ 2 files changed, 12 insertions(+) diff --git a/include/llvm/Pass.h b/include/llvm/Pass.h index 7138fadef55..9e8976e4dec 100644 --- a/include/llvm/Pass.h +++ b/include/llvm/Pass.h @@ -142,6 +142,14 @@ public: return dynamic_cast(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() - 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 96a4a3c02be..ca55b0da0ab 100644 --- a/lib/VMCore/Pass.cpp +++ b/lib/VMCore/Pass.cpp @@ -142,6 +142,10 @@ void Pass::addToPassManager(PassManagerT *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";