[llvm-commits] CVS: llvm/include/llvm/Pass.h PassAnalysisSupport.h PassManager.h
Devang Patel
dpatel at apple.com
Tue Dec 12 18:36:19 PST 2006
Changes in directory llvm/include/llvm:
Pass.h updated: 1.58 -> 1.59
PassAnalysisSupport.h updated: 1.24 -> 1.25
PassManager.h updated: 1.35 -> 1.36
---
Log message:
Add #ifdef switch toggle between old and new pass manager. However,
continue to use old pass manager at the moment. To use new manager
remove #define USE_OLD_PASSMANAGER 1 from Pass.h
---
Diffs of the changes: (+53 -13)
Pass.h | 10 ++++++++++
PassAnalysisSupport.h | 28 ++++++++++++++++++++++++++--
PassManager.h | 28 +++++++++++++++++-----------
3 files changed, 53 insertions(+), 13 deletions(-)
Index: llvm/include/llvm/Pass.h
diff -u llvm/include/llvm/Pass.h:1.58 llvm/include/llvm/Pass.h:1.59
--- llvm/include/llvm/Pass.h:1.58 Tue Dec 12 18:23:44 2006
+++ llvm/include/llvm/Pass.h Tue Dec 12 20:36:01 2006
@@ -36,6 +36,8 @@
#include <typeinfo>
#include <cassert>
+#define USE_OLD_PASSMANAGER 1
+
namespace llvm {
class Value;
@@ -203,7 +205,9 @@
virtual bool runPass(Module &M) { return runOnModule(M); }
virtual bool runPass(BasicBlock&) { return false; }
+#ifdef USE_OLD_PASSMANAGER
virtual void addToPassManager(ModulePassManager *PM, AnalysisUsage &AU);
+#endif
};
@@ -226,10 +230,12 @@
///
virtual bool runOnModule(Module &M) { return false; }
+#ifdef USE_OLD_PASSMANAGER
private:
template<typename Trait> friend class PassManagerT;
friend class ModulePassManager;
virtual void addToPassManager(ModulePassManager *PM, AnalysisUsage &AU);
+#endif
};
//===----------------------------------------------------------------------===//
@@ -269,6 +275,7 @@
///
bool run(Function &F);
+#ifdef USE_OLD_PASSMANAGER
protected:
template<typename Trait> friend class PassManagerT;
friend class ModulePassManager;
@@ -276,6 +283,7 @@
friend class BasicBlockPassManager;
virtual void addToPassManager(ModulePassManager *PM, AnalysisUsage &AU);
virtual void addToPassManager(FunctionPassManagerT *PM, AnalysisUsage &AU);
+#endif
};
@@ -329,6 +337,7 @@
virtual bool runPass(Module &M) { return false; }
virtual bool runPass(BasicBlock &BB);
+#ifdef USE_OLD_PASSMANAGER
private:
template<typename Trait> friend class PassManagerT;
friend class FunctionPassManagerT;
@@ -338,6 +347,7 @@
}
virtual void addToPassManager(FunctionPassManagerT *PM, AnalysisUsage &AU);
virtual void addToPassManager(BasicBlockPassManager *PM,AnalysisUsage &AU);
+#endif
};
/// If the user specifies the -time-passes argument on an LLVM tool command line
Index: llvm/include/llvm/PassAnalysisSupport.h
diff -u llvm/include/llvm/PassAnalysisSupport.h:1.24 llvm/include/llvm/PassAnalysisSupport.h:1.25
--- llvm/include/llvm/PassAnalysisSupport.h:1.24 Tue Dec 12 18:23:44 2006
+++ llvm/include/llvm/PassAnalysisSupport.h Tue Dec 12 20:36:01 2006
@@ -189,10 +189,19 @@
///
template<typename AnalysisType>
AnalysisType *Pass::getAnalysisToUpdate() const {
+#ifdef USE_OLD_PASSMANAGER
assert(Resolver && "Pass not resident in a PassManager object!");
+#else
+ assert(Resolver_New && "Pass not resident in a PassManager object!");
+#endif
const PassInfo *PI = getClassPassInfo<AnalysisType>();
if (PI == 0) return 0;
+#ifdef USE_OLD_PASSMANAGER
return dynamic_cast<AnalysisType*>(Resolver->getAnalysisToUpdate(PI));
+#else
+ return dynamic_cast<AnalysisType*>
+ (Resolver_New->getAnalysisToUpdate(PI, true));
+#endif
}
/// getAnalysis<AnalysisType>() - This function is used by subclasses to get
@@ -201,15 +210,20 @@
///
template<typename AnalysisType>
AnalysisType &Pass::getAnalysis() const {
+#ifdef USE_OLD_PASSMANAGER
assert(Resolver && "Pass has not been inserted into a PassManager object!");
+#else
+ assert(Resolver_New && "Pass has not been inserted into a PassManager object!");
+#endif
const PassInfo *PI = getClassPassInfo<AnalysisType>();
return getAnalysisID<AnalysisType>(PI);
}
template<typename AnalysisType>
AnalysisType &Pass::getAnalysisID(const PassInfo *PI) const {
- assert(Resolver && "Pass has not been inserted into a PassManager object!");
assert(PI && "getAnalysis for unregistered pass!");
+#ifdef USE_OLD_PASSMANAGER
+ assert(Resolver && "Pass has not been inserted into a PassManager object!");
// PI *must* appear in AnalysisImpls. Because the number of passes used
// should be a small number, we just do a linear search over a (dense)
@@ -224,7 +238,17 @@
break;
}
}
-
+#else
+ assert(Resolver_New && "Pass has not been inserted into a PassManager object!");
+ // PI *must* appear in AnalysisImpls. Because the number of passes used
+ // should be a small number, we just do a linear search over a (dense)
+ // vector.
+ Pass *ResultPass = Resolver_New->findImplPass(PI);
+ assert (ResultPass &&
+ "getAnalysis*() called on an analysis that was not "
+ "'required' by pass!");
+
+#endif
// Because the AnalysisType may not be a subclass of pass (for
// AnalysisGroups), we must use dynamic_cast here to potentially adjust the
// return pointer (because the class may multiply inherit, once from pass,
Index: llvm/include/llvm/PassManager.h
diff -u llvm/include/llvm/PassManager.h:1.35 llvm/include/llvm/PassManager.h:1.36
--- llvm/include/llvm/PassManager.h:1.35 Tue Dec 12 18:34:32 2006
+++ llvm/include/llvm/PassManager.h Tue Dec 12 20:36:01 2006
@@ -25,6 +25,9 @@
class ModulePass;
class Module;
class ModuleProvider;
+
+#ifdef USE_OLD_PASSMANAGER
+
class ModulePassManager;
class FunctionPassManagerT;
class BasicBlockPassManager;
@@ -87,17 +90,19 @@
bool doFinalization();
};
-class ModulePassManager_New;
+#else
+
+class ModulePassManager;
class PassManagerImpl_New;
class FunctionPassManagerImpl_New;
-/// PassManager_New manages ModulePassManagers
-class PassManager_New {
+/// PassManager manages ModulePassManagers
+class PassManager {
public:
- PassManager_New();
- ~PassManager_New();
+ PassManager();
+ ~PassManager();
/// add - Add a pass to the queue of passes to run. This passes ownership of
/// the Pass to the PassManager. When the PassManager is destroyed, the pass
@@ -111,18 +116,18 @@
private:
- /// PassManagerImpl_New is the actual class. PassManager_New is just the
+ /// PassManagerImpl_New is the actual class. PassManager is just the
/// wraper to publish simple pass manager interface
PassManagerImpl_New *PM;
};
-/// FunctionPassManager_New manages FunctionPasses and BasicBlockPassManagers.
-class FunctionPassManager_New {
+/// FunctionPassManager manages FunctionPasses and BasicBlockPassManagers.
+class FunctionPassManager {
public:
- FunctionPassManager_New(ModuleProvider *P);
- FunctionPassManager_New();
- ~FunctionPassManager_New();
+ FunctionPassManager(ModuleProvider *P);
+ FunctionPassManager();
+ ~FunctionPassManager();
/// add - Add a pass to the queue of passes to run. This passes
/// ownership of the Pass to the PassManager. When the
@@ -150,6 +155,7 @@
ModuleProvider *MP;
};
+#endif
} // End llvm namespace
More information about the llvm-commits
mailing list