//===----------------------------------------------------------------------===//
// 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;
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 {
// 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();
/// 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;
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();
/// 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;
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();
/// 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();
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:
/// 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.
///
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
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 {
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:
if (DeleteStream) delete Out;
}
- bool run(Module &M) {
+ bool runOnModule(Module &M) {
(*Out) << M << std::flush;
return false;
}
namespace llvm {
-class WriteBytecodePass : public Pass {
+class WriteBytecodePass : public ModulePass {
std::ostream *Out; // ostream to print on
bool DeleteStream;
public:
if (DeleteStream) delete Out;
}
- bool run(Module &M) {
+ bool runOnModule(Module &M) {
WriteBytecodeToFile(&M, *Out);
return false;
}
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.
/// 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
///
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
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);
+};
//===----------------------------------------------------------------------===//
/// 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,
/// 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
/// 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.
///
///
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.
/// 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>;
namespace llvm {
class Pass;
+class ModulePass;
class Module;
class ModuleProvider;
template<class UnitType> class PassManagerT;
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;
}
}
- bool run(Module &M) {
+ bool runOnModule(Module &M) {
InitializeAliasAnalysis(this);
Name = dynamic_cast<Pass*>(&getAnalysis<AliasAnalysis>())->getPassName();
return false;
// 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();
// 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();
using namespace llvm;
namespace {
- class DSAA : public Pass, public AliasAnalysis {
+ class DSAA : public ModulePass, public AliasAnalysis {
TDDataStructures *TD;
BUDataStructures *BU;
public:
// 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>();
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;
// 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;
/// 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;
/// 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
}
-bool LocalDataStructures::run(Module &M) {
+bool LocalDataStructures::runOnModule(Module &M) {
GlobalsGraph = new DSGraph(getAnalysis<TargetData>());
const TargetData &TD = getAnalysis<TargetData>();
// 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())
/// 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;
/// 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.
//----------------------------------------------------------------------------
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
}
-bool Parallelize::run(Module& M) {
+bool Parallelize::runOnModule(Module& M) {
hash_set<Function*> parallelFunctions;
hash_set<Function*> safeParallelFunctions;
hash_set<const GlobalValue*> indirectlyCalled;
/// allowed to use a FunctionPass such as this one.
///---------------------------------------------------------------------------
-class PgmDependenceGraph: public Pass {
+class PgmDependenceGraph: public ModulePass {
/// Information about the function being analyzed.
///
/// 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.
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:
// 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; }
/// 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>();
// 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();
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.
};
public:
- bool run(Module &M) {
+ bool runOnModule(Module &M) {
InitializeAliasAnalysis(this);
IdentifyObjects(M);
CollectConstraints(M);
}
}
-bool CallGraph::run(Module &M) {
+bool CallGraph::runOnModule(Module &M) {
destroy();
Mod = &M;
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);
}
-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
// 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
};
/// 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;
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
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 = "")
}
/// run - Load the profile information from the specified file.
- virtual bool run(Module &M);
+ virtual bool runOnModule(Module &M);
};
RegisterOpt<LoaderPass>
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;
/// 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>();
}
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
/// 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();
/// 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>();
}
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
/// 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();
#include "llvm/Pass.h"
#include "llvm/Bytecode/Writer.h"
#include <iostream>
-
-namespace llvm {
-
-using std::ostream;
+using namespace llvm;
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);
};
} // end anonymous namespace
-Pass *createBytecodeAsmPrinterPass(std::ostream &Out) {
+ModulePass *llvm::createBytecodeAsmPrinterPass(std::ostream &Out) {
return new SparcV9BytecodeWriter(Out);
}
-} // End llvm namespace
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){
// 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.
/// 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
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> {
class LiveRange;
class SparcV9TargetMachine;
-class Pass;
+class ModulePass;
enum SparcV9InstrSchedClass {
SPARC_NONE, /* Instructions with no scheduling restrictions */
/// 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.
///
/// getBytecodeAsmPrinterPass - Emits final LLVM bytecode to assembly file.
///
-Pass* createBytecodeAsmPrinterPass(std::ostream &Out);
+ModulePass* createBytecodeAsmPrinterPass(std::ostream &Out);
FunctionPass *createSparcV9MachineCodeDestructionPass();
};
}
-Pass *llvm::createStackSlotsPass(const TargetMachine &Target) {
+FunctionPass *llvm::createStackSlotsPass(const TargetMachine &Target) {
return new StackSlots(Target);
}
"Promote 'by reference' arguments to scalars");
}
-Pass *llvm::createArgumentPromotionPass() {
+ModulePass *llvm::createArgumentPromotionPass() {
return new ArgPromotion();
}
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.
/// 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).
std::multimap<Function*, CallSite> CallSites;
public:
- bool run(Module &M);
+ bool runOnModule(Module &M);
virtual bool ShouldHackArguments() const { return false; }
/// 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) {
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).
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...
//
NumKilled("deadtypeelim", "Number of unused typenames removed from symtab");
}
-Pass *llvm::createDeadTypeEliminationPass() {
+ModulePass *llvm::createDeadTypeEliminationPass() {
return new DTE();
}
// 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();
using namespace llvm;
namespace {
- class FunctionExtractorPass : public Pass {
+ class FunctionExtractorPass : public ModulePass {
Function *Named;
bool deleteFunc;
public:
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
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);
}
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();
}
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
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;
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) {
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,
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)
/// 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;
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.
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() {
}
}
- 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.
RegisterOpt<InternalizePass> X("internalize", "Internalize Global Symbols");
} // end anonymous namespace
-Pass *llvm::createInternalizePass() {
+ModulePass *llvm::createInternalizePass() {
return new InternalizePass();
}
// 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();
}
/// 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)");
// 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];
// 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
void visitReturnInst(ReturnInst& RI);
void visitUnwindInst(UnwindInst& UI);
- bool run(Module& M);
+ bool runOnModule(Module& M);
bool doInitialization(Module& M);
};
// 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.
// 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);
// 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();
}
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) {
// 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:
// run - This method does the actual work of converting instructions over.
//
- bool run(Module &M);
+ bool runOnModule(Module &M);
};
RegisterOpt<RaiseAllocations>
// createRaiseAllocationsPass - The interface to this file...
-Pass *llvm::createRaiseAllocationsPass() {
+ModulePass *llvm::createRaiseAllocationsPass() {
return new RaiseAllocations();
}
// run - Transform calls into instructions...
//
-bool RaiseAllocations::run(Module &M) {
+bool RaiseAllocations::runOnModule(Module &M) {
// Find the malloc/free prototypes...
doInitialization(M);
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"
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"
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"
BLACK
};
- struct EmitFunctionTable : public Pass {
- bool run(Module &M);
+ struct EmitFunctionTable : public ModulePass {
+ bool runOnModule(Module &M);
};
RegisterOpt<EmitFunctionTable>
}
// 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;
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",
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"
//
// 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;
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);
}
};
/// 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;
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;
}
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);
/// 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];
/// 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;
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;
}