Add new optional getPassName() virtual function that a Pass can override
to make debugging output a lot nicer.
llvm-svn: 2395
diff --git a/llvm/lib/Transforms/Scalar/ADCE.cpp b/llvm/lib/Transforms/Scalar/ADCE.cpp
index 7f1fede..bd60b51 100644
--- a/llvm/lib/Transforms/Scalar/ADCE.cpp
+++ b/llvm/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/llvm/lib/Transforms/Scalar/ConstantProp.cpp b/llvm/lib/Transforms/Scalar/ConstantProp.cpp
index a8dbe3f..77a9599 100644
--- a/llvm/lib/Transforms/Scalar/ConstantProp.cpp
+++ b/llvm/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/llvm/lib/Transforms/Scalar/DCE.cpp b/llvm/lib/Transforms/Scalar/DCE.cpp
index 1a3073c..4aac041 100644
--- a/llvm/lib/Transforms/Scalar/DCE.cpp
+++ b/llvm/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/llvm/lib/Transforms/Scalar/DecomposeMultiDimRefs.cpp b/llvm/lib/Transforms/Scalar/DecomposeMultiDimRefs.cpp
index 0367348..1eb582e 100644
--- a/llvm/lib/Transforms/Scalar/DecomposeMultiDimRefs.cpp
+++ b/llvm/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/llvm/lib/Transforms/Scalar/GCSE.cpp b/llvm/lib/Transforms/Scalar/GCSE.cpp
index b864760..cb24a0c 100644
--- a/llvm/lib/Transforms/Scalar/GCSE.cpp
+++ b/llvm/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/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp b/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp
index 003419b..1e8621b 100644
--- a/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp
+++ b/llvm/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/llvm/lib/Transforms/Scalar/InstructionCombining.cpp b/llvm/lib/Transforms/Scalar/InstructionCombining.cpp
index 626c130..c8d2bed 100644
--- a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp
+++ b/llvm/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/llvm/lib/Transforms/Scalar/LowerAllocations.cpp b/llvm/lib/Transforms/Scalar/LowerAllocations.cpp
index 21456a2..c6cb81f 100644
--- a/llvm/lib/Transforms/Scalar/LowerAllocations.cpp
+++ b/llvm/lib/Transforms/Scalar/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/llvm/lib/Transforms/Scalar/SCCP.cpp b/llvm/lib/Transforms/Scalar/SCCP.cpp
index 12d518b..8271c9b 100644
--- a/llvm/lib/Transforms/Scalar/SCCP.cpp
+++ b/llvm/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/llvm/lib/Transforms/Scalar/SymbolStripping.cpp b/llvm/lib/Transforms/Scalar/SymbolStripping.cpp
index f99684f..8320716 100644
--- a/llvm/lib/Transforms/Scalar/SymbolStripping.cpp
+++ b/llvm/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);
}