Add new optional getPassName() virtual function that a Pass can override
authorChris Lattner <sabre@nondot.org>
Mon, 29 Apr 2002 14:57:45 +0000 (14:57 +0000)
committerChris Lattner <sabre@nondot.org>
Mon, 29 Apr 2002 14:57:45 +0000 (14:57 +0000)
to make debugging output a lot nicer.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@2395 91177308-0d34-0410-b5e6-96231b3b80d8

49 files changed:
include/llvm/Analysis/CallGraph.h
include/llvm/Analysis/DataStructure.h
include/llvm/Analysis/DataStructure/DataStructure.h
include/llvm/Analysis/Dominators.h
include/llvm/Analysis/FindUnsafePointerTypes.h
include/llvm/Analysis/FindUsedTypes.h
include/llvm/Analysis/IntervalPartition.h
include/llvm/Analysis/LiveVar/FunctionLiveVarInfo.h
include/llvm/Analysis/LoopInfo.h
include/llvm/Assembly/PrintModulePass.h
include/llvm/Bytecode/WriteBytecodePass.h
include/llvm/CodeGen/FunctionLiveVarInfo.h
include/llvm/Pass.h
include/llvm/Transforms/Scalar/InductionVars.h
include/llvm/Transforms/Utils/UnifyFunctionExitNodes.h
lib/CodeGen/InstrSched/InstrScheduling.cpp
lib/CodeGen/RegAlloc/PhyRegAlloc.cpp
lib/Target/SparcV9/EmitBytecodeToAssembly.cpp
lib/Target/SparcV9/InstrSched/InstrScheduling.cpp
lib/Target/SparcV9/RegAlloc/PhyRegAlloc.cpp
lib/Target/SparcV9/SparcV9AsmPrinter.cpp
lib/Target/SparcV9/SparcV9PrologEpilogInserter.cpp
lib/Target/SparcV9/SparcV9TargetMachine.cpp
lib/Transforms/HoistPHIConstants.cpp
lib/Transforms/IPO/ConstantMerge.cpp
lib/Transforms/IPO/DeadTypeElimination.cpp
lib/Transforms/IPO/GlobalDCE.cpp
lib/Transforms/IPO/InlineSimple.cpp
lib/Transforms/IPO/Internalize.cpp
lib/Transforms/IPO/OldPoolAllocate.cpp
lib/Transforms/IPO/SimpleStructMutation.cpp
lib/Transforms/Instrumentation/ProfilePaths/ProfilePaths.cpp
lib/Transforms/Instrumentation/TraceValues.cpp
lib/Transforms/LevelRaise.cpp
lib/Transforms/Scalar/ADCE.cpp
lib/Transforms/Scalar/ConstantProp.cpp
lib/Transforms/Scalar/DCE.cpp
lib/Transforms/Scalar/DecomposeMultiDimRefs.cpp
lib/Transforms/Scalar/GCSE.cpp
lib/Transforms/Scalar/IndVarSimplify.cpp
lib/Transforms/Scalar/InstructionCombining.cpp
lib/Transforms/Scalar/SCCP.cpp
lib/Transforms/Scalar/SymbolStripping.cpp
lib/Transforms/Utils/LowerAllocations.cpp
lib/Transforms/Utils/PromoteMemoryToRegister.cpp
lib/VMCore/Pass.cpp
lib/VMCore/PassManagerT.h
lib/VMCore/Verifier.cpp
tools/analyze/analyze.cpp

index 61693876c41c24233d7291776630efe8b9241b03..035d4abc9c40d6000d324823c813bc7c4e2ad1cc 100644 (file)
@@ -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);
 
index 90a4b5df233f4a2edb18892adcc4c0781eba411c..f6b60b8386913c5d9ad1144a991396fd8824119f 100644 (file)
@@ -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; }
 
index 90a4b5df233f4a2edb18892adcc4c0781eba411c..f6b60b8386913c5d9ad1144a991396fd8824119f 100644 (file)
@@ -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; }
 
index 3a29eec6c887bb1a0770ee0402a28296fbcca3c8..e3038da1951f651fc9644fb25b1e19467317316a 100644 (file)
@@ -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;
index 82cc28a06f4a57084be093d510f0e80fa97657eb..98f530caaa8f8c44963c21ecc6538dde3596e904 100644 (file)
@@ -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<PointerType*> &getUnsafeTypes() const {
     return UnsafeTypes;
index 5c02b2cc5fcb1b295670d3a45bb49a3e6dd232f4..ece390e489fe5320c9e57c2920701e1372e856f9 100644 (file)
@@ -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.
index 281b32ed0e85c753140cafcbb82764755b1eed73..ab16250e83c397eae177f586f1cc310422e9363d 100644 (file)
@@ -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);
 
index 4f7db3fb88f96d0e2af76e8c1a051a18c1a7ae28..dab6d3c7f3d4dd35e77c6e9a4e4b342e402f0655 100644 (file)
@@ -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.
index b56de0f80699dc1b98a2ba0b2e952ea4df2c5e42..bb9058c256e4a3434c29d641067eb6f6e2a6fa08 100644 (file)
@@ -72,6 +72,8 @@ public:
   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
index 2d63e6d74f12b3c4517ede59abb6ccbefa3d7e65..83cd852f130f5b174c687d3f0fda3d2f0b95e7c1 100644 (file)
@@ -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;
index bd9d42369ecb7baaa91f015e1d64b906edcba889..84e491a7d90f916ec5f566c0383895e61ddae9f8 100644 (file)
@@ -19,6 +19,8 @@ public:
     : Out(o), DeleteStream(DS) {
   }
 
+  const char *getPassName() const { return "Bytecode Writer"; }
+
   inline ~WriteBytecodePass() {
     if (DeleteStream) delete Out;
   }
index 4f7db3fb88f96d0e2af76e8c1a051a18c1a7ae28..dab6d3c7f3d4dd35e77c6e9a4e4b342e402f0655 100644 (file)
@@ -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.
index bd040b999356e60e2ca5f04dd0cd923956237b58..3c89130cbae18b1d1d71148771126eae3b9262ff 100644 (file)
@@ -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
index 196bb1f10a22bf1e1bb45092ac1d23e3a2d51a5a..704617c594b2b4256691f0cd2486440fb3b1af5d 100644 (file)
@@ -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);
index a6f259a57db5bd7885a0c0aa30e882faa9622f98..6281c8aa4a761dc2d5cb5ef7a31675de9be4d6d7 100644 (file)
@@ -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.
index 4c2a28c788255d3f156e3d1daa6e152f297183d5..b0422797475193f48454333b4e5fb23dbe22d28e 100644 (file)
@@ -1484,6 +1484,8 @@ namespace {
     const TargetMachine &target;
   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 {
index 4ad98d917fd592f85cf17df0d1c67d4dc571ca02..b783255699f85d6e2fa33f2889a4f212a6c6bcff 100644 (file)
@@ -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)
index 92420f9421f4c68e1a82bb654daa841078eed8f1..fdf8f3ec3614a911214ee7724b551cb276293887 100644 (file)
@@ -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";
index 4c2a28c788255d3f156e3d1daa6e152f297183d5..b0422797475193f48454333b4e5fb23dbe22d28e 100644 (file)
@@ -1484,6 +1484,8 @@ namespace {
     const TargetMachine &target;
   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 {
index 4ad98d917fd592f85cf17df0d1c67d4dc571ca02..b783255699f85d6e2fa33f2889a4f212a6c6bcff 100644 (file)
@@ -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)
index f4ca22f9da90c9e186e31880080edc0fec3b2334..8d87bfec6beda57dbca0bcdfa8bc5d37e109f574 100644 (file)
@@ -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);
index 17cd73bfc3428bb92fdb61447f72b42e4b56b81b..b42e77715678994d5e86b9f86851c567ef40f2a1 100644 (file)
@@ -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()) {
index 306b85a2272fdb945270534784a0297101b08868..fecdf23e29a48dc870dd9746837254ee5f470c3e 100644 (file)
@@ -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);
   }
index e969ac24b3ac5ec8cbb2470b1a3c1648426441e1..05480ea9503190983e1eac24d5232f0b1c25ff46 100644 (file)
@@ -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 {
index a635b8d21bed9982cbbc69fca5fe179a743b62c8..146911e818ddb217892a23773b9b94a96b1e1df1 100644 (file)
@@ -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.
     //
index 3ba6057fad2ce513712d951b015a3c4a9dba2bd7..dc330b29f8a16ab5dbfd72dbd7f4bd35a4cbcb97 100644 (file)
@@ -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);
   };
 }
index cd9c35f058a5523ea8439ae71d8656f9e586a03e..e852a6a29fcf67ea80b3139e37b28476cd36f6ac 100644 (file)
@@ -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.
     //
index 1581323bea14b73d7483b9c91b2f49c029afec93..ba64a6abce00cfb2ba7c24ed3db01283abaae86a 100644 (file)
@@ -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);
     }
index 8bb1a9c111c59186269fe7de7a54d8f3cde913ad..c84be9b93a295ef61a2d0b843cde37eace2bf1c6 100644 (file)
@@ -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)
index 6ccd043a85cf8a52d211d17a7ecca280db92ed76..bb990020529259545008a81c0253126c3d151840 100644 (file)
@@ -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;
index 33e028950476a639f707c1e18c9f3920732d6e62..c0d9ef46bc29e88c408bc052924da221855a081e 100644 (file)
@@ -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);
index 26fa86661614d354c373e95bc077d98151362dd5..3a44dbf918e63b15947aa027a56f2ccb9f580d59 100644 (file)
@@ -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 
index 384516283ca4525eab3297f91ca66eab1394b175..1a9a7f3a6ab7e0f06e5dff7678b343ab174bf21b 100644 (file)
@@ -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.
     //
index 07981d0aa361759cfff328c8b1efe471ebae2571..f9f9abeace97d5a19d81be3e78fb5fee93ae554c 100644 (file)
@@ -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 {
index 7f1fedec24ca713398ccbaf09dd72293373a3c01..bd60b519a784608cd2d649d162d9556b8b034be3 100644 (file)
@@ -290,6 +290,8 @@ BasicBlock *ADCE::fixupCFG(BasicBlock *BB, std::set<BasicBlock*> &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) {
index a8dbe3ff9551ae3eae9ae8b9fe62732da63e3881..77a959910fcc5c2856e969d24b6ceef565c0eb8a 100644 (file)
@@ -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;
 
index 1a3073c3c745199c26624b8ddd5f4ebfe6165cc5..4aac04114e0c33ad843af56dfc5a03d1ce49cea8 100644 (file)
@@ -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) {
index 0367348ef5d81f62dac0218721456719198ae7ec..1eb582ebc4c79f1161d2847b7d030f15dbd35a00 100644 (file)
@@ -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<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), 
index b864760e688f83acedb465b5ee4bc554aca118b7..cb24a0cbfc0815a97b12f5aaf886ad13656058e3 100644 (file)
@@ -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
index 003419bb84fb40b06a2b368dceea00be232cf1a2..1e8621b5ed57633df75243d622768691dd58d382 100644 (file)
@@ -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<LoopInfo>());
     }
index 626c1301141b872fe7b129cf541cd78502f371f4..c8d2bed789c2881c909797fad5443e302824641e 100644 (file)
@@ -42,6 +42,8 @@ namespace {
     }
 
   public:
+    const char *getPassName() const { return "Instruction Combining"; }
+
     virtual bool runOnFunction(Function *F);
 
     virtual void getAnalysisUsage(AnalysisUsage &AU) const {
index 12d518b3c8cf86140c893cd56ae4c3b1d6d26112..8271c9bce438ff2bc55364ed73ff8230812329ff 100644 (file)
@@ -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();
index f99684faaf671b549304a2876f58b5a2e8e10407..8320716d54b5f9055c1fd7bb41648b263e163d8b 100644 (file)
@@ -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);
     }
index 21456a27d0d1ed811b0046e3e0946e3e8fa83743..c6cb81f0f52a6f4defa60b62bc19c7dd4d67f549 100644 (file)
@@ -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();
 }
-
-
index e0d2c2475fcc5b322f73376a4ab9b42db56abde3..3d81a8bde05c08023cd9b08b261ef8450e958f29 100644 (file)
@@ -44,6 +44,8 @@ namespace {
     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.
     //
index 0344dd63b335197924686ba77d42a6b3a6d66c08..48e608e90a41b77b7dc25238d34fa17d682548d0 100644 (file)
@@ -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<Module> *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
 //
index 8d1716b95a0776a5884055f4161de7e5261b0798..c72af14ce2fb1e51e67d8351b41019778dd3039b 100644 (file)
@@ -434,6 +434,7 @@ template<> struct PassManagerTraits<BasicBlock> : 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<Function> : 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<Module> : 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.
index 8621ea78813b8e92b106336c5cbb8c7b1f36e22d..0196a99ce6f907286938c42a75adc35e43a6afb8 100644 (file)
@@ -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;
index 6de37384705ba1053d5508df0f70c879690ca067..7dbd3b7d1b58a85cad40c212bce8e145b3937db8 100644 (file)
@@ -83,6 +83,8 @@ class PassPrinter<Pass, PassName> : 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<FunctionPass, PassName> : 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<char>(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<LoopInfo>();
     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";