diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/llvm/Pass.h | 5 | ||||
-rw-r--r-- | include/llvm/PassAnalysisSupport.h | 17 |
2 files changed, 22 insertions, 0 deletions
diff --git a/include/llvm/Pass.h b/include/llvm/Pass.h index f3f71c8..eb4c922 100644 --- a/include/llvm/Pass.h +++ b/include/llvm/Pass.h @@ -46,6 +46,7 @@ class PMStack; class AnalysisResolver; class PMDataManager; class raw_ostream; +class StringRef; // AnalysisID - Use the PassInfo to identify a pass... typedef const PassInfo* AnalysisID; @@ -164,6 +165,10 @@ public: // or null if it is not known. static const PassInfo *lookupPassInfo(intptr_t TI); + // lookupPassInfo - Return the pass info object for the pass with the given + // argument string, or null if it is not known. + static const PassInfo *lookupPassInfo(const StringRef &Arg); + /// getAnalysisIfAvailable<AnalysisType>() - Subclasses use this function to /// get analysis information that might be around, for example to update it. /// This is different than getAnalysis in that it can fail (if the analysis diff --git a/include/llvm/PassAnalysisSupport.h b/include/llvm/PassAnalysisSupport.h index b09ba45..f339481 100644 --- a/include/llvm/PassAnalysisSupport.h +++ b/include/llvm/PassAnalysisSupport.h @@ -24,6 +24,8 @@ namespace llvm { +class StringRef; + // No need to include Pass.h, we are being included by it! //===----------------------------------------------------------------------===// @@ -79,6 +81,9 @@ public: return *this; } + // addPreserved - Add the specified Pass class to the set of analyses + // preserved by this pass. + // template<class PassClass> AnalysisUsage &addPreserved() { assert(Pass::getClassPassInfo<PassClass>() && "Pass class not registered!"); @@ -86,6 +91,18 @@ public: return *this; } + // addPreserved - Add the Pass with the specified argument string to the set + // of analyses preserved by this pass. If no such Pass exists, do nothing. + // This can be useful when a pass is trivially preserved, but may not be + // linked in. Be careful about spelling! + // + AnalysisUsage &addPreserved(const StringRef &Arg) { + const PassInfo *PI = Pass::lookupPassInfo(Arg); + // If the pass exists, preserve it. Otherwise silently do nothing. + if (PI) Preserved.push_back(PI); + return *this; + } + // setPreservesAll - Set by analyses that do not transform their input at all void setPreservesAll() { PreservesAll = true; } bool getPreservesAll() const { return PreservesAll; } |