Add helper method
authorChris Lattner <sabre@nondot.org>
Fri, 21 Mar 2003 21:41:02 +0000 (21:41 +0000)
committerChris Lattner <sabre@nondot.org>
Fri, 21 Mar 2003 21:41:02 +0000 (21:41 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@5753 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Pass.h
lib/VMCore/Pass.cpp

index 7138fadef55ba7cf2c146c6d5d1d4bdd8350ab25..9e8976e4dece51b521fedc2c8c1ccf70584c26da 100644 (file)
@@ -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.
index 96a4a3c02be9ef17bf98c98c15df4309e314da6f..ca55b0da0ab88af8caf0fc202b64d4602e94fd21 100644 (file)
@@ -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";