From 96c466b06ab0c830b07329c1b16037f585ccbe40 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Mon, 29 Apr 2002 14:57:45 +0000 Subject: [PATCH] Add new optional getPassName() virtual function that a Pass can override to make debugging output a lot nicer. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@2395 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Analysis/CallGraph.h | 2 ++ include/llvm/Analysis/DataStructure.h | 2 ++ .../Analysis/DataStructure/DataStructure.h | 2 ++ include/llvm/Analysis/Dominators.h | 20 +++++++++++++++++++ .../llvm/Analysis/FindUnsafePointerTypes.h | 2 ++ include/llvm/Analysis/FindUsedTypes.h | 1 + include/llvm/Analysis/IntervalPartition.h | 2 ++ .../Analysis/LiveVar/FunctionLiveVarInfo.h | 2 ++ include/llvm/Analysis/LoopInfo.h | 2 ++ include/llvm/Assembly/PrintModulePass.h | 4 ++++ include/llvm/Bytecode/WriteBytecodePass.h | 2 ++ include/llvm/CodeGen/FunctionLiveVarInfo.h | 2 ++ include/llvm/Pass.h | 7 +++++-- .../llvm/Transforms/Scalar/InductionVars.h | 2 ++ .../Transforms/Utils/UnifyFunctionExitNodes.h | 2 ++ lib/CodeGen/InstrSched/InstrScheduling.cpp | 2 ++ lib/CodeGen/RegAlloc/PhyRegAlloc.cpp | 2 ++ lib/Target/SparcV9/EmitBytecodeToAssembly.cpp | 2 ++ .../SparcV9/InstrSched/InstrScheduling.cpp | 2 ++ lib/Target/SparcV9/RegAlloc/PhyRegAlloc.cpp | 2 ++ lib/Target/SparcV9/SparcV9AsmPrinter.cpp | 6 ++++++ .../SparcV9/SparcV9PrologEpilogInserter.cpp | 3 +++ lib/Target/SparcV9/SparcV9TargetMachine.cpp | 9 +++++++++ lib/Transforms/HoistPHIConstants.cpp | 2 ++ lib/Transforms/IPO/ConstantMerge.cpp | 4 ++++ lib/Transforms/IPO/DeadTypeElimination.cpp | 4 ++++ lib/Transforms/IPO/GlobalDCE.cpp | 2 ++ lib/Transforms/IPO/InlineSimple.cpp | 1 + lib/Transforms/IPO/Internalize.cpp | 2 ++ lib/Transforms/IPO/OldPoolAllocate.cpp | 2 ++ lib/Transforms/IPO/SimpleStructMutation.cpp | 5 +++-- .../ProfilePaths/ProfilePaths.cpp | 5 +++-- .../Instrumentation/TraceValues.cpp | 2 ++ lib/Transforms/LevelRaise.cpp | 2 ++ lib/Transforms/Scalar/ADCE.cpp | 2 ++ lib/Transforms/Scalar/ConstantProp.cpp | 2 ++ lib/Transforms/Scalar/DCE.cpp | 3 +++ .../Scalar/DecomposeMultiDimRefs.cpp | 10 ++++++---- lib/Transforms/Scalar/GCSE.cpp | 4 ++++ lib/Transforms/Scalar/IndVarSimplify.cpp | 4 ++++ .../Scalar/InstructionCombining.cpp | 2 ++ lib/Transforms/Scalar/SCCP.cpp | 4 ++++ lib/Transforms/Scalar/SymbolStripping.cpp | 3 +++ lib/Transforms/Utils/LowerAllocations.cpp | 6 ++++-- .../Utils/PromoteMemoryToRegister.cpp | 2 ++ lib/VMCore/Pass.cpp | 15 +++++++++----- lib/VMCore/PassManagerT.h | 3 +++ lib/VMCore/Verifier.cpp | 2 ++ tools/analyze/analyze.cpp | 12 ++++++++++- 49 files changed, 169 insertions(+), 18 deletions(-) diff --git a/include/llvm/Analysis/CallGraph.h b/include/llvm/Analysis/CallGraph.h index 61693876c41..035d4abc9c4 100644 --- a/include/llvm/Analysis/CallGraph.h +++ b/include/llvm/Analysis/CallGraph.h @@ -115,6 +115,8 @@ public: 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); diff --git a/include/llvm/Analysis/DataStructure.h b/include/llvm/Analysis/DataStructure.h index 90a4b5df233..f6b60b83869 100644 --- a/include/llvm/Analysis/DataStructure.h +++ b/include/llvm/Analysis/DataStructure.h @@ -439,6 +439,8 @@ public: 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; } diff --git a/include/llvm/Analysis/DataStructure/DataStructure.h b/include/llvm/Analysis/DataStructure/DataStructure.h index 90a4b5df233..f6b60b83869 100644 --- a/include/llvm/Analysis/DataStructure/DataStructure.h +++ b/include/llvm/Analysis/DataStructure/DataStructure.h @@ -439,6 +439,8 @@ public: 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; } diff --git a/include/llvm/Analysis/Dominators.h b/include/llvm/Analysis/Dominators.h index 3a29eec6c88..e3038da1951 100644 --- a/include/llvm/Analysis/Dominators.h +++ b/include/llvm/Analysis/Dominators.h @@ -63,6 +63,11 @@ public: 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: @@ -115,6 +120,11 @@ public: 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; @@ -206,6 +216,11 @@ public: 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; @@ -262,6 +277,11 @@ public: 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; diff --git a/include/llvm/Analysis/FindUnsafePointerTypes.h b/include/llvm/Analysis/FindUnsafePointerTypes.h index 82cc28a06f4..98f530caaa8 100644 --- a/include/llvm/Analysis/FindUnsafePointerTypes.h +++ b/include/llvm/Analysis/FindUnsafePointerTypes.h @@ -30,6 +30,8 @@ public: 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 &getUnsafeTypes() const { return UnsafeTypes; diff --git a/include/llvm/Analysis/FindUsedTypes.h b/include/llvm/Analysis/FindUsedTypes.h index 5c02b2cc5fc..ece390e489f 100644 --- a/include/llvm/Analysis/FindUsedTypes.h +++ b/include/llvm/Analysis/FindUsedTypes.h @@ -24,6 +24,7 @@ public: 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. diff --git a/include/llvm/Analysis/IntervalPartition.h b/include/llvm/Analysis/IntervalPartition.h index 281b32ed0e8..ab16250e83c 100644 --- a/include/llvm/Analysis/IntervalPartition.h +++ b/include/llvm/Analysis/IntervalPartition.h @@ -39,6 +39,8 @@ public: 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); diff --git a/include/llvm/Analysis/LiveVar/FunctionLiveVarInfo.h b/include/llvm/Analysis/LiveVar/FunctionLiveVarInfo.h index 4f7db3fb88f..dab6d3c7f3d 100644 --- a/include/llvm/Analysis/LiveVar/FunctionLiveVarInfo.h +++ b/include/llvm/Analysis/LiveVar/FunctionLiveVarInfo.h @@ -105,6 +105,8 @@ public: 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. diff --git a/include/llvm/Analysis/LoopInfo.h b/include/llvm/Analysis/LoopInfo.h index b56de0f8069..bb9058c256e 100644 --- a/include/llvm/Analysis/LoopInfo.h +++ b/include/llvm/Analysis/LoopInfo.h @@ -72,6 +72,8 @@ public: LoopInfo(AnalysisID id) { assert(id == ID); } ~LoopInfo() { releaseMemory(); } + const char *getPassName() const { return "Natural Loop Analysis"; } + const std::vector &getTopLevelLoops() const { return TopLevelLoops; } // getLoopFor - Return the inner most loop that BB lives in. If a basic block diff --git a/include/llvm/Assembly/PrintModulePass.h b/include/llvm/Assembly/PrintModulePass.h index 2d63e6d74f1..83cd852f130 100644 --- a/include/llvm/Assembly/PrintModulePass.h +++ b/include/llvm/Assembly/PrintModulePass.h @@ -22,6 +22,8 @@ public: 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; @@ -46,6 +48,8 @@ public: bool DS = false) : Banner(B), Out(o), DeleteStream(DS) { } + + const char *getPassName() const { return "Function Printer"; } inline ~PrintFunctionPass() { if (DeleteStream) delete Out; diff --git a/include/llvm/Bytecode/WriteBytecodePass.h b/include/llvm/Bytecode/WriteBytecodePass.h index bd9d42369ec..84e491a7d90 100644 --- a/include/llvm/Bytecode/WriteBytecodePass.h +++ b/include/llvm/Bytecode/WriteBytecodePass.h @@ -19,6 +19,8 @@ public: : Out(o), DeleteStream(DS) { } + const char *getPassName() const { return "Bytecode Writer"; } + inline ~WriteBytecodePass() { if (DeleteStream) delete Out; } diff --git a/include/llvm/CodeGen/FunctionLiveVarInfo.h b/include/llvm/CodeGen/FunctionLiveVarInfo.h index 4f7db3fb88f..dab6d3c7f3d 100644 --- a/include/llvm/CodeGen/FunctionLiveVarInfo.h +++ b/include/llvm/CodeGen/FunctionLiveVarInfo.h @@ -105,6 +105,8 @@ public: 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. diff --git a/include/llvm/Pass.h b/include/llvm/Pass.h index bd040b99935..3c89130cbae 100644 --- a/include/llvm/Pass.h +++ b/include/llvm/Pass.h @@ -41,6 +41,11 @@ public: 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. @@ -312,6 +317,4 @@ protected: void setAnalysisResolver(Pass *P, AnalysisResolver *AR); }; - - #endif diff --git a/include/llvm/Transforms/Scalar/InductionVars.h b/include/llvm/Transforms/Scalar/InductionVars.h index 196bb1f10a2..704617c594b 100644 --- a/include/llvm/Transforms/Scalar/InductionVars.h +++ b/include/llvm/Transforms/Scalar/InductionVars.h @@ -12,6 +12,8 @@ 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); diff --git a/include/llvm/Transforms/Utils/UnifyFunctionExitNodes.h b/include/llvm/Transforms/Utils/UnifyFunctionExitNodes.h index a6f259a57db..6281c8aa4a7 100644 --- a/include/llvm/Transforms/Utils/UnifyFunctionExitNodes.h +++ b/include/llvm/Transforms/Utils/UnifyFunctionExitNodes.h @@ -17,6 +17,8 @@ public: 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. diff --git a/lib/CodeGen/InstrSched/InstrScheduling.cpp b/lib/CodeGen/InstrSched/InstrScheduling.cpp index 4c2a28c7882..b0422797475 100644 --- a/lib/CodeGen/InstrSched/InstrScheduling.cpp +++ b/lib/CodeGen/InstrSched/InstrScheduling.cpp @@ -1484,6 +1484,8 @@ namespace { 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 { diff --git a/lib/CodeGen/RegAlloc/PhyRegAlloc.cpp b/lib/CodeGen/RegAlloc/PhyRegAlloc.cpp index 4ad98d917fd..b783255699f 100644 --- a/lib/CodeGen/RegAlloc/PhyRegAlloc.cpp +++ b/lib/CodeGen/RegAlloc/PhyRegAlloc.cpp @@ -44,6 +44,8 @@ namespace { TargetMachine &Target; public: inline RegisterAllocator(TargetMachine &T) : Target(T) {} + + const char *getPassName() const { return "Register Allocation"; } bool runOnFunction(Function *F) { if (DEBUG_RA) diff --git a/lib/Target/SparcV9/EmitBytecodeToAssembly.cpp b/lib/Target/SparcV9/EmitBytecodeToAssembly.cpp index 92420f9421f..fdf8f3ec361 100644 --- a/lib/Target/SparcV9/EmitBytecodeToAssembly.cpp +++ b/lib/Target/SparcV9/EmitBytecodeToAssembly.cpp @@ -59,6 +59,8 @@ namespace { 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"; diff --git a/lib/Target/SparcV9/InstrSched/InstrScheduling.cpp b/lib/Target/SparcV9/InstrSched/InstrScheduling.cpp index 4c2a28c7882..b0422797475 100644 --- a/lib/Target/SparcV9/InstrSched/InstrScheduling.cpp +++ b/lib/Target/SparcV9/InstrSched/InstrScheduling.cpp @@ -1484,6 +1484,8 @@ namespace { 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 { diff --git a/lib/Target/SparcV9/RegAlloc/PhyRegAlloc.cpp b/lib/Target/SparcV9/RegAlloc/PhyRegAlloc.cpp index 4ad98d917fd..b783255699f 100644 --- a/lib/Target/SparcV9/RegAlloc/PhyRegAlloc.cpp +++ b/lib/Target/SparcV9/RegAlloc/PhyRegAlloc.cpp @@ -44,6 +44,8 @@ namespace { TargetMachine &Target; public: inline RegisterAllocator(TargetMachine &T) : Target(T) {} + + const char *getPassName() const { return "Register Allocation"; } bool runOnFunction(Function *F) { if (DEBUG_RA) diff --git a/lib/Target/SparcV9/SparcV9AsmPrinter.cpp b/lib/Target/SparcV9/SparcV9AsmPrinter.cpp index f4ca22f9da9..8d87bfec6be 100644 --- a/lib/Target/SparcV9/SparcV9AsmPrinter.cpp +++ b/lib/Target/SparcV9/SparcV9AsmPrinter.cpp @@ -192,6 +192,10 @@ struct SparcFunctionAsmPrinter : public FunctionPass, public AsmPrinter { 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; @@ -424,6 +428,8 @@ public: 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); diff --git a/lib/Target/SparcV9/SparcV9PrologEpilogInserter.cpp b/lib/Target/SparcV9/SparcV9PrologEpilogInserter.cpp index 17cd73bfc34..b42e7771567 100644 --- a/lib/Target/SparcV9/SparcV9PrologEpilogInserter.cpp +++ b/lib/Target/SparcV9/SparcV9PrologEpilogInserter.cpp @@ -25,6 +25,9 @@ class InsertPrologEpilogCode : public FunctionPass { 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()) { diff --git a/lib/Target/SparcV9/SparcV9TargetMachine.cpp b/lib/Target/SparcV9/SparcV9TargetMachine.cpp index 306b85a2272..fecdf23e29a 100644 --- a/lib/Target/SparcV9/SparcV9TargetMachine.cpp +++ b/lib/Target/SparcV9/SparcV9TargetMachine.cpp @@ -130,6 +130,11 @@ class ConstructMachineCodeForFunction : public FunctionPass { 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; @@ -140,6 +145,8 @@ class InstructionSelection : public FunctionPass { 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"; @@ -150,6 +157,8 @@ public: }; struct FreeMachineCodeForFunction : public FunctionPass { + const char *getPassName() const { return "Sparc FreeMachineCodeForFunction"; } + static void freeMachineCode(Instruction *I) { MachineCodeForInstruction::destroy(I); } diff --git a/lib/Transforms/HoistPHIConstants.cpp b/lib/Transforms/HoistPHIConstants.cpp index e969ac24b3a..05480ea9503 100644 --- a/lib/Transforms/HoistPHIConstants.cpp +++ b/lib/Transforms/HoistPHIConstants.cpp @@ -75,6 +75,8 @@ static bool doHoistPHIConstants(Function *M) { 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 { diff --git a/lib/Transforms/IPO/ConstantMerge.cpp b/lib/Transforms/IPO/ConstantMerge.cpp index a635b8d21be..146911e818d 100644 --- a/lib/Transforms/IPO/ConstantMerge.cpp +++ b/lib/Transforms/IPO/ConstantMerge.cpp @@ -65,6 +65,8 @@ namespace { 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. @@ -89,6 +91,8 @@ namespace { }; 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. // diff --git a/lib/Transforms/IPO/DeadTypeElimination.cpp b/lib/Transforms/IPO/DeadTypeElimination.cpp index 3ba6057fad2..dc330b29f8a 100644 --- a/lib/Transforms/IPO/DeadTypeElimination.cpp +++ b/lib/Transforms/IPO/DeadTypeElimination.cpp @@ -36,6 +36,8 @@ static const Type *PtrSByte = 0; // 'sbyte*' type 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. @@ -337,6 +339,8 @@ bool CleanupGCCOutput::doFinalization(Module *M) { namespace { struct FunctionResolvingPass : public Pass { + const char *getPassName() const { return "Resolve Functions"; } + bool run(Module *M); }; } diff --git a/lib/Transforms/IPO/GlobalDCE.cpp b/lib/Transforms/IPO/GlobalDCE.cpp index cd9c35f058a..e852a6a29fc 100644 --- a/lib/Transforms/IPO/GlobalDCE.cpp +++ b/lib/Transforms/IPO/GlobalDCE.cpp @@ -49,6 +49,8 @@ static bool RemoveUnreachableFunctions(Module *M, CallGraph &CallGraph) { 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. // diff --git a/lib/Transforms/IPO/InlineSimple.cpp b/lib/Transforms/IPO/InlineSimple.cpp index 1581323bea1..ba64a6abce0 100644 --- a/lib/Transforms/IPO/InlineSimple.cpp +++ b/lib/Transforms/IPO/InlineSimple.cpp @@ -271,6 +271,7 @@ static bool doFunctionInlining(Function *F) { namespace { struct FunctionInlining : public FunctionPass { + const char *getPassName() const { return "Function Inlining"; } virtual bool runOnFunction(Function *F) { return doFunctionInlining(F); } diff --git a/lib/Transforms/IPO/Internalize.cpp b/lib/Transforms/IPO/Internalize.cpp index 8bb1a9c111c..c84be9b93a2 100644 --- a/lib/Transforms/IPO/Internalize.cpp +++ b/lib/Transforms/IPO/Internalize.cpp @@ -12,6 +12,8 @@ #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) diff --git a/lib/Transforms/IPO/OldPoolAllocate.cpp b/lib/Transforms/IPO/OldPoolAllocate.cpp index 6ccd043a85c..bb990020529 100644 --- a/lib/Transforms/IPO/OldPoolAllocate.cpp +++ b/lib/Transforms/IPO/OldPoolAllocate.cpp @@ -199,6 +199,8 @@ namespace { // 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; diff --git a/lib/Transforms/IPO/SimpleStructMutation.cpp b/lib/Transforms/IPO/SimpleStructMutation.cpp index 33e02895047..c0d9ef46bc2 100644 --- a/lib/Transforms/IPO/SimpleStructMutation.cpp +++ b/lib/Transforms/IPO/SimpleStructMutation.cpp @@ -18,12 +18,13 @@ using std::set; 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); diff --git a/lib/Transforms/Instrumentation/ProfilePaths/ProfilePaths.cpp b/lib/Transforms/Instrumentation/ProfilePaths/ProfilePaths.cpp index 26fa8666161..3a44dbf918e 100644 --- a/lib/Transforms/Instrumentation/ProfilePaths/ProfilePaths.cpp +++ b/lib/Transforms/Instrumentation/ProfilePaths/ProfilePaths.cpp @@ -37,8 +37,9 @@ 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 diff --git a/lib/Transforms/Instrumentation/TraceValues.cpp b/lib/Transforms/Instrumentation/TraceValues.cpp index 384516283ca..1a9a7f3a6ab 100644 --- a/lib/Transforms/Instrumentation/TraceValues.cpp +++ b/lib/Transforms/Instrumentation/TraceValues.cpp @@ -30,6 +30,8 @@ namespace { 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. // diff --git a/lib/Transforms/LevelRaise.cpp b/lib/Transforms/LevelRaise.cpp index 07981d0aa36..f9f9abeace9 100644 --- a/lib/Transforms/LevelRaise.cpp +++ b/lib/Transforms/LevelRaise.cpp @@ -471,6 +471,8 @@ static bool doRPR(Function *F) { 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 { diff --git a/lib/Transforms/Scalar/ADCE.cpp b/lib/Transforms/Scalar/ADCE.cpp index 7f1fedec24c..bd60b519a78 100644 --- a/lib/Transforms/Scalar/ADCE.cpp +++ b/lib/Transforms/Scalar/ADCE.cpp @@ -290,6 +290,8 @@ BasicBlock *ADCE::fixupCFG(BasicBlock *BB, std::set &VisitedBlocks, 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) { diff --git a/lib/Transforms/Scalar/ConstantProp.cpp b/lib/Transforms/Scalar/ConstantProp.cpp index a8dbe3ff955..77a959910fc 100644 --- a/lib/Transforms/Scalar/ConstantProp.cpp +++ b/lib/Transforms/Scalar/ConstantProp.cpp @@ -211,6 +211,8 @@ static bool DoConstPropPass(Function *F) { namespace { struct ConstantPropogation : public FunctionPass { + const char *getPassName() const { return "Simple Constant Propogation"; } + inline bool runOnFunction(Function *F) { bool Modified = false; diff --git a/lib/Transforms/Scalar/DCE.cpp b/lib/Transforms/Scalar/DCE.cpp index 1a3073c3c74..4aac04114e0 100644 --- a/lib/Transforms/Scalar/DCE.cpp +++ b/lib/Transforms/Scalar/DCE.cpp @@ -64,6 +64,8 @@ static inline bool RemoveUnusedDefs(BasicBlock::InstListType &Vals) { } struct DeadInstElimination : public BasicBlockPass { + const char *getPassName() const { return "Dead Instruction Elimination"; } + virtual bool runOnBasicBlock(BasicBlock *BB) { return RemoveUnusedDefs(BB->getInstList()); } @@ -340,6 +342,7 @@ static bool RemoveUnusedGlobalValues(Module *Mod) { namespace { struct DeadCodeElimination : public FunctionPass { + const char *getPassName() const { return "Dead Code Elimination"; } // Pass Interface... virtual bool doInitialization(Module *M) { diff --git a/lib/Transforms/Scalar/DecomposeMultiDimRefs.cpp b/lib/Transforms/Scalar/DecomposeMultiDimRefs.cpp index 0367348ef5d..1eb582ebc4c 100644 --- a/lib/Transforms/Scalar/DecomposeMultiDimRefs.cpp +++ b/lib/Transforms/Scalar/DecomposeMultiDimRefs.cpp @@ -9,15 +9,16 @@ //===----------------------------------------------------------------------===// #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: @@ -79,8 +80,9 @@ void DecomposePass::decomposeArrayRef(BasicBlock::iterator &BBI) { // Check for a zero index. This will need a cast instead of // a getElementPtr, or it may need neither. - bool indexIsZero = isa(*OI) && - cast(*OI)->isNullValue(); + bool indexIsZero = isa(*OI) && + cast(*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), diff --git a/lib/Transforms/Scalar/GCSE.cpp b/lib/Transforms/Scalar/GCSE.cpp index b864760e688..cb24a0cbfc0 100644 --- a/lib/Transforms/Scalar/GCSE.cpp +++ b/lib/Transforms/Scalar/GCSE.cpp @@ -30,6 +30,10 @@ namespace { 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 diff --git a/lib/Transforms/Scalar/IndVarSimplify.cpp b/lib/Transforms/Scalar/IndVarSimplify.cpp index 003419bb84f..1e8621b5ed5 100644 --- a/lib/Transforms/Scalar/IndVarSimplify.cpp +++ b/lib/Transforms/Scalar/IndVarSimplify.cpp @@ -197,6 +197,10 @@ static bool doit(Function *M, LoopInfo &Loops) { namespace { struct InductionVariableSimplify : public FunctionPass { + const char *getPassName() const { + return "Induction Variable Cannonicalize"; + } + virtual bool runOnFunction(Function *F) { return doit(F, getAnalysis()); } diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp index 626c1301141..c8d2bed789c 100644 --- a/lib/Transforms/Scalar/InstructionCombining.cpp +++ b/lib/Transforms/Scalar/InstructionCombining.cpp @@ -42,6 +42,8 @@ namespace { } public: + const char *getPassName() const { return "Instruction Combining"; } + virtual bool runOnFunction(Function *F); virtual void getAnalysisUsage(AnalysisUsage &AU) const { diff --git a/lib/Transforms/Scalar/SCCP.cpp b/lib/Transforms/Scalar/SCCP.cpp index 12d518b3c8c..8271c9bce43 100644 --- a/lib/Transforms/Scalar/SCCP.cpp +++ b/lib/Transforms/Scalar/SCCP.cpp @@ -466,6 +466,10 @@ namespace { // 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(); diff --git a/lib/Transforms/Scalar/SymbolStripping.cpp b/lib/Transforms/Scalar/SymbolStripping.cpp index f99684faaf6..8320716d54b 100644 --- a/lib/Transforms/Scalar/SymbolStripping.cpp +++ b/lib/Transforms/Scalar/SymbolStripping.cpp @@ -61,6 +61,8 @@ static bool doStripGlobalSymbols(Module *M) { namespace { struct SymbolStripping : public FunctionPass { + const char *getPassName() const { return "Strip Symbols from Functions"; } + virtual bool runOnFunction(Function *F) { return doSymbolStripping(F); } @@ -70,6 +72,7 @@ namespace { }; struct FullSymbolStripping : public SymbolStripping { + const char *getPassName() const { return "Strip Symbols from Module"; } virtual bool doInitialization(Module *M) { return doStripGlobalSymbols(M); } diff --git a/lib/Transforms/Utils/LowerAllocations.cpp b/lib/Transforms/Utils/LowerAllocations.cpp index 21456a27d0d..c6cb81f0f52 100644 --- a/lib/Transforms/Utils/LowerAllocations.cpp +++ b/lib/Transforms/Utils/LowerAllocations.cpp @@ -34,6 +34,8 @@ public: 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. // @@ -54,6 +56,8 @@ class RaiseAllocations : public BasicBlockPass { 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. // @@ -216,5 +220,3 @@ Pass *createLowerAllocationsPass(const TargetData &TD) { Pass *createRaiseAllocationsPass() { return new RaiseAllocations(); } - - diff --git a/lib/Transforms/Utils/PromoteMemoryToRegister.cpp b/lib/Transforms/Utils/PromoteMemoryToRegister.cpp index e0d2c2475fc..3d81a8bde05 100644 --- a/lib/Transforms/Utils/PromoteMemoryToRegister.cpp +++ b/lib/Transforms/Utils/PromoteMemoryToRegister.cpp @@ -44,6 +44,8 @@ namespace { map > 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. // diff --git a/lib/VMCore/Pass.cpp b/lib/VMCore/Pass.cpp index 0344dd63b33..48e608e90a4 100644 --- a/lib/VMCore/Pass.cpp +++ b/lib/VMCore/Pass.cpp @@ -97,12 +97,12 @@ TimingInfo::~TimingInfo() { 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"; @@ -137,7 +137,7 @@ void PMDebug::PrintPassInformation(unsigned Depth, const char *Action, 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 "; @@ -160,7 +160,7 @@ void PMDebug::PrintAnalysisSetInfo(unsigned Depth, const char *Msg, 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"; @@ -169,7 +169,7 @@ void PMDebug::PrintAnalysisSetInfo(unsigned Depth, const char *Msg, // 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"; } @@ -181,6 +181,11 @@ void Pass::addToPassManager(PassManagerT *PM, AnalysisUsage &AU) { 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 // diff --git a/lib/VMCore/PassManagerT.h b/lib/VMCore/PassManagerT.h index 8d1716b95a0..c72af14ce2f 100644 --- a/lib/VMCore/PassManagerT.h +++ b/lib/VMCore/PassManagerT.h @@ -434,6 +434,7 @@ template<> struct PassManagerTraits : public BasicBlockPass { // 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); @@ -477,6 +478,7 @@ template<> struct PassManagerTraits : public FunctionPass { // 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); @@ -510,6 +512,7 @@ template<> struct PassManagerTraits : public Pass { // 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. diff --git a/lib/VMCore/Verifier.cpp b/lib/VMCore/Verifier.cpp index 8621ea78813..0196a99ce6f 100644 --- a/lib/VMCore/Verifier.cpp +++ b/lib/VMCore/Verifier.cpp @@ -58,6 +58,8 @@ namespace { // Anonymous namespace for class Verifier() : Broken(false) {} + virtual const char *getPassName() const { return "Module Verifier"; } + bool doInitialization(Module *M) { verifySymbolTable(M->getSymbolTable()); return false; diff --git a/tools/analyze/analyze.cpp b/tools/analyze/analyze.cpp index 6de37384705..7dbd3b7d1b5 100644 --- a/tools/analyze/analyze.cpp +++ b/tools/analyze/analyze.cpp @@ -83,6 +83,8 @@ class PassPrinter : public Pass { 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"; @@ -101,6 +103,8 @@ class PassPrinter : public FunctionPass { 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"; @@ -134,6 +138,8 @@ Pass *createPrintModulePass(const string &Message) { } struct InstForest : public FunctionPass { + const char *getPassName() const { return "InstForest Printer"; } + void doit(Function *F) { std::cout << analysis::InstForest(F); } @@ -144,6 +150,8 @@ struct InstForest : public FunctionPass { }; struct IndVars : public FunctionPass { + const char *getPassName() const { return "IndVars Printer"; } + void doit(Function *F) { LoopInfo &LI = getAnalysis(); for (inst_iterator I = inst_begin(F), E = inst_end(F); I != E; ++I) @@ -161,6 +169,8 @@ struct IndVars : public FunctionPass { }; 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) { @@ -199,7 +209,7 @@ class PrinterPass : public TraitClass { const string Message; public: PrinterPass(const string &M) : Message(M) {} - + virtual bool runOnFunction(Function *F) { std::cout << Message << " on function '" << F->getName() << "'\n";