mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-29 22:30:33 +00:00
'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. llvm-svn: 16436
This commit is contained in:
parent
3acc541d97
commit
43c0372c0b
@ -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 {
|
||||
|
@ -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();
|
||||
|
@ -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.
|
||||
///
|
||||
|
@ -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 {
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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>;
|
||||
|
@ -20,6 +20,7 @@
|
||||
namespace llvm {
|
||||
|
||||
class Pass;
|
||||
class ModulePass;
|
||||
class Module;
|
||||
class ModuleProvider;
|
||||
template<class UnitType> class PassManagerT;
|
||||
|
@ -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;
|
||||
|
@ -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();
|
||||
|
@ -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();
|
||||
|
@ -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>();
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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
|
||||
|
@ -1023,7 +1023,7 @@ void GraphBuilder::mergeInGlobalInitializer(GlobalVariable *GV) {
|
||||
}
|
||||
|
||||
|
||||
bool LocalDataStructures::run(Module &M) {
|
||||
bool LocalDataStructures::runOnModule(Module &M) {
|
||||
GlobalsGraph = new DSGraph(getAnalysis<TargetData>());
|
||||
|
||||
const TargetData &TD = getAnalysis<TargetData>();
|
||||
|
@ -457,7 +457,7 @@ bool MemoryDepAnalysis::runOnFunction(Function &F) {
|
||||
// Driver function to compute dependence graphs for every function.
|
||||
// This is temporary and will go away once this is a FunctionPass.
|
||||
//
|
||||
bool MemoryDepAnalysis::run(Module& M)
|
||||
bool MemoryDepAnalysis::runOnModule(Module& M)
|
||||
{
|
||||
for (Module::iterator FI = M.begin(), FE = M.end(); FI != FE; ++FI)
|
||||
if (! FI->isExternal())
|
||||
|
@ -40,7 +40,7 @@ class FunctionModRefInfo;
|
||||
/// allowed to use a FunctionPass such as this one.
|
||||
///---------------------------------------------------------------------------
|
||||
|
||||
class MemoryDepAnalysis : public Pass {
|
||||
class MemoryDepAnalysis : public ModulePass {
|
||||
/// The following map and depGraph pointer are temporary until this class
|
||||
/// becomes a FunctionPass instead of a module Pass.
|
||||
hash_map<Function*, DependenceGraph*> funcMap;
|
||||
@ -63,7 +63,7 @@ public:
|
||||
|
||||
/// Driver function to compute dependence graphs for every function.
|
||||
///
|
||||
bool run(Module &M);
|
||||
bool runOnModule(Module &M);
|
||||
|
||||
/// getGraph - Retrieve the dependence graph for a function.
|
||||
/// This is temporary and will go away once this is a FunctionPass.
|
||||
|
@ -388,11 +388,11 @@ void FindParallelCalls::visitCallInst(CallInst& CI) {
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
namespace {
|
||||
class Parallelize: public Pass {
|
||||
class Parallelize : public ModulePass {
|
||||
public:
|
||||
/// Driver functions to transform a program
|
||||
///
|
||||
bool run(Module& M);
|
||||
bool runOnModule(Module& M);
|
||||
|
||||
/// getAnalysisUsage - Modifies extensively so preserve nothing.
|
||||
/// Uses the DependenceGraph and the Top-down DS Graph (only to find
|
||||
@ -409,7 +409,7 @@ namespace {
|
||||
}
|
||||
|
||||
|
||||
bool Parallelize::run(Module& M) {
|
||||
bool Parallelize::runOnModule(Module& M) {
|
||||
hash_set<Function*> parallelFunctions;
|
||||
hash_set<Function*> safeParallelFunctions;
|
||||
hash_set<const GlobalValue*> indirectlyCalled;
|
||||
|
@ -200,7 +200,7 @@ public:
|
||||
/// allowed to use a FunctionPass such as this one.
|
||||
///---------------------------------------------------------------------------
|
||||
|
||||
class PgmDependenceGraph: public Pass {
|
||||
class PgmDependenceGraph: public ModulePass {
|
||||
|
||||
/// Information about the function being analyzed.
|
||||
///
|
||||
@ -253,7 +253,7 @@ public:
|
||||
|
||||
/// Driver function to compute dependence graphs for every function.
|
||||
///
|
||||
bool run(Module& M) { return true; }
|
||||
bool runOnModule(Module& M) { return true; }
|
||||
|
||||
/// getGraph() -- Retrieve the pgm dependence graph for a function.
|
||||
/// This is temporary and will go away once this is a FunctionPass.
|
||||
|
@ -22,7 +22,7 @@
|
||||
using namespace llvm;
|
||||
|
||||
namespace {
|
||||
class Steens : public Pass, public AliasAnalysis {
|
||||
class Steens : public ModulePass, public AliasAnalysis {
|
||||
DSGraph *ResultGraph;
|
||||
DSGraph *GlobalsGraph; // FIXME: Eliminate globals graph stuff from DNE
|
||||
public:
|
||||
@ -39,7 +39,7 @@ namespace {
|
||||
// run - Build up the result graph, representing the pointer graph for the
|
||||
// program.
|
||||
//
|
||||
bool run(Module &M);
|
||||
bool runOnModule(Module &M);
|
||||
|
||||
virtual void releaseMyMemory() { delete ResultGraph; ResultGraph = 0; }
|
||||
|
||||
@ -103,7 +103,7 @@ void Steens::ResolveFunctionCall(Function *F, const DSCallSite &Call,
|
||||
/// run - Build up the result graph, representing the pointer graph for the
|
||||
/// program.
|
||||
///
|
||||
bool Steens::run(Module &M) {
|
||||
bool Steens::runOnModule(Module &M) {
|
||||
InitializeAliasAnalysis(this);
|
||||
assert(ResultGraph == 0 && "Result graph already allocated!");
|
||||
LocalDataStructures &LDS = getAnalysis<LocalDataStructures>();
|
||||
|
@ -51,7 +51,7 @@ void TDDataStructures::markReachableFunctionsExternallyAccessible(DSNode *N,
|
||||
// run - Calculate the top down data structure graphs for each function in the
|
||||
// program.
|
||||
//
|
||||
bool TDDataStructures::run(Module &M) {
|
||||
bool TDDataStructures::runOnModule(Module &M) {
|
||||
BUDataStructures &BU = getAnalysis<BUDataStructures>();
|
||||
GlobalsGraph = new DSGraph(BU.getGlobalsGraph());
|
||||
GlobalsGraph->setPrintAuxCalls();
|
||||
|
@ -75,7 +75,7 @@ namespace {
|
||||
Statistic<>
|
||||
NumIndirectCallees("anders-aa", "Number of indirect callees found");
|
||||
|
||||
class Andersens : public Pass, public AliasAnalysis,
|
||||
class Andersens : public ModulePass, public AliasAnalysis,
|
||||
private InstVisitor<Andersens> {
|
||||
/// Node class - This class is used to represent a memory object in the
|
||||
/// program, and is the primitive used to build the points-to graph.
|
||||
@ -193,7 +193,7 @@ namespace {
|
||||
};
|
||||
|
||||
public:
|
||||
bool run(Module &M) {
|
||||
bool runOnModule(Module &M) {
|
||||
InitializeAliasAnalysis(this);
|
||||
IdentifyObjects(M);
|
||||
CollectConstraints(M);
|
||||
|
@ -100,7 +100,7 @@ void CallGraph::addToCallGraph(Function *F) {
|
||||
}
|
||||
}
|
||||
|
||||
bool CallGraph::run(Module &M) {
|
||||
bool CallGraph::runOnModule(Module &M) {
|
||||
destroy();
|
||||
|
||||
Mod = &M;
|
||||
|
@ -28,7 +28,7 @@ void CallGraphSCCPass::getAnalysisUsage(AnalysisUsage &AU) const {
|
||||
AU.addPreserved<CallGraph>();
|
||||
}
|
||||
|
||||
bool CallGraphSCCPass::run(Module &M) {
|
||||
bool CallGraphSCCPass::runOnModule(Module &M) {
|
||||
CallGraph &CG = getAnalysis<CallGraph>();
|
||||
bool Changed = doInitialization(CG);
|
||||
for (scc_iterator<CallGraph*> I = scc_begin(&CG), E = scc_end(&CG);
|
||||
|
@ -58,7 +58,7 @@ static inline bool isSafeInstruction(const Instruction &I) {
|
||||
}
|
||||
|
||||
|
||||
bool FindUnsafePointerTypes::run(Module &Mod) {
|
||||
bool FindUnsafePointerTypes::runOnModule(Module &Mod) {
|
||||
for (Module::iterator FI = Mod.begin(), E = Mod.end();
|
||||
FI != E; ++FI) {
|
||||
const Function *F = FI; // We don't need/want write access
|
||||
|
@ -58,7 +58,7 @@ void FindUsedTypes::IncorporateValue(const Value *V) {
|
||||
|
||||
// run - This incorporates all types used by the specified module
|
||||
//
|
||||
bool FindUsedTypes::run(Module &m) {
|
||||
bool FindUsedTypes::runOnModule(Module &m) {
|
||||
UsedTypes.clear(); // reset if run multiple times...
|
||||
|
||||
// Loop over global variables, incorporating their types
|
||||
|
@ -67,7 +67,7 @@ namespace {
|
||||
};
|
||||
|
||||
/// GlobalsModRef - The actual analysis pass.
|
||||
class GlobalsModRef : public Pass, public AliasAnalysis {
|
||||
class GlobalsModRef : public ModulePass, public AliasAnalysis {
|
||||
/// NonAddressTakenGlobals - The globals that do not have their addresses
|
||||
/// taken.
|
||||
std::set<GlobalValue*> NonAddressTakenGlobals;
|
||||
@ -77,7 +77,7 @@ namespace {
|
||||
std::map<Function*, FunctionRecord> FunctionInfo;
|
||||
|
||||
public:
|
||||
bool run(Module &M) {
|
||||
bool runOnModule(Module &M) {
|
||||
InitializeAliasAnalysis(this); // set up super class
|
||||
AnalyzeGlobals(M); // find non-addr taken globals
|
||||
AnalyzeCallGraph(getAnalysis<CallGraph>(), M); // Propagate on CG
|
||||
|
@ -28,7 +28,7 @@ namespace {
|
||||
cl::value_desc("filename"),
|
||||
cl::desc("Profile file loaded by -profile-loader"));
|
||||
|
||||
class LoaderPass : public Pass, public ProfileInfo {
|
||||
class LoaderPass : public ModulePass, public ProfileInfo {
|
||||
std::string Filename;
|
||||
public:
|
||||
LoaderPass(const std::string &filename = "")
|
||||
@ -45,7 +45,7 @@ namespace {
|
||||
}
|
||||
|
||||
/// run - Load the profile information from the specified file.
|
||||
virtual bool run(Module &M);
|
||||
virtual bool runOnModule(Module &M);
|
||||
};
|
||||
|
||||
RegisterOpt<LoaderPass>
|
||||
@ -62,7 +62,7 @@ Pass *llvm::createProfileLoaderPass(const std::string &Filename) {
|
||||
return new LoaderPass(Filename);
|
||||
}
|
||||
|
||||
bool LoaderPass::run(Module &M) {
|
||||
bool LoaderPass::runOnModule(Module &M) {
|
||||
ProfileInfoLoader PIL("profile-loader", Filename, M);
|
||||
EdgeCounts.clear();
|
||||
bool PrintedWarning = false;
|
||||
|
@ -47,7 +47,7 @@ namespace {
|
||||
/// NameAllUsedStructs - This pass inserts names for any unnamed structure
|
||||
/// types that are used by the program.
|
||||
///
|
||||
class CBackendNameAllUsedStructs : public Pass {
|
||||
class CBackendNameAllUsedStructs : public ModulePass {
|
||||
void getAnalysisUsage(AnalysisUsage &AU) const {
|
||||
AU.addRequired<FindUsedTypes>();
|
||||
}
|
||||
@ -56,7 +56,7 @@ namespace {
|
||||
return "C backend type canonicalizer";
|
||||
}
|
||||
|
||||
virtual bool run(Module &M);
|
||||
virtual bool runOnModule(Module &M);
|
||||
};
|
||||
|
||||
/// CWriter - This class is the main chunk of code that converts an LLVM
|
||||
@ -216,7 +216,7 @@ namespace {
|
||||
/// the program, and removes names from structure types that are not used by the
|
||||
/// program.
|
||||
///
|
||||
bool CBackendNameAllUsedStructs::run(Module &M) {
|
||||
bool CBackendNameAllUsedStructs::runOnModule(Module &M) {
|
||||
// Get a set of types that are used by the program...
|
||||
std::set<const Type *> UT = getAnalysis<FindUsedTypes>().getTypes();
|
||||
|
||||
|
@ -17,10 +17,7 @@
|
||||
#include "llvm/Pass.h"
|
||||
#include "llvm/Bytecode/Writer.h"
|
||||
#include <iostream>
|
||||
|
||||
namespace llvm {
|
||||
|
||||
using std::ostream;
|
||||
using namespace llvm;
|
||||
|
||||
namespace {
|
||||
|
||||
@ -87,14 +84,14 @@ namespace {
|
||||
}
|
||||
|
||||
// SparcV9BytecodeWriter - Write bytecode out to a stream that is sparc'ified
|
||||
class SparcV9BytecodeWriter : public Pass {
|
||||
class SparcV9BytecodeWriter : public ModulePass {
|
||||
std::ostream &Out;
|
||||
public:
|
||||
SparcV9BytecodeWriter(std::ostream &out) : Out(out) {}
|
||||
|
||||
const char *getPassName() const { return "Emit Bytecode to SparcV9 Assembly";}
|
||||
|
||||
virtual bool run(Module &M) {
|
||||
virtual bool runOnModule(Module &M) {
|
||||
// Write an object containing the bytecode to the SPARC assembly stream
|
||||
writePrologue (Out, "LLVM BYTECODE OUTPUT", "LLVMBytecode");
|
||||
osparcasmstream OS(Out);
|
||||
@ -112,8 +109,7 @@ namespace {
|
||||
};
|
||||
} // end anonymous namespace
|
||||
|
||||
Pass *createBytecodeAsmPrinterPass(std::ostream &Out) {
|
||||
ModulePass *llvm::createBytecodeAsmPrinterPass(std::ostream &Out) {
|
||||
return new SparcV9BytecodeWriter(Out);
|
||||
}
|
||||
|
||||
} // End llvm namespace
|
||||
|
@ -27,13 +27,13 @@ namespace llvm {
|
||||
|
||||
typedef std::vector<Constant *> GVVectorTy;
|
||||
|
||||
class InternalGlobalMapper : public Pass {
|
||||
class InternalGlobalMapper : public ModulePass {
|
||||
public:
|
||||
bool run (Module &M);
|
||||
bool runOnModule(Module &M);
|
||||
};
|
||||
|
||||
Pass *llvm::createInternalGlobalMapperPass () {
|
||||
return new InternalGlobalMapper ();
|
||||
ModulePass *llvm::createInternalGlobalMapperPass() {
|
||||
return new InternalGlobalMapper();
|
||||
}
|
||||
|
||||
static void maybeAddInternalValueToVector (GVVectorTy &Vector, GlobalValue &GV){
|
||||
@ -41,14 +41,14 @@ static void maybeAddInternalValueToVector (GVVectorTy &Vector, GlobalValue &GV){
|
||||
// be mangled), then put the GV, casted to sbyte*, in the vector. Otherwise
|
||||
// add a null.
|
||||
if (GV.hasInternalLinkage () && GV.hasName ())
|
||||
Vector.push_back (ConstantExpr::getCast
|
||||
(&GV, PointerType::get (Type::SByteTy)));
|
||||
Vector.push_back(ConstantExpr::getCast(&GV,
|
||||
PointerType::get(Type::SByteTy)));
|
||||
else
|
||||
Vector.push_back (ConstantPointerNull::get (PointerType::get
|
||||
(Type::SByteTy)));
|
||||
}
|
||||
|
||||
bool InternalGlobalMapper::run (Module &M) {
|
||||
bool InternalGlobalMapper::runOnModule(Module &M) {
|
||||
GVVectorTy gvvector;
|
||||
|
||||
// Populate the vector with internal global values and their names.
|
||||
|
@ -78,8 +78,8 @@ namespace {
|
||||
/// MappingInfoAsmPrinter Pass object, which uses OUT as its output
|
||||
/// stream for assembly output.
|
||||
///
|
||||
Pass *getMappingInfoAsmPrinterPass(std::ostream &out){
|
||||
return (new MappingInfoAsmPrinter(out));
|
||||
ModulePass *getMappingInfoAsmPrinterPass(std::ostream &out){
|
||||
return new MappingInfoAsmPrinter(out);
|
||||
}
|
||||
|
||||
/// runOnFunction - Builds up the maps for the given function FI and then
|
||||
|
@ -21,10 +21,10 @@
|
||||
|
||||
namespace llvm {
|
||||
|
||||
class Pass;
|
||||
class ModulePass;
|
||||
|
||||
Pass *getMappingInfoAsmPrinterPass(std::ostream &out);
|
||||
Pass *createInternalGlobalMapperPass();
|
||||
ModulePass *getMappingInfoAsmPrinterPass(std::ostream &out);
|
||||
ModulePass *createInternalGlobalMapperPass();
|
||||
|
||||
class MappingInfo {
|
||||
struct byteVector : public std::vector <unsigned char> {
|
||||
|
@ -28,7 +28,7 @@ namespace llvm {
|
||||
|
||||
class LiveRange;
|
||||
class SparcV9TargetMachine;
|
||||
class Pass;
|
||||
class ModulePass;
|
||||
|
||||
enum SparcV9InstrSchedClass {
|
||||
SPARC_NONE, /* Instructions with no scheduling restrictions */
|
||||
@ -91,7 +91,7 @@ protected:
|
||||
/// createStackSlotsPass - External interface to stack-slots pass that enters 2
|
||||
/// empty slots at the top of each function stack
|
||||
///
|
||||
Pass *createStackSlotsPass(const TargetMachine &TM);
|
||||
FunctionPass *createStackSlotsPass(const TargetMachine &TM);
|
||||
|
||||
/// Specializes LLVM code for a target machine.
|
||||
///
|
||||
@ -111,7 +111,7 @@ FunctionPass* createPrologEpilogInsertionPass();
|
||||
|
||||
/// getBytecodeAsmPrinterPass - Emits final LLVM bytecode to assembly file.
|
||||
///
|
||||
Pass* createBytecodeAsmPrinterPass(std::ostream &Out);
|
||||
ModulePass* createBytecodeAsmPrinterPass(std::ostream &Out);
|
||||
|
||||
FunctionPass *createSparcV9MachineCodeDestructionPass();
|
||||
|
||||
|
@ -46,7 +46,7 @@ namespace {
|
||||
};
|
||||
}
|
||||
|
||||
Pass *llvm::createStackSlotsPass(const TargetMachine &Target) {
|
||||
FunctionPass *llvm::createStackSlotsPass(const TargetMachine &Target) {
|
||||
return new StackSlots(Target);
|
||||
}
|
||||
|
||||
|
@ -75,7 +75,7 @@ namespace {
|
||||
"Promote 'by reference' arguments to scalars");
|
||||
}
|
||||
|
||||
Pass *llvm::createArgumentPromotionPass() {
|
||||
ModulePass *llvm::createArgumentPromotionPass() {
|
||||
return new ArgPromotion();
|
||||
}
|
||||
|
||||
|
@ -26,19 +26,19 @@ using namespace llvm;
|
||||
namespace {
|
||||
Statistic<> NumMerged("constmerge", "Number of global constants merged");
|
||||
|
||||
struct ConstantMerge : public Pass {
|
||||
struct ConstantMerge : public ModulePass {
|
||||
// run - For this pass, process all of the globals in the module,
|
||||
// eliminating duplicate constants.
|
||||
//
|
||||
bool run(Module &M);
|
||||
bool runOnModule(Module &M);
|
||||
};
|
||||
|
||||
RegisterOpt<ConstantMerge> X("constmerge","Merge Duplicate Global Constants");
|
||||
}
|
||||
|
||||
Pass *llvm::createConstantMergePass() { return new ConstantMerge(); }
|
||||
ModulePass *llvm::createConstantMergePass() { return new ConstantMerge(); }
|
||||
|
||||
bool ConstantMerge::run(Module &M) {
|
||||
bool ConstantMerge::runOnModule(Module &M) {
|
||||
std::map<Constant*, GlobalVariable*> CMap;
|
||||
|
||||
// Replacements - This vector contains a list of replacements to perform.
|
||||
|
@ -38,7 +38,7 @@ namespace {
|
||||
|
||||
/// DAE - The dead argument elimination pass.
|
||||
///
|
||||
class DAE : public Pass {
|
||||
class DAE : public ModulePass {
|
||||
/// Liveness enum - During our initial pass over the program, we determine
|
||||
/// that things are either definately alive, definately dead, or in need of
|
||||
/// interprocedural analysis (MaybeLive).
|
||||
@ -75,7 +75,7 @@ namespace {
|
||||
std::multimap<Function*, CallSite> CallSites;
|
||||
|
||||
public:
|
||||
bool run(Module &M);
|
||||
bool runOnModule(Module &M);
|
||||
|
||||
virtual bool ShouldHackArguments() const { return false; }
|
||||
|
||||
@ -106,8 +106,8 @@ namespace {
|
||||
/// createDeadArgEliminationPass - This pass removes arguments from functions
|
||||
/// which are not used by the body of the function.
|
||||
///
|
||||
Pass *llvm::createDeadArgEliminationPass() { return new DAE(); }
|
||||
Pass *llvm::createDeadArgHackingPass() { return new DAH(); }
|
||||
ModulePass *llvm::createDeadArgEliminationPass() { return new DAE(); }
|
||||
ModulePass *llvm::createDeadArgHackingPass() { return new DAH(); }
|
||||
|
||||
static inline bool CallPassesValueThoughVararg(Instruction *Call,
|
||||
const Value *Arg) {
|
||||
@ -484,7 +484,7 @@ void DAE::RemoveDeadArgumentsFromFunction(Function *F) {
|
||||
F->getParent()->getFunctionList().erase(F);
|
||||
}
|
||||
|
||||
bool DAE::run(Module &M) {
|
||||
bool DAE::runOnModule(Module &M) {
|
||||
// First phase: loop through the module, determining which arguments are live.
|
||||
// We assume all arguments are dead unless proven otherwise (allowing us to
|
||||
// determine that dead arguments passed into recursive functions are dead).
|
||||
|
@ -21,14 +21,14 @@
|
||||
using namespace llvm;
|
||||
|
||||
namespace {
|
||||
struct DTE : public Pass {
|
||||
struct DTE : public ModulePass {
|
||||
// doPassInitialization - For this pass, it removes global symbol table
|
||||
// entries for primitive types. These are never used for linking in GCC and
|
||||
// they make the output uglier to look at, so we nuke them.
|
||||
//
|
||||
// Also, initialize instance variables.
|
||||
//
|
||||
bool run(Module &M);
|
||||
bool runOnModule(Module &M);
|
||||
|
||||
// getAnalysisUsage - This function needs FindUsedTypes to do its job...
|
||||
//
|
||||
@ -41,7 +41,7 @@ namespace {
|
||||
NumKilled("deadtypeelim", "Number of unused typenames removed from symtab");
|
||||
}
|
||||
|
||||
Pass *llvm::createDeadTypeEliminationPass() {
|
||||
ModulePass *llvm::createDeadTypeEliminationPass() {
|
||||
return new DTE();
|
||||
}
|
||||
|
||||
@ -65,7 +65,7 @@ static inline bool ShouldNukeSymtabEntry(const Type *Ty){
|
||||
// uglier to look at, so we nuke them. Also eliminate types that are never used
|
||||
// in the entire program as indicated by FindUsedTypes.
|
||||
//
|
||||
bool DTE::run(Module &M) {
|
||||
bool DTE::runOnModule(Module &M) {
|
||||
bool Changed = false;
|
||||
|
||||
SymbolTable &ST = M.getSymbolTable();
|
||||
|
@ -17,7 +17,7 @@
|
||||
using namespace llvm;
|
||||
|
||||
namespace {
|
||||
class FunctionExtractorPass : public Pass {
|
||||
class FunctionExtractorPass : public ModulePass {
|
||||
Function *Named;
|
||||
bool deleteFunc;
|
||||
public:
|
||||
@ -28,7 +28,7 @@ namespace {
|
||||
FunctionExtractorPass(Function *F = 0, bool deleteFn = true)
|
||||
: Named(F), deleteFunc(deleteFn) {}
|
||||
|
||||
bool run(Module &M) {
|
||||
bool runOnModule(Module &M) {
|
||||
if (Named == 0) {
|
||||
Named = M.getMainFunction();
|
||||
if (Named == 0) return false; // No function to extract
|
||||
@ -112,6 +112,6 @@ namespace {
|
||||
RegisterPass<FunctionExtractorPass> X("extract", "Function Extractor");
|
||||
}
|
||||
|
||||
Pass *llvm::createFunctionExtractionPass(Function *F, bool deleteFn) {
|
||||
ModulePass *llvm::createFunctionExtractionPass(Function *F, bool deleteFn) {
|
||||
return new FunctionExtractorPass(F, deleteFn);
|
||||
}
|
||||
|
@ -35,17 +35,17 @@ namespace {
|
||||
Statistic<>NumResolved("funcresolve", "Number of varargs functions resolved");
|
||||
Statistic<> NumGlobals("funcresolve", "Number of global variables resolved");
|
||||
|
||||
struct FunctionResolvingPass : public Pass {
|
||||
struct FunctionResolvingPass : public ModulePass {
|
||||
virtual void getAnalysisUsage(AnalysisUsage &AU) const {
|
||||
AU.addRequired<TargetData>();
|
||||
}
|
||||
|
||||
bool run(Module &M);
|
||||
bool runOnModule(Module &M);
|
||||
};
|
||||
RegisterOpt<FunctionResolvingPass> X("funcresolve", "Resolve Functions");
|
||||
}
|
||||
|
||||
Pass *llvm::createFunctionResolvingPass() {
|
||||
ModulePass *llvm::createFunctionResolvingPass() {
|
||||
return new FunctionResolvingPass();
|
||||
}
|
||||
|
||||
@ -293,7 +293,7 @@ static bool ProcessGlobalsWithSameName(Module &M, TargetData &TD,
|
||||
return false;
|
||||
}
|
||||
|
||||
bool FunctionResolvingPass::run(Module &M) {
|
||||
bool FunctionResolvingPass::runOnModule(Module &M) {
|
||||
std::map<std::string, std::vector<GlobalValue*> > Globals;
|
||||
|
||||
// Loop over the globals, adding them to the Globals map. We use a two pass
|
||||
|
@ -31,14 +31,14 @@ using namespace llvm;
|
||||
namespace {
|
||||
Statistic<> NumMarked("constify", "Number of globals marked constant");
|
||||
|
||||
struct Constifier : public Pass {
|
||||
bool run(Module &M);
|
||||
struct Constifier : public ModulePass {
|
||||
bool runOnModule(Module &M);
|
||||
};
|
||||
|
||||
RegisterOpt<Constifier> X("constify", "Global Constifier");
|
||||
}
|
||||
|
||||
Pass *llvm::createGlobalConstifierPass() { return new Constifier(); }
|
||||
ModulePass *llvm::createGlobalConstifierPass() { return new Constifier(); }
|
||||
|
||||
/// A lot of global constants are stored only in trivially dead setter
|
||||
/// functions. Because we don't want to cycle between globaldce and this pass,
|
||||
@ -81,7 +81,7 @@ static bool isStoredThrough(Value *V, std::set<PHINode*> &PHIUsers) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Constifier::run(Module &M) {
|
||||
bool Constifier::runOnModule(Module &M) {
|
||||
bool Changed = false;
|
||||
std::set<PHINode*> PHIUsers;
|
||||
for (Module::giterator GV = M.gbegin(), E = M.gend(); GV != E; ++GV)
|
||||
|
@ -27,11 +27,11 @@ namespace {
|
||||
Statistic<> NumFunctions("globaldce","Number of functions removed");
|
||||
Statistic<> NumVariables("globaldce","Number of global variables removed");
|
||||
|
||||
struct GlobalDCE : public Pass {
|
||||
struct GlobalDCE : public ModulePass {
|
||||
// run - Do the GlobalDCE pass on the specified module, optionally updating
|
||||
// the specified callgraph to reflect the changes.
|
||||
//
|
||||
bool run(Module &M);
|
||||
bool runOnModule(Module &M);
|
||||
|
||||
private:
|
||||
std::set<GlobalValue*> AliveGlobals;
|
||||
@ -47,9 +47,9 @@ namespace {
|
||||
RegisterOpt<GlobalDCE> X("globaldce", "Dead Global Elimination");
|
||||
}
|
||||
|
||||
Pass *llvm::createGlobalDCEPass() { return new GlobalDCE(); }
|
||||
ModulePass *llvm::createGlobalDCEPass() { return new GlobalDCE(); }
|
||||
|
||||
bool GlobalDCE::run(Module &M) {
|
||||
bool GlobalDCE::runOnModule(Module &M) {
|
||||
bool Changed = false;
|
||||
// Loop over the module, adding globals which are obviously necessary.
|
||||
for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I) {
|
||||
|
@ -29,17 +29,17 @@ namespace {
|
||||
|
||||
/// IPCP - The interprocedural constant propagation pass
|
||||
///
|
||||
struct IPCP : public Pass {
|
||||
bool run(Module &M);
|
||||
struct IPCP : public ModulePass {
|
||||
bool runOnModule(Module &M);
|
||||
private:
|
||||
bool processFunction(Function &F);
|
||||
};
|
||||
RegisterOpt<IPCP> X("ipconstprop", "Interprocedural constant propagation");
|
||||
}
|
||||
|
||||
Pass *llvm::createIPConstantPropagationPass() { return new IPCP(); }
|
||||
ModulePass *llvm::createIPConstantPropagationPass() { return new IPCP(); }
|
||||
|
||||
bool IPCP::run(Module &M) {
|
||||
bool IPCP::runOnModule(Module &M) {
|
||||
bool Changed = false;
|
||||
bool LocalChange = true;
|
||||
|
||||
|
@ -66,7 +66,7 @@ namespace {
|
||||
RegisterOpt<SimpleInliner> X("inline", "Function Integration/Inlining");
|
||||
}
|
||||
|
||||
Pass *llvm::createFunctionInliningPass() { return new SimpleInliner(); }
|
||||
ModulePass *llvm::createFunctionInliningPass() { return new SimpleInliner(); }
|
||||
|
||||
// CountCodeReductionForConstant - Figure out an approximation for how many
|
||||
// instructions will be constant folded if the specified value is constant.
|
||||
|
@ -39,7 +39,7 @@ namespace {
|
||||
cl::desc("A list of symbol names to preserve"),
|
||||
cl::CommaSeparated);
|
||||
|
||||
class InternalizePass : public Pass {
|
||||
class InternalizePass : public ModulePass {
|
||||
std::set<std::string> ExternalNames;
|
||||
public:
|
||||
InternalizePass() {
|
||||
@ -65,7 +65,7 @@ namespace {
|
||||
}
|
||||
}
|
||||
|
||||
virtual bool run(Module &M) {
|
||||
virtual bool runOnModule(Module &M) {
|
||||
// If no list or file of symbols was specified, check to see if there is a
|
||||
// "main" symbol defined in the module. If so, use it, otherwise do not
|
||||
// internalize the module, it must be a library or something.
|
||||
@ -117,6 +117,6 @@ namespace {
|
||||
RegisterOpt<InternalizePass> X("internalize", "Internalize Global Symbols");
|
||||
} // end anonymous namespace
|
||||
|
||||
Pass *llvm::createInternalizePass() {
|
||||
ModulePass *llvm::createInternalizePass() {
|
||||
return new InternalizePass();
|
||||
}
|
||||
|
@ -126,7 +126,7 @@ bool LoopExtractor::runOnFunction(Function &F) {
|
||||
// createSingleLoopExtractorPass - This pass extracts one natural loop from the
|
||||
// program into a function if it can. This is used by bugpoint.
|
||||
//
|
||||
Pass *llvm::createSingleLoopExtractorPass() {
|
||||
ModulePass *llvm::createSingleLoopExtractorPass() {
|
||||
return new SingleLoopExtractor();
|
||||
}
|
||||
|
||||
@ -135,13 +135,13 @@ namespace {
|
||||
/// BlockExtractorPass - This pass is used by bugpoint to extract all blocks
|
||||
/// from the module into their own functions except for those specified by the
|
||||
/// BlocksToNotExtract list.
|
||||
class BlockExtractorPass : public Pass {
|
||||
class BlockExtractorPass : public ModulePass {
|
||||
std::vector<BasicBlock*> BlocksToNotExtract;
|
||||
public:
|
||||
BlockExtractorPass(std::vector<BasicBlock*> &B) : BlocksToNotExtract(B) {}
|
||||
BlockExtractorPass() {}
|
||||
|
||||
bool run(Module &M);
|
||||
bool runOnModule(Module &M);
|
||||
};
|
||||
RegisterOpt<BlockExtractorPass>
|
||||
XX("extract-blocks", "Extract Basic Blocks From Module (for bugpoint use)");
|
||||
@ -150,11 +150,11 @@ namespace {
|
||||
// createBlockExtractorPass - This pass extracts all blocks (except those
|
||||
// specified in the argument list) from the functions in the module.
|
||||
//
|
||||
Pass *llvm::createBlockExtractorPass(std::vector<BasicBlock*> &BTNE) {
|
||||
ModulePass *llvm::createBlockExtractorPass(std::vector<BasicBlock*> &BTNE) {
|
||||
return new BlockExtractorPass(BTNE);
|
||||
}
|
||||
|
||||
bool BlockExtractorPass::run(Module &M) {
|
||||
bool BlockExtractorPass::runOnModule(Module &M) {
|
||||
std::set<BasicBlock*> TranslatedBlocksToNotExtract;
|
||||
for (unsigned i = 0, e = BlocksToNotExtract.size(); i != e; ++i) {
|
||||
BasicBlock *BB = BlocksToNotExtract[i];
|
||||
|
@ -64,7 +64,7 @@ namespace {
|
||||
// class because it works on a module as a whole, not a function at a
|
||||
// time.
|
||||
|
||||
class LowerSetJmp : public Pass,
|
||||
class LowerSetJmp : public ModulePass,
|
||||
public InstVisitor<LowerSetJmp> {
|
||||
// LLVM library functions...
|
||||
Function* InitSJMap; // __llvm_sjljeh_init_setjmpmap
|
||||
@ -119,7 +119,7 @@ namespace {
|
||||
void visitReturnInst(ReturnInst& RI);
|
||||
void visitUnwindInst(UnwindInst& UI);
|
||||
|
||||
bool run(Module& M);
|
||||
bool runOnModule(Module& M);
|
||||
bool doInitialization(Module& M);
|
||||
};
|
||||
|
||||
@ -129,8 +129,7 @@ namespace {
|
||||
// run - Run the transformation on the program. We grab the function
|
||||
// prototypes for longjmp and setjmp. If they are used in the program,
|
||||
// then we can go directly to the places they're at and transform them.
|
||||
bool LowerSetJmp::run(Module& M)
|
||||
{
|
||||
bool LowerSetJmp::runOnModule(Module& M) {
|
||||
bool Changed = false;
|
||||
|
||||
// These are what the functions are called.
|
||||
@ -509,8 +508,7 @@ void LowerSetJmp::visitInvokeInst(InvokeInst& II)
|
||||
|
||||
// visitReturnInst - We want to destroy the setjmp map upon exit from the
|
||||
// function.
|
||||
void LowerSetJmp::visitReturnInst(ReturnInst& RI)
|
||||
{
|
||||
void LowerSetJmp::visitReturnInst(ReturnInst &RI) {
|
||||
Function* Func = RI.getParent()->getParent();
|
||||
new CallInst(DestroySJMap, make_vector<Value*>(GetSetJmpMap(Func), 0),
|
||||
"", &RI);
|
||||
@ -518,15 +516,13 @@ void LowerSetJmp::visitReturnInst(ReturnInst& RI)
|
||||
|
||||
// visitUnwindInst - We want to destroy the setjmp map upon exit from the
|
||||
// function.
|
||||
void LowerSetJmp::visitUnwindInst(UnwindInst& UI)
|
||||
{
|
||||
void LowerSetJmp::visitUnwindInst(UnwindInst &UI) {
|
||||
Function* Func = UI.getParent()->getParent();
|
||||
new CallInst(DestroySJMap, make_vector<Value*>(GetSetJmpMap(Func), 0),
|
||||
"", &UI);
|
||||
}
|
||||
|
||||
Pass* llvm::createLowerSetJmpPass()
|
||||
{
|
||||
ModulePass *llvm::createLowerSetJmpPass() {
|
||||
return new LowerSetJmp();
|
||||
}
|
||||
|
||||
|
@ -38,7 +38,7 @@ namespace {
|
||||
RegisterOpt<PruneEH> X("prune-eh", "Remove unused exception handling info");
|
||||
}
|
||||
|
||||
Pass *llvm::createPruneEHPass() { return new PruneEH(); }
|
||||
ModulePass *llvm::createPruneEHPass() { return new PruneEH(); }
|
||||
|
||||
|
||||
bool PruneEH::runOnSCC(const std::vector<CallGraphNode *> &SCC) {
|
||||
|
@ -28,7 +28,7 @@ namespace {
|
||||
// RaiseAllocations - Turn %malloc and %free calls into the appropriate
|
||||
// instruction.
|
||||
//
|
||||
class RaiseAllocations : public Pass {
|
||||
class RaiseAllocations : public ModulePass {
|
||||
Function *MallocFunc; // Functions in the module we are processing
|
||||
Function *FreeFunc; // Initialized by doPassInitializationVirt
|
||||
public:
|
||||
@ -41,7 +41,7 @@ namespace {
|
||||
|
||||
// run - This method does the actual work of converting instructions over.
|
||||
//
|
||||
bool run(Module &M);
|
||||
bool runOnModule(Module &M);
|
||||
};
|
||||
|
||||
RegisterOpt<RaiseAllocations>
|
||||
@ -50,7 +50,7 @@ namespace {
|
||||
|
||||
|
||||
// createRaiseAllocationsPass - The interface to this file...
|
||||
Pass *llvm::createRaiseAllocationsPass() {
|
||||
ModulePass *llvm::createRaiseAllocationsPass() {
|
||||
return new RaiseAllocations();
|
||||
}
|
||||
|
||||
@ -114,7 +114,7 @@ void RaiseAllocations::doInitialization(Module &M) {
|
||||
|
||||
// run - Transform calls into instructions...
|
||||
//
|
||||
bool RaiseAllocations::run(Module &M) {
|
||||
bool RaiseAllocations::runOnModule(Module &M) {
|
||||
// Find the malloc/free prototypes...
|
||||
doInitialization(M);
|
||||
|
||||
|
@ -29,15 +29,15 @@
|
||||
using namespace llvm;
|
||||
|
||||
namespace {
|
||||
class FunctionProfiler : public Pass {
|
||||
bool run(Module &M);
|
||||
class FunctionProfiler : public ModulePass {
|
||||
bool runOnModule(Module &M);
|
||||
};
|
||||
|
||||
RegisterOpt<FunctionProfiler> X("insert-function-profiling",
|
||||
"Insert instrumentation for function profiling");
|
||||
}
|
||||
|
||||
bool FunctionProfiler::run(Module &M) {
|
||||
bool FunctionProfiler::runOnModule(Module &M) {
|
||||
Function *Main = M.getMainFunction();
|
||||
if (Main == 0) {
|
||||
std::cerr << "WARNING: cannot insert function profiling into a module"
|
||||
@ -69,15 +69,15 @@ bool FunctionProfiler::run(Module &M) {
|
||||
|
||||
|
||||
namespace {
|
||||
class BlockProfiler : public Pass {
|
||||
bool run(Module &M);
|
||||
class BlockProfiler : public ModulePass {
|
||||
bool runOnModule(Module &M);
|
||||
};
|
||||
|
||||
RegisterOpt<BlockProfiler> Y("insert-block-profiling",
|
||||
"Insert instrumentation for block profiling");
|
||||
}
|
||||
|
||||
bool BlockProfiler::run(Module &M) {
|
||||
bool BlockProfiler::runOnModule(Module &M) {
|
||||
Function *Main = M.getMainFunction();
|
||||
if (Main == 0) {
|
||||
std::cerr << "WARNING: cannot insert block profiling into a module"
|
||||
|
@ -28,15 +28,15 @@
|
||||
using namespace llvm;
|
||||
|
||||
namespace {
|
||||
class EdgeProfiler : public Pass {
|
||||
bool run(Module &M);
|
||||
class EdgeProfiler : public ModulePass {
|
||||
bool runOnModule(Module &M);
|
||||
};
|
||||
|
||||
RegisterOpt<EdgeProfiler> X("insert-edge-profiling",
|
||||
"Insert instrumentation for edge profiling");
|
||||
}
|
||||
|
||||
bool EdgeProfiler::run(Module &M) {
|
||||
bool EdgeProfiler::runOnModule(Module &M) {
|
||||
Function *Main = M.getMainFunction();
|
||||
if (Main == 0) {
|
||||
std::cerr << "WARNING: cannot insert edge profiling into a module"
|
||||
|
@ -27,8 +27,8 @@ namespace {
|
||||
BLACK
|
||||
};
|
||||
|
||||
struct EmitFunctionTable : public Pass {
|
||||
bool run(Module &M);
|
||||
struct EmitFunctionTable : public ModulePass {
|
||||
bool runOnModule(Module &M);
|
||||
};
|
||||
|
||||
RegisterOpt<EmitFunctionTable>
|
||||
@ -64,7 +64,7 @@ static char hasBackEdge(Function *F){
|
||||
}
|
||||
|
||||
// Per Module pass for inserting function table
|
||||
bool EmitFunctionTable::run(Module &M){
|
||||
bool EmitFunctionTable::runOnModule(Module &M){
|
||||
std::vector<const Type*> vType;
|
||||
|
||||
std::vector<Constant *> vConsts;
|
||||
|
@ -25,8 +25,8 @@
|
||||
using namespace llvm;
|
||||
|
||||
namespace {
|
||||
class TraceBasicBlocks : public Pass {
|
||||
bool run(Module &M);
|
||||
class TraceBasicBlocks : public ModulePass {
|
||||
bool runOnModule(Module &M);
|
||||
};
|
||||
|
||||
RegisterOpt<TraceBasicBlocks> X("trace-basic-blocks",
|
||||
@ -52,7 +52,7 @@ static void InsertInstrumentationCall (BasicBlock *BB,
|
||||
Instruction *InstrCall = new CallInst (InstrFn, Args, "", InsertPos);
|
||||
}
|
||||
|
||||
bool TraceBasicBlocks::run(Module &M) {
|
||||
bool TraceBasicBlocks::runOnModule(Module &M) {
|
||||
Function *Main = M.getMainFunction();
|
||||
if (Main == 0) {
|
||||
std::cerr << "WARNING: cannot insert basic-block trace instrumentation"
|
||||
|
@ -726,9 +726,9 @@ template<> struct PassManagerTraits<Function> : public FunctionPass {
|
||||
//
|
||||
// This is the top level PassManager implementation that holds generic passes.
|
||||
//
|
||||
template<> struct PassManagerTraits<Module> : public Pass {
|
||||
template<> struct PassManagerTraits<Module> : public ModulePass {
|
||||
// PassClass - The type of passes tracked by this PassManager
|
||||
typedef Pass PassClass;
|
||||
typedef ModulePass PassClass;
|
||||
|
||||
// SubPassClass - The types of classes that should be collated together
|
||||
typedef FunctionPass SubPassClass;
|
||||
@ -740,15 +740,15 @@ template<> struct PassManagerTraits<Module> : public Pass {
|
||||
typedef AnalysisResolver ParentClass;
|
||||
|
||||
// runPass - Specify how the pass should be run on the UnitType
|
||||
static bool runPass(PassClass *P, Module *M) { return P->run(*M); }
|
||||
static bool runPass(PassClass *P, Module *M) { return P->runOnModule(*M); }
|
||||
|
||||
// getPMName() - Return the name of the unit the PassManager operates on for
|
||||
// debugging.
|
||||
const char *getPMName() const { return "Module"; }
|
||||
virtual const char *getPassName() const { return "Module Pass Manager"; }
|
||||
|
||||
// run - Implement the PassManager interface...
|
||||
bool run(Module &M) {
|
||||
// runOnModule - Implement the PassManager interface.
|
||||
bool runOnModule(Module &M) {
|
||||
return ((PassManagerT<Module>*)this)->runOnUnit(&M);
|
||||
}
|
||||
};
|
||||
|
@ -28,8 +28,8 @@ namespace {
|
||||
/// external functions that are called with constant arguments. This can be
|
||||
/// useful when looking for standard library functions we should constant fold
|
||||
/// or handle in alias analyses.
|
||||
struct ExternalFunctionsPassedConstants : public Pass {
|
||||
virtual bool run(Module &M) {
|
||||
struct ExternalFunctionsPassedConstants : public ModulePass {
|
||||
virtual bool runOnModule(Module &M) {
|
||||
for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I)
|
||||
if (I->isExternal()) {
|
||||
bool PrintedFn = false;
|
||||
|
@ -58,8 +58,8 @@ namespace llvm {
|
||||
|
||||
|
||||
namespace {
|
||||
struct CallGraphPrinter : public Pass {
|
||||
virtual bool run(Module &M) {
|
||||
struct CallGraphPrinter : public ModulePass {
|
||||
virtual bool runOnModule(Module &M) {
|
||||
WriteGraphToFile(std::cerr, "callgraph", &getAnalysis<CallGraph>());
|
||||
return false;
|
||||
}
|
||||
|
@ -30,11 +30,11 @@
|
||||
|
||||
using namespace llvm;
|
||||
|
||||
struct ModulePassPrinter : public Pass {
|
||||
struct ModulePassPrinter : public ModulePass {
|
||||
const PassInfo *PassToPrint;
|
||||
ModulePassPrinter(const PassInfo *PI) : PassToPrint(PI) {}
|
||||
|
||||
virtual bool run(Module &M) {
|
||||
virtual bool runOnModule(Module &M) {
|
||||
std::cout << "Printing analysis '" << PassToPrint->getPassName() << "':\n";
|
||||
getAnalysisID<Pass>(PassToPrint).print(std::cout, &M);
|
||||
|
||||
|
@ -211,14 +211,14 @@ namespace {
|
||||
/// BlockExtractorPass - This pass is used by bugpoint to extract all blocks
|
||||
/// from the module into their own functions except for those specified by the
|
||||
/// BlocksToNotExtract list.
|
||||
class BlockExtractorPass : public Pass {
|
||||
bool run(Module &M);
|
||||
class BlockExtractorPass : public ModulePass {
|
||||
bool runOnModule(Module &M);
|
||||
};
|
||||
RegisterOpt<BlockExtractorPass>
|
||||
XX("extract-bbs", "Extract Basic Blocks From Module (for bugpoint use)");
|
||||
}
|
||||
|
||||
bool BlockExtractorPass::run(Module &M) {
|
||||
bool BlockExtractorPass::runOnModule(Module &M) {
|
||||
std::set<BasicBlock*> TranslatedBlocksToNotExtract;
|
||||
for (unsigned i = 0, e = BlocksToNotExtract.size(); i != e; ++i) {
|
||||
BasicBlock *BB = BlocksToNotExtract[i];
|
||||
|
Loading…
Reference in New Issue
Block a user