summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2002-07-16 23:49:24 +0000
committerChris Lattner <sabre@nondot.org>2002-07-16 23:49:24 +0000
commit3378a5b5913110f9212540ab030baf59e9c39ccc (patch)
tree65c31bf7d14e0950e4a5d54f857a833071d2e68a /lib
parent23014c9b00be6bd963279bec8906d3767466c2d5 (diff)
downloadllvm-3378a5b5913110f9212540ab030baf59e9c39ccc.tar.gz
llvm-3378a5b5913110f9212540ab030baf59e9c39ccc.tar.bz2
llvm-3378a5b5913110f9212540ab030baf59e9c39ccc.tar.xz
* Add a bunch of debugging features to LevelRaise
- Verify the function every time it is exprconverted if DEBUG is on - Provide a way to start exprconversion AT a specific instruction. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@2934 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/Transforms/LevelRaise.cpp41
1 files changed, 37 insertions, 4 deletions
diff --git a/lib/Transforms/LevelRaise.cpp b/lib/Transforms/LevelRaise.cpp
index 1defda4d84..94aebcbc65 100644
--- a/lib/Transforms/LevelRaise.cpp
+++ b/lib/Transforms/LevelRaise.cpp
@@ -14,17 +14,29 @@
#include "llvm/Pass.h"
#include "llvm/ConstantHandling.h"
#include "llvm/Analysis/Expressions.h"
+#include "llvm/Analysis/Verifier.h"
#include "llvm/Transforms/Utils/BasicBlockUtils.h"
#include "Support/STLExtras.h"
#include "Support/StatisticReporter.h"
+#include "Support/CommandLine.h"
#include <algorithm>
using std::cerr;
-static Statistic<> NumLoadStorePeepholes("raise\t\t- Number of load/store peepholes");
-static Statistic<> NumGEPInstFormed("raise\t\t- Number of other getelementptr's formed");
-static Statistic<> NumExprTreesConv("raise\t\t- Number of expression trees converted");
+// StartInst - This enables the -raise-start-inst=foo option to cause the level
+// raising pass to start at instruction "foo", which is immensely useful for
+// debugging!
+//
+static cl::String StartInst("raise-start-inst", "Start raise pass at the "
+ "instruction with the specified name", cl::Hidden);
+
+static Statistic<> NumLoadStorePeepholes("raise\t\t- Number of load/store "
+ "peepholes");
+static Statistic<> NumGEPInstFormed("raise\t\t- Number of other "
+ "getelementptr's formed");
+static Statistic<> NumExprTreesConv("raise\t\t- Number of expression trees"
+ " converted");
static Statistic<> NumCastOfCast("raise\t\t- Number of cast-of-self removed");
-static Statistic<> NumDCEorCP("raise\t\t- Number of insts DCE'd or constprop'd");
+static Statistic<> NumDCEorCP("raise\t\t- Number of insts DCEd or constprop'd");
#define PRINT_PEEPHOLE(ID, NUM, I) \
@@ -221,6 +233,9 @@ static bool PeepholeOptimize(BasicBlock *BB, BasicBlock::iterator &BI) {
BI = BB->begin(); // Rescan basic block. BI might be invalidated.
PRINT_PEEPHOLE1("CAST-SRC-EXPR-CONV:out", E);
DEBUG(cerr << "DONE CONVERTING SRC EXPR TYPE: \n" << BB->getParent());
+
+ DEBUG(assert(verifyFunction(*BB->getParent()) == false &&
+ "Function broken!"));
++NumExprTreesConv;
return true;
}
@@ -240,6 +255,9 @@ static bool PeepholeOptimize(BasicBlock *BB, BasicBlock::iterator &BI) {
BI = BB->begin(); // Rescan basic block. BI might be invalidated.
PRINT_PEEPHOLE1("CAST-DEST-EXPR-CONV:out", Src);
DEBUG(cerr << "DONE CONVERTING EXPR TYPE: \n\n" << BB->getParent());
+
+ DEBUG(assert(verifyFunction(*BB->getParent()) == false &&
+ "Function broken!"));
++NumExprTreesConv;
return true;
}
@@ -468,6 +486,21 @@ static bool doRPR(Function &F) {
//
bool Changed = false, LocalChange;
+
+ // If the StartInst option was specified, then Peephole optimize that
+ // instruction first if it occurs in this function.
+ //
+ if (!StartInst.empty()) {
+ for (Function::iterator BB = F.begin(), BBE = F.end(); BB != BBE; ++BB)
+ for (BasicBlock::iterator BI = BB->begin(); BI != BB->end(); ++BI)
+ if (BI->getName() == StartInst) {
+ bool SavedDebug = DebugFlag; // Save the DEBUG() controlling flag.
+ DebugFlag = true; // Turn on DEBUG's
+ Changed |= PeepholeOptimize(BB, BI);
+ DebugFlag = SavedDebug; // Restore DebugFlag to previous state
+ }
+ }
+
do {
DEBUG(cerr << "Looping: \n" << F);