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
diff --git a/lib/Transforms/HoistPHIConstants.cpp b/lib/Transforms/HoistPHIConstants.cpp
index e969ac2..05480ea 100644
--- a/lib/Transforms/HoistPHIConstants.cpp
+++ b/lib/Transforms/HoistPHIConstants.cpp
@@ -75,6 +75,8 @@
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 a635b8d..146911e 100644
--- a/lib/Transforms/IPO/ConstantMerge.cpp
+++ b/lib/Transforms/IPO/ConstantMerge.cpp
@@ -65,6 +65,8 @@
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 @@
};
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 3ba6057..dc330b2 100644
--- a/lib/Transforms/IPO/DeadTypeElimination.cpp
+++ b/lib/Transforms/IPO/DeadTypeElimination.cpp
@@ -36,6 +36,8 @@
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 @@
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 cd9c35f..e852a6a 100644
--- a/lib/Transforms/IPO/GlobalDCE.cpp
+++ b/lib/Transforms/IPO/GlobalDCE.cpp
@@ -49,6 +49,8 @@
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 1581323..ba64a6a 100644
--- a/lib/Transforms/IPO/InlineSimple.cpp
+++ b/lib/Transforms/IPO/InlineSimple.cpp
@@ -271,6 +271,7 @@
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 8bb1a9c..c84be9b 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 6ccd043..bb99002 100644
--- a/lib/Transforms/IPO/OldPoolAllocate.cpp
+++ b/lib/Transforms/IPO/OldPoolAllocate.cpp
@@ -199,6 +199,8 @@
// 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 33e0289..c0d9ef4 100644
--- a/lib/Transforms/IPO/SimpleStructMutation.cpp
+++ b/lib/Transforms/IPO/SimpleStructMutation.cpp
@@ -18,12 +18,13 @@
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 26fa866..3a44dbf 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 3845162..1a9a7f3 100644
--- a/lib/Transforms/Instrumentation/TraceValues.cpp
+++ b/lib/Transforms/Instrumentation/TraceValues.cpp
@@ -30,6 +30,8 @@
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 07981d0..f9f9abe 100644
--- a/lib/Transforms/LevelRaise.cpp
+++ b/lib/Transforms/LevelRaise.cpp
@@ -471,6 +471,8 @@
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 7f1fede..bd60b51 100644
--- a/lib/Transforms/Scalar/ADCE.cpp
+++ b/lib/Transforms/Scalar/ADCE.cpp
@@ -290,6 +290,8 @@
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 a8dbe3f..77a9599 100644
--- a/lib/Transforms/Scalar/ConstantProp.cpp
+++ b/lib/Transforms/Scalar/ConstantProp.cpp
@@ -211,6 +211,8 @@
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 1a3073c..4aac041 100644
--- a/lib/Transforms/Scalar/DCE.cpp
+++ b/lib/Transforms/Scalar/DCE.cpp
@@ -64,6 +64,8 @@
}
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 @@
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 0367348..1eb582e 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 @@
// 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),
diff --git a/lib/Transforms/Scalar/GCSE.cpp b/lib/Transforms/Scalar/GCSE.cpp
index b864760..cb24a0c 100644
--- a/lib/Transforms/Scalar/GCSE.cpp
+++ b/lib/Transforms/Scalar/GCSE.cpp
@@ -30,6 +30,10 @@
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 003419b..1e8621b 100644
--- a/lib/Transforms/Scalar/IndVarSimplify.cpp
+++ b/lib/Transforms/Scalar/IndVarSimplify.cpp
@@ -197,6 +197,10 @@
namespace {
struct InductionVariableSimplify : public FunctionPass {
+ const char *getPassName() const {
+ return "Induction Variable Cannonicalize";
+ }
+
virtual bool runOnFunction(Function *F) {
return doit(F, getAnalysis<LoopInfo>());
}
diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp
index 626c130..c8d2bed 100644
--- a/lib/Transforms/Scalar/InstructionCombining.cpp
+++ b/lib/Transforms/Scalar/InstructionCombining.cpp
@@ -42,6 +42,8 @@
}
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 12d518b..8271c9b 100644
--- a/lib/Transforms/Scalar/SCCP.cpp
+++ b/lib/Transforms/Scalar/SCCP.cpp
@@ -466,6 +466,10 @@
// 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 f99684f..8320716 100644
--- a/lib/Transforms/Scalar/SymbolStripping.cpp
+++ b/lib/Transforms/Scalar/SymbolStripping.cpp
@@ -61,6 +61,8 @@
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 @@
};
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 21456a2..c6cb81f 100644
--- a/lib/Transforms/Utils/LowerAllocations.cpp
+++ b/lib/Transforms/Utils/LowerAllocations.cpp
@@ -34,6 +34,8 @@
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 @@
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 *createRaiseAllocationsPass() {
return new RaiseAllocations();
}
-
-
diff --git a/lib/Transforms/Utils/PromoteMemoryToRegister.cpp b/lib/Transforms/Utils/PromoteMemoryToRegister.cpp
index e0d2c24..3d81a8b 100644
--- a/lib/Transforms/Utils/PromoteMemoryToRegister.cpp
+++ b/lib/Transforms/Utils/PromoteMemoryToRegister.cpp
@@ -44,6 +44,8 @@
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.
//