diff options
author | Chris Lattner <sabre@nondot.org> | 2002-05-22 17:17:27 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2002-05-22 17:17:27 +0000 |
commit | f016ea4ff80c56c467247a90567dd07bddb590f3 (patch) | |
tree | 83ccc99063e91b0f13ad44491575a52378fa0cb5 /lib/Transforms/Scalar/ADCE.cpp | |
parent | 70e60cbd4dd59b61e3e9d0a55f24cf92b0dc8724 (diff) |
Use the new DEBUG(x) macro to allow debugging code to be enabled on the commandline
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@2713 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Scalar/ADCE.cpp')
-rw-r--r-- | lib/Transforms/Scalar/ADCE.cpp | 41 |
1 files changed, 15 insertions, 26 deletions
diff --git a/lib/Transforms/Scalar/ADCE.cpp b/lib/Transforms/Scalar/ADCE.cpp index 4c0169171b..20a34c1c7e 100644 --- a/lib/Transforms/Scalar/ADCE.cpp +++ b/lib/Transforms/Scalar/ADCE.cpp @@ -16,12 +16,11 @@ #include "llvm/Support/CFG.h" #include "Support/STLExtras.h" #include "Support/DepthFirstIterator.h" +#include "Support/StatisticReporter.h" #include <algorithm> #include <iostream> using std::cerr; -#define DEBUG_ADCE 1 - namespace { //===----------------------------------------------------------------------===// @@ -69,17 +68,13 @@ private: inline void markInstructionLive(Instruction *I) { if (LiveSet.count(I)) return; -#ifdef DEBUG_ADCE - cerr << "Insn Live: " << I; -#endif + DEBUG(cerr << "Insn Live: " << I); LiveSet.insert(I); WorkList.push_back(I); } inline void markTerminatorLive(const BasicBlock *BB) { -#ifdef DEBUG_ADCE - cerr << "Terminat Live: " << BB->getTerminator(); -#endif + DEBUG(cerr << "Terminat Live: " << BB->getTerminator()); markInstructionLive((Instruction*)BB->getTerminator()); } @@ -101,9 +96,7 @@ Pass *createAggressiveDCEPass() { // true if the function was modified. // void ADCE::doADCE(DominanceFrontier &CDG) { -#ifdef DEBUG_ADCE - cerr << "Function: " << Func; -#endif + DEBUG(cerr << "Function: " << Func); // Iterate over all of the instructions in the function, eliminating trivially // dead instructions, and marking instructions live that are known to be @@ -130,9 +123,7 @@ void ADCE::doADCE(DominanceFrontier &CDG) { } } -#ifdef DEBUG_ADCE - cerr << "Processing work list\n"; -#endif + DEBUG(cerr << "Processing work list\n"); // AliveBlocks - Set of basic blocks that we know have instructions that are // alive in them... @@ -173,15 +164,15 @@ void ADCE::doADCE(DominanceFrontier &CDG) { markInstructionLive(Operand); } -#ifdef DEBUG_ADCE - cerr << "Current Function: X = Live\n"; - for (Function::iterator I = Func->begin(), E = Func->end(); I != E; ++I) - for (BasicBlock::iterator BI = (*I)->begin(), BE = (*I)->end(); - BI != BE; ++BI) { - if (LiveSet.count(*BI)) cerr << "X "; - cerr << *BI; - } -#endif + if (DebugFlag) { + cerr << "Current Function: X = Live\n"; + for (Function::iterator I = Func->begin(), E = Func->end(); I != E; ++I) + for (BasicBlock::iterator BI = (*I)->begin(), BE = (*I)->end(); + BI != BE; ++BI) { + if (LiveSet.count(*BI)) cerr << "X "; + cerr << *BI; + } + } // After the worklist is processed, recursively walk the CFG in depth first // order, patching up references to dead blocks... @@ -266,9 +257,7 @@ BasicBlock *ADCE::fixupCFG(BasicBlock *BB, std::set<BasicBlock*> &VisitedBlocks, if (VisitedBlocks.count(BB)) return 0; // Revisiting a node? No update. VisitedBlocks.insert(BB); // We have now visited this node! -#ifdef DEBUG_ADCE - cerr << "Fixing up BB: " << BB; -#endif + DEBUG(cerr << "Fixing up BB: " << BB); if (AliveBlocks.count(BB)) { // Is the block alive? // Yes it's alive: loop through and eliminate all dead instructions in block |