aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/llvm/PassSupport.h14
-rw-r--r--lib/VMCore/Pass.cpp63
2 files changed, 37 insertions, 40 deletions
diff --git a/include/llvm/PassSupport.h b/include/llvm/PassSupport.h
index 60c24b0666..9f5bc55f9c 100644
--- a/include/llvm/PassSupport.h
+++ b/include/llvm/PassSupport.h
@@ -38,6 +38,7 @@ class PassInfo {
const char *PassName; // Nice name for Pass
const char *PassArgument; // Command Line argument to run this pass
const std::type_info &TypeInfo; // type_info object for this Pass class
+ bool IsCFGOnlyPass; // Pass only looks at the CFG.
bool IsAnalysisGroup; // True if an analysis group.
std::vector<const PassInfo*> ItfImpl;// Interfaces implemented by this pass
@@ -48,8 +49,8 @@ public:
/// through RegisterPass.
PassInfo(const char *name, const char *arg, const std::type_info &ti,
Pass *(*normal)() = 0)
- : PassName(name), PassArgument(arg), TypeInfo(ti), IsAnalysisGroup(false),
- NormalCtor(normal) {
+ : PassName(name), PassArgument(arg), TypeInfo(ti),
+ IsCFGOnlyPass(false), IsAnalysisGroup(false), NormalCtor(normal) {
}
/// getPassName - Return the friendly name for the pass, never returns null
@@ -73,6 +74,11 @@ public:
bool isAnalysisGroup() const { return IsAnalysisGroup; }
void SetIsAnalysisGroup() { IsAnalysisGroup = true; }
+ /// isCFGOnlyPass - return true if this pass only looks at the CFG for the
+ /// function.
+ bool isCFGOnlyPass() const { return IsCFGOnlyPass; }
+ void SetIsCFGOnlyPass() { IsCFGOnlyPass = true; }
+
/// getNormalCtor - Return a pointer to a function, that when called, creates
/// an instance of the pass and returns it. This pointer may be null if there
/// is no default constructor for the pass.
@@ -159,7 +165,9 @@ protected:
/// setOnlyUsesCFG - Notice that this pass only depends on the CFG, so
/// transformations that do not modify the CFG do not invalidate this pass.
///
- void setOnlyUsesCFG();
+ void setOnlyUsesCFG() {
+ PIObj.SetIsCFGOnlyPass();
+ }
};
template<typename PassName>
diff --git a/lib/VMCore/Pass.cpp b/lib/VMCore/Pass.cpp
index cf7e1c05a7..3c108fbeb7 100644
--- a/lib/VMCore/Pass.cpp
+++ b/lib/VMCore/Pass.cpp
@@ -24,21 +24,6 @@
using namespace llvm;
//===----------------------------------------------------------------------===//
-// AnalysisID Class Implementation
-//
-
-// getCFGOnlyAnalyses - A wrapper around the CFGOnlyAnalyses which make it
-// initializer order independent.
-static std::vector<const PassInfo*> &getCFGOnlyAnalyses() {
- static std::vector<const PassInfo*> CFGOnlyAnalyses;
- return CFGOnlyAnalyses;
-}
-
-void RegisterPassBase::setOnlyUsesCFG() {
- getCFGOnlyAnalyses().push_back(&PIObj);
-}
-
-//===----------------------------------------------------------------------===//
// AnalysisResolver Class Implementation
//
@@ -50,28 +35,6 @@ void AnalysisResolver::setAnalysisResolver(Pass *P, AnalysisResolver *AR) {
}
//===----------------------------------------------------------------------===//
-// AnalysisUsage Class Implementation
-//
-
-// setPreservesCFG - This function should be called to by the pass, iff they do
-// not:
-//
-// 1. Add or remove basic blocks from the function
-// 2. Modify terminator instructions in any way.
-//
-// This function annotates the AnalysisUsage info object to say that analyses
-// that only depend on the CFG are preserved by this pass.
-//
-void AnalysisUsage::setPreservesCFG() {
- // Since this transformation doesn't modify the CFG, it preserves all analyses
- // that only depend on the CFG (like dominators, loop info, etc...)
- //
- Preserved.insert(Preserved.end(),
- getCFGOnlyAnalyses().begin(), getCFGOnlyAnalyses().end());
-}
-
-
-//===----------------------------------------------------------------------===//
// PassManager implementation - The PassManager class is a simple Pimpl class
// that wraps the PassManagerT template.
//
@@ -500,3 +463,29 @@ void PassRegistrationListener::enumeratePasses() {
passEnumerate(I->second);
}
+//===----------------------------------------------------------------------===//
+// AnalysisUsage Class Implementation
+//
+
+// setPreservesCFG - This function should be called to by the pass, iff they do
+// not:
+//
+// 1. Add or remove basic blocks from the function
+// 2. Modify terminator instructions in any way.
+//
+// This function annotates the AnalysisUsage info object to say that analyses
+// that only depend on the CFG are preserved by this pass.
+//
+void AnalysisUsage::setPreservesCFG() {
+ // Since this transformation doesn't modify the CFG, it preserves all analyses
+ // that only depend on the CFG (like dominators, loop info, etc...)
+ //
+ if (PassInfoMap) {
+ for (std::map<TypeInfo, PassInfo*>::iterator I = PassInfoMap->begin(),
+ E = PassInfoMap->end(); I != E; ++I)
+ if (I->second->isCFGOnlyPass())
+ Preserved.push_back(I->second);
+ }
+}
+
+