[llvm-commits] CVS: llvm/lib/Transforms/Utils/CodeExtractor.cpp LowerSwitch.cpp SimplifyCFG.cpp

Bill Wendling isanbard at gmail.com
Sun Nov 26 02:18:09 PST 2006



Changes in directory llvm/lib/Transforms/Utils:

CodeExtractor.cpp updated: 1.41 -> 1.42
LowerSwitch.cpp updated: 1.25 -> 1.26
SimplifyCFG.cpp updated: 1.105 -> 1.106
---
Log message:

Remove #include <iostream> and use llvm_* streams instead.


---
Diffs of the changes:  (+37 -40)

 CodeExtractor.cpp |   22 +++++++++++-----------
 LowerSwitch.cpp   |   14 ++++++--------
 SimplifyCFG.cpp   |   41 ++++++++++++++++++++---------------------
 3 files changed, 37 insertions(+), 40 deletions(-)


Index: llvm/lib/Transforms/Utils/CodeExtractor.cpp
diff -u llvm/lib/Transforms/Utils/CodeExtractor.cpp:1.41 llvm/lib/Transforms/Utils/CodeExtractor.cpp:1.42
--- llvm/lib/Transforms/Utils/CodeExtractor.cpp:1.41	Fri Oct 20 02:07:24 2006
+++ llvm/lib/Transforms/Utils/CodeExtractor.cpp	Sun Nov 26 04:17:54 2006
@@ -29,7 +29,6 @@
 #include "llvm/ADT/StringExtras.h"
 #include <algorithm>
 #include <set>
-#include <iostream>
 using namespace llvm;
 
 // Provide a command-line option to aggregate function arguments into a struct
@@ -245,8 +244,8 @@
                                            BasicBlock *newHeader,
                                            Function *oldFunction,
                                            Module *M) {
-  DEBUG(std::cerr << "inputs: " << inputs.size() << "\n");
-  DEBUG(std::cerr << "outputs: " << outputs.size() << "\n");
+  DOUT << "inputs: " << inputs.size() << "\n";
+  DOUT << "outputs: " << outputs.size() << "\n";
 
   // This function returns unsigned, outputs will go back by reference.
   switch (NumExitBlocks) {
@@ -262,24 +261,25 @@
   for (Values::const_iterator i = inputs.begin(),
          e = inputs.end(); i != e; ++i) {
     const Value *value = *i;
-    DEBUG(std::cerr << "value used in func: " << *value << "\n");
+    DOUT << "value used in func: " << *value << "\n";
     paramTy.push_back(value->getType());
   }
 
   // Add the types of the output values to the function's argument list.
   for (Values::const_iterator I = outputs.begin(), E = outputs.end();
        I != E; ++I) {
-    DEBUG(std::cerr << "instr used in func: " << **I << "\n");
+    DOUT << "instr used in func: " << **I << "\n";
     if (AggregateArgs)
       paramTy.push_back((*I)->getType());
     else
       paramTy.push_back(PointerType::get((*I)->getType()));
   }
 
-  DEBUG(std::cerr << "Function type: " << *RetTy << " f(");
-  DEBUG(for (std::vector<const Type*>::iterator i = paramTy.begin(),
-               e = paramTy.end(); i != e; ++i) std::cerr << **i << ", ");
-  DEBUG(std::cerr << ")\n");
+  DOUT << "Function type: " << *RetTy << " f(";
+  for (std::vector<const Type*>::iterator i = paramTy.begin(),
+         e = paramTy.end(); i != e; ++i)
+    DOUT << **i << ", ";
+  DOUT << ")\n";
 
   if (AggregateArgs && (inputs.size() + outputs.size() > 0)) {
     PointerType *StructPtr = PointerType::get(StructType::get(paramTy));
@@ -699,10 +699,10 @@
           }
     }
 
-  //std::cerr << "NEW FUNCTION: " << *newFunction;
+  //llvm_cerr << "NEW FUNCTION: " << *newFunction;
   //  verifyFunction(*newFunction);
 
-  //  std::cerr << "OLD FUNCTION: " << *oldFunction;
+  //  llvm_cerr << "OLD FUNCTION: " << *oldFunction;
   //  verifyFunction(*oldFunction);
 
   DEBUG(if (verifyFunction(*newFunction)) abort());


Index: llvm/lib/Transforms/Utils/LowerSwitch.cpp
diff -u llvm/lib/Transforms/Utils/LowerSwitch.cpp:1.25 llvm/lib/Transforms/Utils/LowerSwitch.cpp:1.26
--- llvm/lib/Transforms/Utils/LowerSwitch.cpp:1.25	Fri Oct 20 02:07:24 2006
+++ llvm/lib/Transforms/Utils/LowerSwitch.cpp	Sun Nov 26 04:17:54 2006
@@ -23,7 +23,6 @@
 #include "llvm/Support/Compiler.h"
 #include "llvm/ADT/Statistic.h"
 #include <algorithm>
-#include <iostream>
 using namespace llvm;
 
 namespace {
@@ -97,7 +96,7 @@
 
 // operator<< - Used for debugging purposes.
 //
-std::ostream& operator<<(std::ostream &O,
+llvm_ostream& operator<<(llvm_ostream &O,
                          const std::vector<LowerSwitch::Case> &C) {
   O << "[";
 
@@ -124,14 +123,13 @@
 
   unsigned Mid = Size / 2;
   std::vector<Case> LHS(Begin, Begin + Mid);
-  DEBUG(std::cerr << "LHS: " << LHS << "\n");
+  DOUT << "LHS: " << LHS << "\n";
   std::vector<Case> RHS(Begin + Mid, End);
-  DEBUG(std::cerr << "RHS: " << RHS << "\n");
+  DOUT << "RHS: " << RHS << "\n";
 
   Case& Pivot = *(Begin + Mid);
-  DEBUG(std::cerr << "Pivot ==> "
-                  << cast<ConstantInt>(Pivot.first)->getSExtValue()
-                  << "\n");
+  DOUT << "Pivot ==> "
+       << cast<ConstantInt>(Pivot.first)->getSExtValue() << "\n";
 
   BasicBlock* LBranch = switchConvert(LHS.begin(), LHS.end(), Val,
                                       OrigBlock, Default);
@@ -226,7 +224,7 @@
     Cases.push_back(Case(SI->getSuccessorValue(i), SI->getSuccessor(i)));
 
   std::sort(Cases.begin(), Cases.end(), CaseCmp());
-  DEBUG(std::cerr << "Cases: " << Cases << "\n");
+  DOUT << "Cases: " << Cases << "\n";
   BasicBlock* SwitchBlock = switchConvert(Cases.begin(), Cases.end(), Val,
                                           OrigBlock, NewDefault);
 


Index: llvm/lib/Transforms/Utils/SimplifyCFG.cpp
diff -u llvm/lib/Transforms/Utils/SimplifyCFG.cpp:1.105 llvm/lib/Transforms/Utils/SimplifyCFG.cpp:1.106
--- llvm/lib/Transforms/Utils/SimplifyCFG.cpp:1.105	Sat Nov 18 13:19:36 2006
+++ llvm/lib/Transforms/Utils/SimplifyCFG.cpp	Sun Nov 26 04:17:54 2006
@@ -23,7 +23,6 @@
 #include <functional>
 #include <set>
 #include <map>
-#include <iostream>
 using namespace llvm;
 
 /// SafeToMergeTerminators - Return true if it is safe to merge these two
@@ -149,7 +148,7 @@
   //
   if (!CanPropagatePredecessorsForPHIs(BB, Succ)) return false;
   
-  DEBUG(std::cerr << "Killing Trivial BB: \n" << *BB);
+  DOUT << "Killing Trivial BB: \n" << *BB;
   
   if (isa<PHINode>(Succ->begin())) {
     // If there is more than one pred of succ, and there are PHI nodes in
@@ -629,8 +628,8 @@
         // Remove PHI node entries for the dead edge.
         ThisCases[0].second->removePredecessor(TI->getParent());
 
-        DEBUG(std::cerr << "Threading pred instr: " << *Pred->getTerminator()
-              << "Through successor TI: " << *TI << "Leaving: " << *NI << "\n");
+        DOUT << "Threading pred instr: " << *Pred->getTerminator()
+             << "Through successor TI: " << *TI << "Leaving: " << *NI << "\n";
 
         TI->eraseFromParent();   // Nuke the old one.
         // If condition is now dead, nuke it.
@@ -645,8 +644,8 @@
         for (unsigned i = 0, e = PredCases.size(); i != e; ++i)
           DeadCases.insert(PredCases[i].first);
 
-        DEBUG(std::cerr << "Threading pred instr: " << *Pred->getTerminator()
-                  << "Through successor TI: " << *TI);
+        DOUT << "Threading pred instr: " << *Pred->getTerminator()
+             << "Through successor TI: " << *TI;
 
         for (unsigned i = SI->getNumCases()-1; i != 0; --i)
           if (DeadCases.count(SI->getCaseValue(i))) {
@@ -654,7 +653,7 @@
             SI->removeCase(i);
           }
 
-        DEBUG(std::cerr << "Leaving: " << *TI << "\n");
+        DOUT << "Leaving: " << *TI << "\n";
         return true;
       }
     }
@@ -695,8 +694,8 @@
     // Insert the new branch.
     Instruction *NI = new BranchInst(TheRealDest, TI);
 
-    DEBUG(std::cerr << "Threading pred instr: " << *Pred->getTerminator()
-          << "Through successor TI: " << *TI << "Leaving: " << *NI << "\n");
+    DOUT << "Threading pred instr: " << *Pred->getTerminator()
+         << "Through successor TI: " << *TI << "Leaving: " << *NI << "\n";
     Instruction *Cond = 0;
     if (BranchInst *BI = dyn_cast<BranchInst>(TI))
       Cond = dyn_cast<Instruction>(BI->getCondition());
@@ -1074,8 +1073,8 @@
     if (NumPhis > 2)
       return false;
   
-  DEBUG(std::cerr << "FOUND IF CONDITION!  " << *IfCond << "  T: "
-        << IfTrue->getName() << "  F: " << IfFalse->getName() << "\n");
+  DOUT << "FOUND IF CONDITION!  " << *IfCond << "  T: "
+       << IfTrue->getName() << "  F: " << IfFalse->getName() << "\n";
   
   // Loop over the PHI's seeing if we can promote them all to select
   // instructions.  While we are at it, keep track of the instructions
@@ -1194,7 +1193,7 @@
   // Remove basic blocks that have no predecessors... which are unreachable.
   if (pred_begin(BB) == pred_end(BB) ||
       *pred_begin(BB) == BB && ++pred_begin(BB) == pred_end(BB)) {
-    DEBUG(std::cerr << "Removing BB: \n" << *BB);
+    DOUT << "Removing BB: \n" << *BB;
 
     // Loop through all of our successors and make sure they know that one
     // of their predecessors is going away.
@@ -1248,8 +1247,8 @@
       if (!UncondBranchPreds.empty()) {
         while (!UncondBranchPreds.empty()) {
           BasicBlock *Pred = UncondBranchPreds.back();
-          DEBUG(std::cerr << "FOLDING: " << *BB
-                          << "INTO UNCOND BRANCH PRED: " << *Pred);
+          DOUT << "FOLDING: " << *BB
+               << "INTO UNCOND BRANCH PRED: " << *Pred;
           UncondBranchPreds.pop_back();
           Instruction *UncondBranch = Pred->getTerminator();
           // Clone the return and add it to the end of the predecessor.
@@ -1336,9 +1335,9 @@
               else
                 NewRetVal = TrueValue;
               
-              DEBUG(std::cerr << "\nCHANGING BRANCH TO TWO RETURNS INTO SELECT:"
-                    << "\n  " << *BI << "Select = " << *NewRetVal
-                    << "TRUEBLOCK: " << *TrueSucc << "FALSEBLOCK: "<< *FalseSucc);
+              DOUT << "\nCHANGING BRANCH TO TWO RETURNS INTO SELECT:"
+                   << "\n  " << *BI << "Select = " << *NewRetVal
+                   << "TRUEBLOCK: " << *TrueSucc << "FALSEBLOCK: "<< *FalseSucc;
 
               new ReturnInst(NewRetVal, BI);
               BI->eraseFromParent();
@@ -1594,8 +1593,8 @@
                 if (OtherDest == BB)
                   OtherDest = CommonDest;
                 
-                DEBUG(std::cerr << "FOLDING BRs:" << *PBI->getParent()
-                                << "AND: " << *BI->getParent());
+                DOUT << "FOLDING BRs:" << *PBI->getParent()
+                     << "AND: " << *BI->getParent();
                                 
                 // BI may have other predecessors.  Because of this, we leave
                 // it alone, but modify PBI.
@@ -1646,7 +1645,7 @@
                   }
                 }
 
-                DEBUG(std::cerr << "INTO: " << *PBI->getParent());
+                DOUT << "INTO: " << *PBI->getParent();
 
                 // This basic block is probably dead.  We know it has at least
                 // one fewer predecessor.
@@ -1791,7 +1790,7 @@
   }
 
   if (OnlySucc) {
-    DEBUG(std::cerr << "Merging: " << *BB << "into: " << *OnlyPred);
+    DOUT << "Merging: " << *BB << "into: " << *OnlyPred;
 
     // Resolve any PHI nodes at the start of the block.  They are all
     // guaranteed to have exactly one entry if they exist, unless there are






More information about the llvm-commits mailing list