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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31925 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Bill Wendling 2006-11-26 10:17:54 +00:00
parent 0a81aac4b4
commit 0d45a096cf
3 changed files with 37 additions and 40 deletions

View File

@ -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 @@ Function *CodeExtractor::constructFunction(const Values &inputs,
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 @@ Function *CodeExtractor::constructFunction(const Values &inputs,
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 @@ ExtractCodeRegion(const std::vector<BasicBlock*> &code) {
}
}
//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());

View File

@ -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 @@ bool LowerSwitch::runOnFunction(Function &F) {
// 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 @@ BasicBlock* LowerSwitch::switchConvert(CaseItr Begin, CaseItr End,
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 @@ void LowerSwitch::processSwitchInst(SwitchInst *SI) {
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);

View File

@ -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 @@ static bool TryToSimplifyUncondBranchFromEmptyBlock(BasicBlock *BB,
//
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 @@ static bool SimplifyEqualityComparisonWithOnlyPredecessor(TerminatorInst *TI,
// 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 @@ static bool SimplifyEqualityComparisonWithOnlyPredecessor(TerminatorInst *TI,
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 @@ static bool SimplifyEqualityComparisonWithOnlyPredecessor(TerminatorInst *TI,
SI->removeCase(i);
}
DEBUG(std::cerr << "Leaving: " << *TI << "\n");
DOUT << "Leaving: " << *TI << "\n";
return true;
}
}
@ -695,8 +694,8 @@ static bool SimplifyEqualityComparisonWithOnlyPredecessor(TerminatorInst *TI,
// 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 @@ static bool FoldTwoEntryPHINode(PHINode *PN) {
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 @@ bool llvm::SimplifyCFG(BasicBlock *BB) {
// 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 @@ bool llvm::SimplifyCFG(BasicBlock *BB) {
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 @@ bool llvm::SimplifyCFG(BasicBlock *BB) {
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 @@ bool llvm::SimplifyCFG(BasicBlock *BB) {
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 @@ bool llvm::SimplifyCFG(BasicBlock *BB) {
}
}
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 @@ bool llvm::SimplifyCFG(BasicBlock *BB) {
}
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