aboutsummaryrefslogtreecommitdiffstats
path: root/include/llvm/PassAnalysisSupport.h
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2009-10-08 17:00:02 +0000
committerDan Gohman <gohman@apple.com>2009-10-08 17:00:02 +0000
commit8a261e44f71a433b7d9af373c3e3dfa6fea67146 (patch)
tree0f0a78c5c187f1764a43d34439e7cbaecbb9323b /include/llvm/PassAnalysisSupport.h
parentd4a537be0574460e9369152ca482456ccabac776 (diff)
downloadexternal_llvm-8a261e44f71a433b7d9af373c3e3dfa6fea67146.zip
external_llvm-8a261e44f71a433b7d9af373c3e3dfa6fea67146.tar.gz
external_llvm-8a261e44f71a433b7d9af373c3e3dfa6fea67146.tar.bz2
Add a form of addPreserved which takes a string argument, to allow passes
to declare that they preserve other passes without needing to pull in additional header file or library dependencies. Convert MachineFunctionPass and CodeGenLICM to make use of this. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@83555 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/PassAnalysisSupport.h')
-rw-r--r--include/llvm/PassAnalysisSupport.h17
1 files changed, 17 insertions, 0 deletions
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; }