CallGraph(AnalysisID AID) : Root(0) { assert(AID == ID); }
~CallGraph() { destroy(); }
+ virtual const char *getPassName() const { return "Call Graph Construction"; }
+
// run - Compute the call graph for the specified module.
virtual bool run(Module *TheModule);
DataStructure(AnalysisID id) { assert(id == ID); }
~DataStructure() { releaseMemory(); }
+ virtual const char *getPassName() const { return "Data Structure Analysis"; }
+
// run - Do nothing, because methods are analyzed lazily
virtual bool run(Module *TheModule) { return false; }
DataStructure(AnalysisID id) { assert(id == ID); }
~DataStructure() { releaseMemory(); }
+ virtual const char *getPassName() const { return "Data Structure Analysis"; }
+
// run - Do nothing, because methods are analyzed lazily
virtual bool run(Module *TheModule) { return false; }
DominatorSet(AnalysisID id) : DominatorBase(id == PostDomID) {}
+ virtual const char *getPassName() const {
+ if (isPostDominator()) return "Post-Dominator Set Construction";
+ else return "Dominator Set Construction";
+ }
+
virtual bool runOnFunction(Function *F);
// Accessor interface:
ImmediateDominators(AnalysisID id) : DominatorBase(id == PostDomID) {}
+ virtual const char *getPassName() const {
+ if (isPostDominator()) return "Immediate Post-Dominators Construction";
+ else return "Immediate Dominators Construction";
+ }
+
virtual bool runOnFunction(Function *F) {
IDoms.clear(); // Reset from the last time we were run...
DominatorSet *DS;
DominatorTree(AnalysisID id) : DominatorBase(id == PostDomID) {}
~DominatorTree() { reset(); }
+ virtual const char *getPassName() const {
+ if (isPostDominator()) return "Post-Dominator Tree Construction";
+ else return "Dominator Tree Construction";
+ }
+
virtual bool runOnFunction(Function *F) {
reset();
DominatorSet *DS;
DominanceFrontier(AnalysisID id) : DominatorBase(id == PostDomID) {}
+ virtual const char *getPassName() const {
+ if (isPostDominator()) return "Post-Dominance Frontier Construction";
+ else return "Dominance Frontier Construction";
+ }
+
virtual bool runOnFunction(Function *) {
Frontiers.clear();
DominatorTree *DT;
FindUnsafePointerTypes(AnalysisID id) { assert(ID == id); }
+ virtual const char *getPassName() const { return "Find Unsafe Pointer Types";}
+
// Accessor for underlying type set...
inline const std::set<PointerType*> &getUnsafeTypes() const {
return UnsafeTypes;
static AnalysisID IncludeSymbolTableID;
FindUsedTypes(AnalysisID id) : IncludeSymbolTables(id != ID) {}
+ virtual const char *getPassName() const { return "Find Used Types"; }
// getTypes - After the pass has been run, return the set containing all of
// the types used in the module.
IntervalPartition(AnalysisID AID) : RootInterval(0) { assert(AID == ID); }
+ const char *getPassName() const { return "Interval Partition Construction"; }
+
// run - Calculate the interval partition for this function
virtual bool runOnFunction(Function *F);
FunctionLiveVarInfo(AnalysisID id = ID) { assert(id == ID); }
+ virtual const char *getPassName() const { return "Live Variable Analysis"; }
+
// --------- Implement the FunctionPass interface ----------------------
// runOnFunction - Perform analysis, update internal data structures.
LoopInfo(AnalysisID id) { assert(id == ID); }
~LoopInfo() { releaseMemory(); }
+ const char *getPassName() const { return "Natural Loop Analysis"; }
+
const std::vector<Loop*> &getTopLevelLoops() const { return TopLevelLoops; }
// getLoopFor - Return the inner most loop that BB lives in. If a basic block
inline PrintModulePass(std::ostream *o = &std::cout, bool DS = false)
: Out(o), DeleteStream(DS) {
}
+
+ const char *getPassName() const { return "Module Printer"; }
inline ~PrintModulePass() {
if (DeleteStream) delete Out;
bool DS = false)
: Banner(B), Out(o), DeleteStream(DS) {
}
+
+ const char *getPassName() const { return "Function Printer"; }
inline ~PrintFunctionPass() {
if (DeleteStream) delete Out;
: Out(o), DeleteStream(DS) {
}
+ const char *getPassName() const { return "Bytecode Writer"; }
+
inline ~WriteBytecodePass() {
if (DeleteStream) delete Out;
}
FunctionLiveVarInfo(AnalysisID id = ID) { assert(id == ID); }
+ virtual const char *getPassName() const { return "Live Variable Analysis"; }
+
// --------- Implement the FunctionPass interface ----------------------
// runOnFunction - Perform analysis, update internal data structures.
inline Pass(AnalysisResolver *AR = 0) : Resolver(AR) {}
inline virtual ~Pass() {} // Destructor is virtual so we can be subclassed
+ // getPassName - Return a nice clean name for a pass. This should be
+ // overloaded by the pass, but if it is not, C++ RTTI will be consulted to get
+ // a SOMEWHAT intelligable name for the pass.
+ //
+ virtual const char *getPassName() const;
// run - Run this pass, returning true if a modification was made to the
// module argument. This should be implemented by all concrete subclasses.
void setAnalysisResolver(Pass *P, AnalysisResolver *AR);
};
-
-
#endif
class IntervalPartition;
struct InductionVariableCannonicalize : public FunctionPass {
+ const char *getPassName() const { return "**OLD IndVars ***"; }
+
// doInductionVariableCannonicalize - Simplify induction variables in loops
//
static bool doIt(Function *F, IntervalPartition &IP);
static AnalysisID ID; // Pass ID
UnifyFunctionExitNodes(AnalysisID id = ID) : ExitNode(0) { assert(ID == id); }
+ virtual const char *getPassName() const { return "Unify Function Exit Nodes";}
+
// UnifyAllExitNodes - Unify all exit nodes of the CFG by creating a new
// BasicBlock, and converting all returns to unconditional branches to this
// new basic block. The singular exit node is returned in ExitNode.
const TargetMachine ⌖
public:
inline InstructionSchedulingWithSSA(const TargetMachine &T) : target(T) {}
+
+ const char *getPassName() const { return "Instruction Scheduling"; }
// getAnalysisUsage - We use LiveVarInfo...
virtual void getAnalysisUsage(AnalysisUsage &AU) const {
TargetMachine &Target;
public:
inline RegisterAllocator(TargetMachine &T) : Target(T) {}
+
+ const char *getPassName() const { return "Register Allocation"; }
bool runOnFunction(Function *F) {
if (DEBUG_RA)
public:
SparcBytecodeWriter(std::ostream &out) : Out(out) {}
+ const char *getPassName() const { return "Emit Bytecode to Sparc Assembly";}
+
virtual bool run(Module *M) {
// Write bytecode out to the sparc assembly stream
Out << "\n\n!LLVM BYTECODE OUTPUT\n\t.section \".rodata\"\n\t.align 8\n";
const TargetMachine ⌖
public:
inline InstructionSchedulingWithSSA(const TargetMachine &T) : target(T) {}
+
+ const char *getPassName() const { return "Instruction Scheduling"; }
// getAnalysisUsage - We use LiveVarInfo...
virtual void getAnalysisUsage(AnalysisUsage &AU) const {
TargetMachine &Target;
public:
inline RegisterAllocator(TargetMachine &T) : Target(T) {}
+
+ const char *getPassName() const { return "Register Allocation"; }
bool runOnFunction(Function *F) {
if (DEBUG_RA)
inline SparcFunctionAsmPrinter(std::ostream &os, const TargetMachine &t)
: AsmPrinter(os, t) {}
+ const char *getPassName() const {
+ return "Output Sparc Assembly for Functions";
+ }
+
virtual bool doInitialization(Module *M) {
startModule(M);
return false;
SparcModuleAsmPrinter(std::ostream &os, TargetMachine &t)
: AsmPrinter(os, t) {}
+ const char *getPassName() const { return "Output Sparc Assembly for Module"; }
+
virtual bool run(Module *M) {
startModule(M);
emitGlobalsAndConstants(M);
TargetMachine &Target;
public:
InsertPrologEpilogCode(TargetMachine &T) : Target(T) {}
+
+ const char *getPassName() const { return "Sparc Prolog/Epilog Inserter"; }
+
bool runOnFunction(Function *F) {
MachineCodeForMethod &mcodeInfo = MachineCodeForMethod::get(F);
if (!mcodeInfo.isCompiledAsLeafMethod()) {
TargetMachine &Target;
public:
inline ConstructMachineCodeForFunction(TargetMachine &T) : Target(T) {}
+
+ const char *getPassName() const {
+ return "Sparc ConstructMachineCodeForFunction";
+ }
+
bool runOnFunction(Function *F) {
MachineCodeForMethod::construct(F, Target);
return false;
TargetMachine &Target;
public:
inline InstructionSelection(TargetMachine &T) : Target(T) {}
+ const char *getPassName() const { return "Sparc Instruction Selection"; }
+
bool runOnFunction(Function *F) {
if (SelectInstructionsForMethod(F, Target)) {
cerr << "Instr selection failed for function " << F->getName() << "\n";
};
struct FreeMachineCodeForFunction : public FunctionPass {
+ const char *getPassName() const { return "Sparc FreeMachineCodeForFunction"; }
+
static void freeMachineCode(Instruction *I) {
MachineCodeForInstruction::destroy(I);
}
namespace {
struct HoistPHIConstants : public FunctionPass {
+ const char *getPassName() const { return "Hoist Constants from PHI Nodes"; }
+
virtual bool runOnFunction(Function *F) { return doHoistPHIConstants(F); }
virtual void getAnalysisUsage(AnalysisUsage &AU) const {
unsigned LastConstantSeen;
public:
inline ConstantMerge() : LastConstantSeen(0) {}
+
+ const char *getPassName() const {return "Merge Duplicate Global Constants";}
// doInitialization - For this pass, process all of the globals in the
// module, eliminating duplicate constants.
};
struct DynamicConstantMerge : public ConstantMerge {
+ const char *getPassName() const { return "Dynamic Constant Merge"; }
+
// runOnFunction - Check to see if any globals have been added to the
// global list for the module. If so, eliminate them.
//
namespace {
struct CleanupGCCOutput : public FunctionPass {
+ const char *getPassName() const { return "Cleanup GCC Output"; }
+
// 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.
namespace {
struct FunctionResolvingPass : public Pass {
+ const char *getPassName() const { return "Resolve Functions"; }
+
bool run(Module *M);
};
}
namespace {
struct GlobalDCE : public Pass {
+ const char *getPassName() const { return "Dead Global Elimination"; }
+
// run - Do the GlobalDCE pass on the specified module, optionally updating
// the specified callgraph to reflect the changes.
//
namespace {
struct FunctionInlining : public FunctionPass {
+ const char *getPassName() const { return "Function Inlining"; }
virtual bool runOnFunction(Function *F) {
return doFunctionInlining(F);
}
#include "llvm/Function.h"
class InternalizePass : public Pass {
+ const char *getPassName() const { return "Internalize Functions"; }
+
virtual bool run(Module *M) {
bool FoundMain = false; // Look for a function named main...
for (Module::iterator I = M->begin(), E = M->end(); I != E; ++I)
// Define the pass class that we implement...
struct PoolAllocate : public Pass {
+ const char *getPassName() const { return "Pool Allocate"; }
+
PoolAllocate() {
switch (ReqPointerSize) {
case Ptr32bits: POINTERTYPE = Type::UIntTy; break;
using std::pair;
namespace {
- class SimpleStructMutation : public MutateStructTypes {
- public:
+ struct SimpleStructMutation : public MutateStructTypes {
enum Transform { SwapElements, SortElements } CurrentXForm;
SimpleStructMutation(enum Transform XForm) : CurrentXForm(XForm) {}
+ const char *getPassName() const { return "Simple Struct Mutation"; }
+
virtual bool run(Module *M) {
setTransforms(getTransforms(M, CurrentXForm));
bool Changed = MutateStructTypes::run(M);
using std::vector;
-class ProfilePaths: public FunctionPass {
- public:
+struct ProfilePaths : public FunctionPass {
+ const char *getPassName() const { return "ProfilePaths"; }
+
bool runOnFunction(Function *F);
// Before this pass, make sure that there is only one
InsertTraceCode(bool traceBasicBlockExits, bool traceFunctionExits)
: TraceBasicBlockExits(traceBasicBlockExits),
TraceFunctionExits(traceFunctionExits) {}
+
+ const char *getPassName() const { return "Trace Code Insertion"; }
// Add a prototype for printf if it is not already in the program.
//
namespace {
struct RaisePointerReferences : public FunctionPass {
+ const char *getPassName() const { return "Raise Pointer References"; }
+
virtual bool runOnFunction(Function *F) { return doRPR(F); }
virtual void getAnalysisUsage(AnalysisUsage &AU) const {
namespace {
struct AgressiveDCE : public FunctionPass {
+ const char *getPassName() const {return "Aggressive Dead Code Elimination";}
+
// doADCE - Execute the Agressive Dead Code Elimination Algorithm
//
virtual bool runOnFunction(Function *F) {
namespace {
struct ConstantPropogation : public FunctionPass {
+ const char *getPassName() const { return "Simple Constant Propogation"; }
+
inline bool runOnFunction(Function *F) {
bool Modified = false;
}
struct DeadInstElimination : public BasicBlockPass {
+ const char *getPassName() const { return "Dead Instruction Elimination"; }
+
virtual bool runOnBasicBlock(BasicBlock *BB) {
return RemoveUnusedDefs(BB->getInstList());
}
namespace {
struct DeadCodeElimination : public FunctionPass {
+ const char *getPassName() const { return "Dead Code Elimination"; }
// Pass Interface...
virtual bool doInitialization(Module *M) {
//===----------------------------------------------------------------------===//
#include "llvm/Transforms/Scalar/DecomposeMultiDimRefs.h"
-#include "llvm/Constants.h"
+#include "llvm/Constant.h"
#include "llvm/iMemory.h"
#include "llvm/iOther.h"
#include "llvm/BasicBlock.h"
-#include "llvm/Function.h"
#include "llvm/Pass.h"
namespace {
struct DecomposePass : public BasicBlockPass {
+ const char *getPassName() const { return "Decompose Subscripting Exps"; }
+
virtual bool runOnBasicBlock(BasicBlock *BB);
private:
// Check for a zero index. This will need a cast instead of
// a getElementPtr, or it may need neither.
- bool indexIsZero = isa<ConstantUInt>(*OI) &&
- cast<Constant>(*OI)->isNullValue();
+ bool indexIsZero = isa<Constant>(*OI) &&
+ cast<Constant>(*OI)->isNullValue() &&
+ (*OI)->getType() == Type::UIntTy;
// Extract the first index. If the ptr is a pointer to a structure
// and the next index is a structure offset (i.e., not an array offset),
DominatorSet *DomSetInfo;
ImmediateDominators *ImmDominator;
public:
+ const char *getPassName() const {
+ return "Global Common Subexpression Elimination";
+ }
+
virtual bool runOnFunction(Function *F);
// Visitation methods, these are invoked depending on the type of
namespace {
struct InductionVariableSimplify : public FunctionPass {
+ const char *getPassName() const {
+ return "Induction Variable Cannonicalize";
+ }
+
virtual bool runOnFunction(Function *F) {
return doit(F, getAnalysis<LoopInfo>());
}
}
public:
+ const char *getPassName() const { return "Instruction Combining"; }
+
virtual bool runOnFunction(Function *F);
virtual void getAnalysisUsage(AnalysisUsage &AU) const {
// to prove whether a value is constant and whether blocks are used.
//
struct SCCPPass : public FunctionPass {
+ const char *getPassName() const {
+ return "Sparse Conditional Constant Propogation";
+ }
+
inline bool runOnFunction(Function *F) {
SCCP S(F);
return S.doSCCP();
namespace {
struct SymbolStripping : public FunctionPass {
+ const char *getPassName() const { return "Strip Symbols from Functions"; }
+
virtual bool runOnFunction(Function *F) {
return doSymbolStripping(F);
}
};
struct FullSymbolStripping : public SymbolStripping {
+ const char *getPassName() const { return "Strip Symbols from Module"; }
virtual bool doInitialization(Module *M) {
return doStripGlobalSymbols(M);
}
MallocFunc = FreeFunc = 0;
}
+ const char *getPassName() const { return "Lower Allocations"; }
+
// doPassInitialization - For the lower allocations pass, this ensures that a
// module contains a declaration for a malloc and a free function.
//
public:
inline RaiseAllocations() : MallocFunc(0), FreeFunc(0) {}
+ const char *getPassName() const { return "Raise Allocations"; }
+
// doPassInitialization - For the raise allocations pass, this finds a
// declaration for malloc and free if they exist.
//
Pass *createRaiseAllocationsPass() {
return new RaiseAllocations();
}
-
-
map<BasicBlock*,vector<PHINode*> > NewPhiNodes; // the PhiNodes we're adding
public:
+ const char *getPassName() const { return "Promote Memory to Register"; }
+
// runOnFunction - To run this pass, first we calculate the alloca
// instructions that are safe for promotion, then we promote each one.
//
cerr << std::string(79, '=') << "\n"
<< " ... Pass execution timing report ...\n"
<< std::string(79, '=') << "\n Total Execution Time: " << TotalTime
- << " seconds\n\n % Time: Seconds:\tPass Name (mangled):\n";
+ << " seconds\n\n % Time: Seconds:\tPass Name:\n";
// Loop through all of the timing data, printing it out...
for (unsigned i = 0, e = Data.size(); i != e; ++i) {
fprintf(stderr, " %6.2f%% %fs\t%s\n", Data[i].first*100 / TotalTime,
- Data[i].first, typeid(*Data[i].second).name());
+ Data[i].first, Data[i].second->getPassName());
}
cerr << " 100.00% " << TotalTime << "s\tTOTAL\n"
<< std::string(79, '=') << "\n";
Pass *P, Annotable *V) {
if (PassDebugging >= PassExecutions) {
std::cerr << (void*)P << std::string(Depth*2+1, ' ') << Action << " '"
- << typeid(*P).name();
+ << P->getPassName();
if (V) {
std::cerr << "' on ";
std::cerr << (void*)P << std::string(Depth*2+3, ' ') << Msg << " Analyses:";
for (unsigned i = 0; i != Set.size(); ++i) {
Pass *P = Set[i].createPass(); // Good thing this is just debug code...
- std::cerr << " " << typeid(*P).name();
+ std::cerr << " " << P->getPassName();
delete P;
}
std::cerr << "\n";
// dumpPassStructure - Implement the -debug-passes=PassStructure option
void Pass::dumpPassStructure(unsigned Offset = 0) {
- std::cerr << std::string(Offset*2, ' ') << typeid(*this).name() << "\n";
+ std::cerr << std::string(Offset*2, ' ') << getPassName() << "\n";
}
PM->addPass(this, AU);
}
+
+// getPassName - Use C++ RTTI to get a SOMEWHAT intelligable name for the pass.
+//
+const char *Pass::getPassName() const { return typeid(*this).name(); }
+
//===----------------------------------------------------------------------===//
// FunctionPass Implementation
//
// getPMName() - Return the name of the unit the PassManager operates on for
// debugging.
const char *getPMName() const { return "BasicBlock"; }
+ virtual const char *getPassName() const { return "BasicBlock Pass Manager"; }
// Implement the BasicBlockPass interface...
virtual bool doInitialization(Module *M);
// getPMName() - Return the name of the unit the PassManager operates on for
// debugging.
const char *getPMName() const { return "Function"; }
+ virtual const char *getPassName() const { return "Function Pass Manager"; }
// Implement the FunctionPass interface...
virtual bool doInitialization(Module *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"; }
// TimingInformation - This data member maintains timing information for each
// of the passes that is executed.
Verifier() : Broken(false) {}
+ virtual const char *getPassName() const { return "Module Verifier"; }
+
bool doInitialization(Module *M) {
verifySymbolTable(M->getSymbolTable());
return false;
const AnalysisID ID;
public:
PassPrinter(const string &M, AnalysisID id) : Message(M), ID(id) {}
+
+ const char *getPassName() const { return "IP Pass Printer"; }
virtual bool run(Module *M) {
std::cout << Message << "\n";
const AnalysisID ID;
public:
PassPrinter(const string &M, AnalysisID id) : Message(M), ID(id) {}
+
+ const char *getPassName() const { return "Function Pass Printer"; }
virtual bool runOnFunction(Function *F) {
std::cout << Message << " on function '" << F->getName() << "'\n";
}
struct InstForest : public FunctionPass {
+ const char *getPassName() const { return "InstForest Printer"; }
+
void doit(Function *F) {
std::cout << analysis::InstForest<char>(F);
}
};
struct IndVars : public FunctionPass {
+ const char *getPassName() const { return "IndVars Printer"; }
+
void doit(Function *F) {
LoopInfo &LI = getAnalysis<LoopInfo>();
for (inst_iterator I = inst_begin(F), E = inst_end(F); I != E; ++I)
};
struct Exprs : public FunctionPass {
+ const char *getPassName() const { return "Expression Printer"; }
+
static void doit(Function *F) {
std::cout << "Classified expressions for: " << F->getName() << "\n";
for (inst_iterator I = inst_begin(F), E = inst_end(F); I != E; ++I) {
const string Message;
public:
PrinterPass(const string &M) : Message(M) {}
-
+
virtual bool runOnFunction(Function *F) {
std::cout << Message << " on function '" << F->getName() << "'\n";