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
This commit is contained in:
Dan Gohman
2009-10-08 17:00:02 +00:00
parent d4a537be05
commit 8a261e44f7
5 changed files with 52 additions and 16 deletions
+17
View File
@@ -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; }