aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2004-09-20 04:48:05 +0000
committerChris Lattner <sabre@nondot.org>2004-09-20 04:48:05 +0000
commitb12914bfc0f76a7a48357162d5f4c39a1343e69b (patch)
tree00bff0412482165a6d7d60775e4aeb6ebe3b4628
parentbba61c07ddca19f72b13dd5a410358d296ed1d6a (diff)
'Pass' should now not be derived from by clients. Instead, they should derive
from ModulePass. Instead of implementing Pass::run, then should implement ModulePass::runOnModule. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16436 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/llvm/Analysis/CallGraph.h6
-rw-r--r--include/llvm/Analysis/DataStructure/DataStructure.h14
-rw-r--r--include/llvm/Analysis/FindUnsafePointerTypes.h4
-rw-r--r--include/llvm/Analysis/FindUsedTypes.h4
-rw-r--r--include/llvm/Assembly/PrintModulePass.h4
-rw-r--r--include/llvm/Bytecode/WriteBytecodePass.h4
-rw-r--r--include/llvm/CallGraphSCCPass.h4
-rw-r--r--include/llvm/Pass.h36
-rw-r--r--include/llvm/PassManager.h1
-rw-r--r--lib/Analysis/AliasAnalysisCounter.cpp4
-rw-r--r--lib/Analysis/DataStructure/BottomUpClosure.cpp2
-rw-r--r--lib/Analysis/DataStructure/CompleteBottomUp.cpp2
-rw-r--r--lib/Analysis/DataStructure/DataStructureAA.cpp4
-rw-r--r--lib/Analysis/DataStructure/DataStructureOpt.cpp4
-rw-r--r--lib/Analysis/DataStructure/IPModRef.cpp2
-rw-r--r--lib/Analysis/DataStructure/IPModRef.h4
-rw-r--r--lib/Analysis/DataStructure/Local.cpp2
-rw-r--r--lib/Analysis/DataStructure/MemoryDepAnalysis.cpp2
-rw-r--r--lib/Analysis/DataStructure/MemoryDepAnalysis.h4
-rw-r--r--lib/Analysis/DataStructure/Parallelize.cpp6
-rw-r--r--lib/Analysis/DataStructure/PgmDependenceGraph.h4
-rw-r--r--lib/Analysis/DataStructure/Steensgaard.cpp6
-rw-r--r--lib/Analysis/DataStructure/TopDownClosure.cpp2
-rw-r--r--lib/Analysis/IPA/Andersens.cpp4
-rw-r--r--lib/Analysis/IPA/CallGraph.cpp2
-rw-r--r--lib/Analysis/IPA/CallGraphSCCPass.cpp2
-rw-r--r--lib/Analysis/IPA/FindUnsafePointerTypes.cpp2
-rw-r--r--lib/Analysis/IPA/FindUsedTypes.cpp2
-rw-r--r--lib/Analysis/IPA/GlobalsModRef.cpp4
-rw-r--r--lib/Analysis/ProfileInfoLoaderPass.cpp6
-rw-r--r--lib/Target/CBackend/CBackend.cpp6
-rw-r--r--lib/Target/CBackend/Writer.cpp6
-rw-r--r--lib/Target/SparcV9/EmitBytecodeToAssembly.cpp12
-rw-r--r--lib/Target/SparcV9/InternalGlobalMapper.cpp14
-rw-r--r--lib/Target/SparcV9/MappingInfo.cpp4
-rw-r--r--lib/Target/SparcV9/MappingInfo.h6
-rw-r--r--lib/Target/SparcV9/SparcV9Internals.h6
-rw-r--r--lib/Target/SparcV9/SparcV9StackSlots.cpp2
-rw-r--r--lib/Transforms/IPO/ArgumentPromotion.cpp2
-rw-r--r--lib/Transforms/IPO/ConstantMerge.cpp8
-rw-r--r--lib/Transforms/IPO/DeadArgumentElimination.cpp10
-rw-r--r--lib/Transforms/IPO/DeadTypeElimination.cpp8
-rw-r--r--lib/Transforms/IPO/ExtractFunction.cpp6
-rw-r--r--lib/Transforms/IPO/FunctionResolution.cpp8
-rw-r--r--lib/Transforms/IPO/GlobalDCE.cpp8
-rw-r--r--lib/Transforms/IPO/GlobalOpt.cpp8
-rw-r--r--lib/Transforms/IPO/IPConstantPropagation.cpp8
-rw-r--r--lib/Transforms/IPO/InlineSimple.cpp2
-rw-r--r--lib/Transforms/IPO/Internalize.cpp6
-rw-r--r--lib/Transforms/IPO/LoopExtractor.cpp10
-rw-r--r--lib/Transforms/IPO/LowerSetJmp.cpp16
-rw-r--r--lib/Transforms/IPO/PruneEH.cpp2
-rw-r--r--lib/Transforms/IPO/RaiseAllocations.cpp8
-rw-r--r--lib/Transforms/Instrumentation/BlockProfiling.cpp12
-rw-r--r--lib/Transforms/Instrumentation/EdgeProfiling.cpp6
-rw-r--r--lib/Transforms/Instrumentation/EmitFunctions.cpp6
-rw-r--r--lib/Transforms/Instrumentation/TraceBasicBlocks.cpp6
-rw-r--r--lib/VMCore/PassManagerT.h10
-rw-r--r--tools/analyze/AnalysisWrappers.cpp4
-rw-r--r--tools/analyze/GraphPrinters.cpp4
-rw-r--r--tools/analyze/analyze.cpp4
-rw-r--r--tools/bugpoint/ExtractFunction.cpp6
-rw-r--r--tools/opt/AnalysisWrappers.cpp4
-rw-r--r--tools/opt/GraphPrinters.cpp4
64 files changed, 193 insertions, 186 deletions
diff --git a/include/llvm/Analysis/CallGraph.h b/include/llvm/Analysis/CallGraph.h
index 8f2c302389..446ea500d4 100644
--- a/include/llvm/Analysis/CallGraph.h
+++ b/include/llvm/Analysis/CallGraph.h
@@ -64,7 +64,7 @@ class CallGraphNode;
//===----------------------------------------------------------------------===//
// CallGraph class definition
//
-class CallGraph : public Pass {
+class CallGraph : public ModulePass {
Module *Mod; // The module this call graph represents
typedef std::map<const Function *, CallGraphNode *> FunctionMapTy;
@@ -150,8 +150,8 @@ public:
CallGraph() : Root(0), CallsExternalNode(0) {}
~CallGraph() { destroy(); }
- // run - Compute the call graph for the specified module.
- virtual bool run(Module &M);
+ // runOnModule - Compute the call graph for the specified module.
+ virtual bool runOnModule(Module &M);
// getAnalysisUsage - This obviously provides a call graph
virtual void getAnalysisUsage(AnalysisUsage &AU) const {
diff --git a/include/llvm/Analysis/DataStructure/DataStructure.h b/include/llvm/Analysis/DataStructure/DataStructure.h
index 9351ed4c98..34575a2db8 100644
--- a/include/llvm/Analysis/DataStructure/DataStructure.h
+++ b/include/llvm/Analysis/DataStructure/DataStructure.h
@@ -40,14 +40,14 @@ namespace DataStructureAnalysis {
// FIXME: This should be a Function pass that can be USED by a Pass, and would
// be automatically preserved. Until we can do that, this is a Pass.
//
-class LocalDataStructures : public Pass {
+class LocalDataStructures : public ModulePass {
// DSInfo, one graph for each function
hash_map<Function*, DSGraph*> DSInfo;
DSGraph *GlobalsGraph;
public:
~LocalDataStructures() { releaseMemory(); }
- virtual bool run(Module &M);
+ virtual bool runOnModule(Module &M);
bool hasGraph(const Function &F) const {
return DSInfo.find(const_cast<Function*>(&F)) != DSInfo.end();
@@ -86,7 +86,7 @@ public:
/// data structure graphs for all of the functions in the program. This pass
/// only performs a "Bottom Up" propagation (hence the name).
///
-class BUDataStructures : public Pass {
+class BUDataStructures : public ModulePass {
protected:
// DSInfo, one graph for each function
hash_map<Function*, DSGraph*> DSInfo;
@@ -95,7 +95,7 @@ protected:
public:
~BUDataStructures() { releaseMemory(); }
- virtual bool run(Module &M);
+ virtual bool runOnModule(Module &M);
bool hasGraph(const Function &F) const {
return DSInfo.find(const_cast<Function*>(&F)) != DSInfo.end();
@@ -149,7 +149,7 @@ private:
/// for each function using the closed graphs for the callers computed
/// by the bottom-up pass.
///
-class TDDataStructures : public Pass {
+class TDDataStructures : public ModulePass {
// DSInfo, one graph for each function
hash_map<Function*, DSGraph*> DSInfo;
hash_set<Function*> ArgsRemainIncomplete;
@@ -157,7 +157,7 @@ class TDDataStructures : public Pass {
public:
~TDDataStructures() { releaseMyMemory(); }
- virtual bool run(Module &M);
+ virtual bool runOnModule(Module &M);
bool hasGraph(const Function &F) const {
return DSInfo.find(const_cast<Function*>(&F)) != DSInfo.end();
@@ -207,7 +207,7 @@ private:
/// allocation.
///
struct CompleteBUDataStructures : public BUDataStructures {
- virtual bool run(Module &M);
+ virtual bool runOnModule(Module &M);
bool hasGraph(const Function &F) const {
return DSInfo.find(const_cast<Function*>(&F)) != DSInfo.end();
diff --git a/include/llvm/Analysis/FindUnsafePointerTypes.h b/include/llvm/Analysis/FindUnsafePointerTypes.h
index a2306021f9..2d453f087a 100644
--- a/include/llvm/Analysis/FindUnsafePointerTypes.h
+++ b/include/llvm/Analysis/FindUnsafePointerTypes.h
@@ -31,7 +31,7 @@ namespace llvm {
class PointerType;
-struct FindUnsafePointerTypes : public Pass {
+struct FindUnsafePointerTypes : public ModulePass {
// UnsafeTypes - Set of types that are not safe to transform.
std::set<PointerType*> UnsafeTypes;
public:
@@ -44,7 +44,7 @@ public:
/// values of various types. If they are deemed to be 'unsafe' note that the
/// type is not safe to transform.
///
- virtual bool run(Module &M);
+ virtual bool runOnModule(Module &M);
/// print - Loop over the results of the analysis, printing out unsafe types.
///
diff --git a/include/llvm/Analysis/FindUsedTypes.h b/include/llvm/Analysis/FindUsedTypes.h
index 69471791ab..143d6ce031 100644
--- a/include/llvm/Analysis/FindUsedTypes.h
+++ b/include/llvm/Analysis/FindUsedTypes.h
@@ -21,7 +21,7 @@ namespace llvm {
class Type;
-class FindUsedTypes : public Pass {
+class FindUsedTypes : public ModulePass {
std::set<const Type *> UsedTypes;
public:
/// getTypes - After the pass has been run, return the set containing all of
@@ -47,7 +47,7 @@ private:
public:
/// run - This incorporates all types used by the specified module
- bool run(Module &M);
+ bool runOnModule(Module &M);
/// getAnalysisUsage - We do not modify anything.
virtual void getAnalysisUsage(AnalysisUsage &AU) const {
diff --git a/include/llvm/Assembly/PrintModulePass.h b/include/llvm/Assembly/PrintModulePass.h
index fc7e6f48a5..102701fde2 100644
--- a/include/llvm/Assembly/PrintModulePass.h
+++ b/include/llvm/Assembly/PrintModulePass.h
@@ -24,7 +24,7 @@
namespace llvm {
-class PrintModulePass : public Pass {
+class PrintModulePass : public ModulePass {
std::ostream *Out; // ostream to print on
bool DeleteStream; // Delete the ostream in our dtor?
public:
@@ -37,7 +37,7 @@ public:
if (DeleteStream) delete Out;
}
- bool run(Module &M) {
+ bool runOnModule(Module &M) {
(*Out) << M << std::flush;
return false;
}
diff --git a/include/llvm/Bytecode/WriteBytecodePass.h b/include/llvm/Bytecode/WriteBytecodePass.h
index b8863e6b47..5b6325d521 100644
--- a/include/llvm/Bytecode/WriteBytecodePass.h
+++ b/include/llvm/Bytecode/WriteBytecodePass.h
@@ -21,7 +21,7 @@
namespace llvm {
-class WriteBytecodePass : public Pass {
+class WriteBytecodePass : public ModulePass {
std::ostream *Out; // ostream to print on
bool DeleteStream;
public:
@@ -34,7 +34,7 @@ public:
if (DeleteStream) delete Out;
}
- bool run(Module &M) {
+ bool runOnModule(Module &M) {
WriteBytecodeToFile(&M, *Out);
return false;
}
diff --git a/include/llvm/CallGraphSCCPass.h b/include/llvm/CallGraphSCCPass.h
index b7fba387ea..389a80c9e3 100644
--- a/include/llvm/CallGraphSCCPass.h
+++ b/include/llvm/CallGraphSCCPass.h
@@ -28,7 +28,7 @@ namespace llvm {
class CallGraphNode;
class CallGraph;
-struct CallGraphSCCPass : public Pass {
+struct CallGraphSCCPass : public ModulePass {
/// doInitialization - This method is called before the SCC's of the program
/// has been processed, allowing the pass to do initialization as necessary.
@@ -52,7 +52,7 @@ struct CallGraphSCCPass : public Pass {
/// run - Run this pass, returning true if a modification was made to the
/// module argument. This is implemented in terms of the runOnSCC method.
///
- virtual bool run(Module &M);
+ virtual bool runOnModule(Module &M);
/// getAnalysisUsage - For this class, we declare that we require and preserve
diff --git a/include/llvm/Pass.h b/include/llvm/Pass.h
index 08496c5d2e..77f630c316 100644
--- a/include/llvm/Pass.h
+++ b/include/llvm/Pass.h
@@ -84,10 +84,10 @@ public:
///
const PassInfo *getPassInfo() const;
- /// run - Run this pass, returning true if a modification was made to the
+ /// runPass - Run this pass, returning true if a modification was made to the
/// module argument. This should be implemented by all concrete subclasses.
///
- virtual bool run(Module &M) = 0;
+ virtual bool runPass(Module &M) = 0;
/// print - Print out the internal state of the pass. This is called by
/// Analyze to print out the contents of an analysis. Otherwise it is not
@@ -200,13 +200,27 @@ private:
friend class PassManagerT<Module>;
friend class PassManagerT<Function>;
friend class PassManagerT<BasicBlock>;
- virtual void addToPassManager(PassManagerT<Module> *PM, AnalysisUsage &AU);
};
inline std::ostream &operator<<(std::ostream &OS, const Pass &P) {
P.print(OS, 0); return OS;
}
+//===----------------------------------------------------------------------===//
+/// ModulePass class - This class is used to implement unstructured
+/// interprocedural optimizations and analyses. ModulePass's may do anything
+/// they want to the program.
+///
+struct ModulePass : public Pass {
+
+ /// runOnModule - Virtual method overriden by subclasses to process the module
+ /// being operated on.
+ virtual bool runOnModule(Module &M) = 0;
+
+ bool runPass(Module &M) { return runOnModule(M); }
+
+ virtual void addToPassManager(PassManagerT<Module> *PM, AnalysisUsage &AU);
+};
//===----------------------------------------------------------------------===//
@@ -214,7 +228,7 @@ inline std::ostream &operator<<(std::ostream &OS, const Pass &P) {
/// not need to be run. This is useful for things like target information and
/// "basic" versions of AnalysisGroups.
///
-struct ImmutablePass : public Pass {
+struct ImmutablePass : public ModulePass {
/// initializePass - This method may be overriden by immutable passes to allow
/// them to perform various initialization actions they require. This is
/// primarily because an ImmutablePass can "require" another ImmutablePass,
@@ -225,14 +239,13 @@ struct ImmutablePass : public Pass {
/// ImmutablePasses are never run.
///
- virtual bool run(Module &M) { return false; }
+ virtual bool runOnModule(Module &M) { return false; }
private:
friend class PassManagerT<Module>;
virtual void addToPassManager(PassManagerT<Module> *PM, AnalysisUsage &AU);
};
-
//===----------------------------------------------------------------------===//
/// FunctionPass class - This class is used to implement most global
/// optimizations. Optimizations should subclass this class if they meet the
@@ -242,7 +255,7 @@ private:
/// 2. Optimizing a function does not cause the addition or removal of any
/// functions in the module
///
-struct FunctionPass : public Pass {
+struct FunctionPass : public ModulePass {
/// doInitialization - Virtual method overridden by subclasses to do
/// any necessary per-module initialization.
///
@@ -258,10 +271,11 @@ struct FunctionPass : public Pass {
///
virtual bool doFinalization(Module &M) { return false; }
- /// run - On a module, we run this pass by initializing, ronOnFunction'ing
- /// once for every function in the module, then by finalizing.
+ /// runOnModule - On a module, we run this pass by initializing,
+ /// ronOnFunction'ing once for every function in the module, then by
+ /// finalizing.
///
- virtual bool run(Module &M);
+ virtual bool runOnModule(Module &M);
/// run - On a function, we simply initialize, run the function, then
/// finalize.
@@ -323,7 +337,7 @@ struct BasicBlockPass : public FunctionPass {
/// To run directly on the basic block, we initialize, runOnBasicBlock, then
/// finalize.
///
- bool run(BasicBlock &BB);
+ bool runPass(BasicBlock &BB);
private:
friend class PassManagerT<Function>;
diff --git a/include/llvm/PassManager.h b/include/llvm/PassManager.h
index b1d369b925..1b77c875d9 100644
--- a/include/llvm/PassManager.h
+++ b/include/llvm/PassManager.h
@@ -20,6 +20,7 @@
namespace llvm {
class Pass;
+class ModulePass;
class Module;
class ModuleProvider;
template<class UnitType> class PassManagerT;
diff --git a/lib/Analysis/AliasAnalysisCounter.cpp b/lib/Analysis/AliasAnalysisCounter.cpp
index 09fd6b9e0e..b17941fdec 100644
--- a/lib/Analysis/AliasAnalysisCounter.cpp
+++ b/lib/Analysis/AliasAnalysisCounter.cpp
@@ -18,7 +18,7 @@
using namespace llvm;
namespace {
- class AliasAnalysisCounter : public Pass, public AliasAnalysis {
+ class AliasAnalysisCounter : public ModulePass, public AliasAnalysis {
unsigned No, May, Must;
unsigned NoMR, JustRef, JustMod, MR;
const char *Name;
@@ -64,7 +64,7 @@ namespace {
}
}
- bool run(Module &M) {
+ bool runOnModule(Module &M) {
InitializeAliasAnalysis(this);
Name = dynamic_cast<Pass*>(&getAnalysis<AliasAnalysis>())->getPassName();
return false;
diff --git a/lib/Analysis/DataStructure/BottomUpClosure.cpp b/lib/Analysis/DataStructure/BottomUpClosure.cpp
index 4bc6fafcf6..bf4b01cfc1 100644
--- a/lib/Analysis/DataStructure/BottomUpClosure.cpp
+++ b/lib/Analysis/DataStructure/BottomUpClosure.cpp
@@ -35,7 +35,7 @@ using namespace DS;
// run - Calculate the bottom up data structure graphs for each function in the
// program.
//
-bool BUDataStructures::run(Module &M) {
+bool BUDataStructures::runOnModule(Module &M) {
LocalDataStructures &LocalDSA = getAnalysis<LocalDataStructures>();
GlobalsGraph = new DSGraph(LocalDSA.getGlobalsGraph());
GlobalsGraph->setPrintAuxCalls();
diff --git a/lib/Analysis/DataStructure/CompleteBottomUp.cpp b/lib/Analysis/DataStructure/CompleteBottomUp.cpp
index b2a0f4ba9b..ee111e9d8f 100644
--- a/lib/Analysis/DataStructure/CompleteBottomUp.cpp
+++ b/lib/Analysis/DataStructure/CompleteBottomUp.cpp
@@ -32,7 +32,7 @@ namespace {
// run - Calculate the bottom up data structure graphs for each function in the
// program.
//
-bool CompleteBUDataStructures::run(Module &M) {
+bool CompleteBUDataStructures::runOnModule(Module &M) {
BUDataStructures &BU = getAnalysis<BUDataStructures>();
GlobalsGraph = new DSGraph(BU.getGlobalsGraph());
GlobalsGraph->setPrintAuxCalls();
diff --git a/lib/Analysis/DataStructure/DataStructureAA.cpp b/lib/Analysis/DataStructure/DataStructureAA.cpp
index 3cff79526f..6444cc8aeb 100644
--- a/lib/Analysis/DataStructure/DataStructureAA.cpp
+++ b/lib/Analysis/DataStructure/DataStructureAA.cpp
@@ -19,7 +19,7 @@
using namespace llvm;
namespace {
- class DSAA : public Pass, public AliasAnalysis {
+ class DSAA : public ModulePass, public AliasAnalysis {
TDDataStructures *TD;
BUDataStructures *BU;
public:
@@ -32,7 +32,7 @@ namespace {
// run - Build up the result graph, representing the pointer graph for the
// program.
//
- bool run(Module &M) {
+ bool runOnModule(Module &M) {
InitializeAliasAnalysis(this);
TD = &getAnalysis<TDDataStructures>();
BU = &getAnalysis<BUDataStructures>();
diff --git a/lib/Analysis/DataStructure/DataStructureOpt.cpp b/lib/Analysis/DataStructure/DataStructureOpt.cpp
index f7a1ed9af3..1996aea67d 100644
--- a/lib/Analysis/DataStructure/DataStructureOpt.cpp
+++ b/lib/Analysis/DataStructure/DataStructureOpt.cpp
@@ -25,10 +25,10 @@ namespace {
Statistic<>
NumGlobalsIsolated("ds-opt", "Number of globals with references dropped");
- class DSOpt : public Pass {
+ class DSOpt : public ModulePass {
TDDataStructures *TD;
public:
- bool run(Module &M) {
+ bool runOnModule(Module &M) {
TD = &getAnalysis<TDDataStructures>();
bool Changed = OptimizeGlobals(M);
return Changed;
diff --git a/lib/Analysis/DataStructure/IPModRef.cpp b/lib/Analysis/DataStructure/IPModRef.cpp
index ccc15f74e4..6793b0ecdb 100644
--- a/lib/Analysis/DataStructure/IPModRef.cpp
+++ b/lib/Analysis/DataStructure/IPModRef.cpp
@@ -374,7 +374,7 @@ void IPModRef::releaseMemory()
// NO real interprocedural work because all that has been done the
// data structure analysis.
//
-bool IPModRef::run(Module &theModule)
+bool IPModRef::runOnModule(Module &theModule)
{
M = &theModule;
diff --git a/lib/Analysis/DataStructure/IPModRef.h b/lib/Analysis/DataStructure/IPModRef.h
index 4a825dbea3..f8ac15c1be 100644
--- a/lib/Analysis/DataStructure/IPModRef.h
+++ b/lib/Analysis/DataStructure/IPModRef.h
@@ -183,7 +183,7 @@ public:
/// from an arbitrary callsite, or during an execution of a single call-site
/// within the function.
///
-class IPModRef : public Pass {
+class IPModRef : public ModulePass {
std::map<const Function*, FunctionModRefInfo*> funcToModRefInfoMap;
Module* M;
@@ -197,7 +197,7 @@ public:
/// This initializes the module reference, and then computes IPModRef
/// results immediately if demand-driven analysis was *not* specified.
///
- virtual bool run(Module &M);
+ virtual bool runOnModule(Module &M);
/// getFunctionModRefInfo - Retrieve the Mod/Ref information for a single
/// function
diff --git a/lib/Analysis/DataStructure/Local.cpp b/lib/Analysis/DataStructure/Local.cpp