1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-20 11:33:24 +02:00

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

llvm-svn: 31925
This commit is contained in:
Bill Wendling 2006-11-26 10:17:54 +00:00
parent 5c13d56f78
commit 999f49061f
3 changed files with 37 additions and 40 deletions

View File

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

View File

@ -23,7 +23,6 @@
#include "llvm/Support/Compiler.h" #include "llvm/Support/Compiler.h"
#include "llvm/ADT/Statistic.h" #include "llvm/ADT/Statistic.h"
#include <algorithm> #include <algorithm>
#include <iostream>
using namespace llvm; using namespace llvm;
namespace { namespace {
@ -97,7 +96,7 @@ bool LowerSwitch::runOnFunction(Function &F) {
// operator<< - Used for debugging purposes. // operator<< - Used for debugging purposes.
// //
std::ostream& operator<<(std::ostream &O, llvm_ostream& operator<<(llvm_ostream &O,
const std::vector<LowerSwitch::Case> &C) { const std::vector<LowerSwitch::Case> &C) {
O << "["; O << "[";
@ -124,14 +123,13 @@ BasicBlock* LowerSwitch::switchConvert(CaseItr Begin, CaseItr End,
unsigned Mid = Size / 2; unsigned Mid = Size / 2;
std::vector<Case> LHS(Begin, Begin + Mid); std::vector<Case> LHS(Begin, Begin + Mid);
DEBUG(std::cerr << "LHS: " << LHS << "\n"); DOUT << "LHS: " << LHS << "\n";
std::vector<Case> RHS(Begin + Mid, End); std::vector<Case> RHS(Begin + Mid, End);
DEBUG(std::cerr << "RHS: " << RHS << "\n"); DOUT << "RHS: " << RHS << "\n";
Case& Pivot = *(Begin + Mid); Case& Pivot = *(Begin + Mid);
DEBUG(std::cerr << "Pivot ==> " DOUT << "Pivot ==> "
<< cast<ConstantInt>(Pivot.first)->getSExtValue() << cast<ConstantInt>(Pivot.first)->getSExtValue() << "\n";
<< "\n");
BasicBlock* LBranch = switchConvert(LHS.begin(), LHS.end(), Val, BasicBlock* LBranch = switchConvert(LHS.begin(), LHS.end(), Val,
OrigBlock, Default); OrigBlock, Default);
@ -226,7 +224,7 @@ void LowerSwitch::processSwitchInst(SwitchInst *SI) {
Cases.push_back(Case(SI->getSuccessorValue(i), SI->getSuccessor(i))); Cases.push_back(Case(SI->getSuccessorValue(i), SI->getSuccessor(i)));
std::sort(Cases.begin(), Cases.end(), CaseCmp()); 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, BasicBlock* SwitchBlock = switchConvert(Cases.begin(), Cases.end(), Val,
OrigBlock, NewDefault); OrigBlock, NewDefault);

View File

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