summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBill Wendling <isanbard@gmail.com>2006-11-26 09:46:52 +0000
committerBill Wendling <isanbard@gmail.com>2006-11-26 09:46:52 +0000
commitb7427031372337e6d67f9573ec6c722ab5ea913e (patch)
tree81d17a2f061f022381d1f4104579aaa51ca84f31
parent62c804a3ea537a83f307ed9c2788138cc47cc2ed (diff)
downloadllvm-b7427031372337e6d67f9573ec6c722ab5ea913e.tar.gz
llvm-b7427031372337e6d67f9573ec6c722ab5ea913e.tar.bz2
llvm-b7427031372337e6d67f9573ec6c722ab5ea913e.tar.xz
Removed #include <iostream> and replaced with llvm_* streams.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31923 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Transforms/Scalar/ADCE.cpp17
-rw-r--r--lib/Transforms/Scalar/CondPropagate.cpp2
-rw-r--r--lib/Transforms/Scalar/InstructionCombining.cpp21
-rw-r--r--lib/Transforms/Scalar/LICM.cpp8
-rw-r--r--lib/Transforms/Scalar/LoopStrengthReduce.cpp39
-rw-r--r--lib/Transforms/Scalar/LoopUnroll.cpp13
-rw-r--r--lib/Transforms/Scalar/LoopUnswitch.cpp35
-rw-r--r--lib/Transforms/Scalar/LowerPacked.cpp13
-rw-r--r--lib/Transforms/Scalar/SCCP.cpp45
-rw-r--r--lib/Transforms/Scalar/ScalarReplAggregates.cpp12
-rw-r--r--lib/Transforms/Scalar/TailDuplication.cpp10
11 files changed, 100 insertions, 115 deletions
diff --git a/lib/Transforms/Scalar/ADCE.cpp b/lib/Transforms/Scalar/ADCE.cpp
index 8632c7ad58..76a09f80e4 100644
--- a/lib/Transforms/Scalar/ADCE.cpp
+++ b/lib/Transforms/Scalar/ADCE.cpp
@@ -27,7 +27,6 @@
#include "llvm/ADT/Statistic.h"
#include "llvm/ADT/STLExtras.h"
#include <algorithm>
-#include <iostream>
using namespace llvm;
namespace {
@@ -92,12 +91,12 @@ private:
inline void markInstructionLive(Instruction *I) {
if (!LiveSet.insert(I).second) return;
- DEBUG(std::cerr << "Insn Live: " << *I);
+ DOUT << "Insn Live: " << *I;
WorkList.push_back(I);
}
inline void markTerminatorLive(const BasicBlock *BB) {
- DEBUG(std::cerr << "Terminator Live: " << *BB->getTerminator());
+ DOUT << "Terminator Live: " << *BB->getTerminator();
markInstructionLive(const_cast<TerminatorInst*>(BB->getTerminator()));
}
};
@@ -260,7 +259,7 @@ bool ADCE::doADCE() {
for (pred_iterator PI = pred_begin(I), E = pred_end(I); PI != E; ++PI)
markInstructionLive((*PI)->getTerminator());
- DEBUG(std::cerr << "Processing work list\n");
+ DOUT << "Processing work list\n";
// AliveBlocks - Set of basic blocks that we know have instructions that are
// alive in them...
@@ -309,13 +308,13 @@ bool ADCE::doADCE() {
}
DEBUG(
- std::cerr << "Current Function: X = Live\n";
+ DOUT << "Current Function: X = Live\n";
for (Function::iterator I = Func->begin(), E = Func->end(); I != E; ++I){
- std::cerr << I->getName() << ":\t"
- << (AliveBlocks.count(I) ? "LIVE\n" : "DEAD\n");
+ DOUT << I->getName() << ":\t"
+ << (AliveBlocks.count(I) ? "LIVE\n" : "DEAD\n");
for (BasicBlock::iterator BI = I->begin(), BE = I->end(); BI != BE; ++BI){
- if (LiveSet.count(BI)) std::cerr << "X ";
- std::cerr << *BI;
+ if (LiveSet.count(BI)) DOUT << "X ";
+ DOUT << *BI;
}
});
diff --git a/lib/Transforms/Scalar/CondPropagate.cpp b/lib/Transforms/Scalar/CondPropagate.cpp
index 703105fac6..39f699aafe 100644
--- a/lib/Transforms/Scalar/CondPropagate.cpp
+++ b/lib/Transforms/Scalar/CondPropagate.cpp
@@ -22,7 +22,7 @@
#include "llvm/Type.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/Statistic.h"
-#include <iostream>
+#include "llvm/Support/Streams.h"
using namespace llvm;
namespace {
diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp
index 5a586e022b..4e5d6639d4 100644
--- a/lib/Transforms/Scalar/InstructionCombining.cpp
+++ b/lib/Transforms/Scalar/InstructionCombining.cpp
@@ -52,7 +52,6 @@
#include "llvm/ADT/Statistic.h"
#include "llvm/ADT/STLExtras.h"
#include <algorithm>
-#include <iostream>
using namespace llvm;
using namespace llvm::PatternMatch;
@@ -5551,7 +5550,7 @@ Instruction *InstCombiner::PromoteCastOfAllocation(CastInst &CI,
// Add operands to the worklist.
AddUsesToWorkList(*User);
++NumDeadInst;
- DEBUG(std::cerr << "IC: DCE: " << *User);
+ DOUT << "IC: DCE: " << *User;
User->eraseFromParent();
removeFromWorkList(User);
@@ -6867,7 +6866,7 @@ bool InstCombiner::transformConstExprCastCall(CallSite CS) {
// If we are removing arguments to the function, emit an obnoxious warning...
if (FT->getNumParams() < NumActualArgs)
if (!FT->isVarArg()) {
- std::cerr << "WARNING: While resolving call to function '"
+ llvm_cerr << "WARNING: While resolving call to function '"
<< Callee->getName() << "' arguments were dropped!\n";
} else {
// Add all of the arguments in their promoted form to the arg list...
@@ -8556,7 +8555,7 @@ static void AddReachableCodeToWorklist(BasicBlock *BB,
// DCE instruction if trivially dead.
if (isInstructionTriviallyDead(Inst)) {
++NumDeadInst;
- DEBUG(std::cerr << "IC: DCE: " << *Inst);
+ DOUT << "IC: DCE: " << *Inst;
Inst->eraseFromParent();
continue;
}
@@ -8565,7 +8564,7 @@ static void AddReachableCodeToWorklist(BasicBlock *BB,
if (Constant *C = ConstantFoldInstruction(Inst)) {
if (ConstantExpr *CE = dyn_cast<ConstantExpr>(C))
C = OptimizeConstantExpr(CE, TD);
- DEBUG(std::cerr << "IC: ConstFold to: " << *C << " from: " << *Inst);
+ DOUT << "IC: ConstFold to: " << *C << " from: " << *Inst;
Inst->replaceAllUsesWith(C);
++NumConstProp;
Inst->eraseFromParent();
@@ -8624,7 +8623,7 @@ bool InstCombiner::runOnFunction(Function &F) {
while (Term != BB->begin()) { // Remove instrs bottom-up
BasicBlock::iterator I = Term; --I;
- DEBUG(std::cerr << "IC: DCE: " << *I);
+ DOUT << "IC: DCE: " << *I;
++NumDeadInst;
if (!I->use_empty())
@@ -8645,7 +8644,7 @@ bool InstCombiner::runOnFunction(Function &F) {
AddUsesToWorkList(*I);
++NumDeadInst;
- DEBUG(std::cerr << "IC: DCE: " << *I);
+ DOUT << "IC: DCE: " << *I;
I->eraseFromParent();
removeFromWorkList(I);
@@ -8656,7 +8655,7 @@ bool InstCombiner::runOnFunction(Function &F) {
if (Constant *C = ConstantFoldInstruction(I)) {
if (ConstantExpr *CE = dyn_cast<ConstantExpr>(C))
C = OptimizeConstantExpr(CE, TD);
- DEBUG(std::cerr << "IC: ConstFold to: " << *C << " from: " << *I);
+ DOUT << "IC: ConstFold to: " << *C << " from: " << *I;
// Add operands to the worklist.
AddUsesToWorkList(*I);
@@ -8696,8 +8695,8 @@ bool InstCombiner::runOnFunction(Function &F) {
++NumCombined;
// Should we replace the old instruction with a new one?
if (Result != I) {
- DEBUG(std::cerr << "IC: Old = " << *I
- << " New = " << *Result);
+ DOUT << "IC: Old = " << *I
+ << " New = " << *Result;
// Everything uses the new instruction now.
I->replaceAllUsesWith(Result);
@@ -8733,7 +8732,7 @@ bool InstCombiner::runOnFunction(Function &F) {
// Erase the old instruction.
InstParent->getInstList().erase(I);
} else {
- DEBUG(std::cerr << "IC: MOD = " << *I);
+ DOUT << "IC: MOD = " << *I;
// If the instruction was modified, it's possible that it is now dead.
// if so, remove it.
diff --git a/lib/Transforms/Scalar/LICM.cpp b/lib/Transforms/Scalar/LICM.cpp
index 7ca9be0135..2a790f21a7 100644
--- a/lib/Transforms/Scalar/LICM.cpp
+++ b/lib/Transforms/Scalar/LICM.cpp
@@ -47,7 +47,6 @@
#include "llvm/Support/Debug.h"
#include "llvm/ADT/Statistic.h"
#include <algorithm>
-#include <iostream>
using namespace llvm;
namespace {
@@ -430,7 +429,7 @@ bool LICM::isLoopInvariantInst(Instruction &I) {
/// position, and may either delete it or move it to outside of the loop.
///
void LICM::sink(Instruction &I) {
- DEBUG(std::cerr << "LICM sinking instruction: " << I);
+ DOUT << "LICM sinking instruction: " << I;
std::vector<BasicBlock*> ExitBlocks;
CurLoop->getExitBlocks(ExitBlocks);
@@ -565,8 +564,7 @@ void LICM::sink(Instruction &I) {
/// that is safe to hoist, this instruction is called to do the dirty work.
///
void LICM::hoist(Instruction &I) {
- DEBUG(std::cerr << "LICM hoisting to " << Preheader->getName()
- << ": " << I);
+ DOUT << "LICM hoisting to " << Preheader->getName() << ": " << I;
// Remove the instruction from its current basic block... but don't delete the
// instruction.
@@ -785,7 +783,7 @@ void LICM::FindPromotableValuesInLoop(
for (AliasSet::iterator I = AS.begin(), E = AS.end(); I != E; ++I)
ValueToAllocaMap.insert(std::make_pair(I->first, AI));
- DEBUG(std::cerr << "LICM: Promoting value: " << *V << "\n");
+ DOUT << "LICM: Promoting value: " << *V << "\n";
}
}
}
diff --git a/lib/Transforms/Scalar/LoopStrengthReduce.cpp b/lib/Transforms/Scalar/LoopStrengthReduce.cpp
index 5a661c7bc5..3ac4df7c99 100644
--- a/lib/Transforms/Scalar/LoopStrengthReduce.cpp
+++ b/lib/Transforms/Scalar/LoopStrengthReduce.cpp
@@ -34,7 +34,6 @@
#include "llvm/Support/Compiler.h"
#include "llvm/Target/TargetLowering.h"
#include <algorithm>
-#include <iostream>
#include <set>
using namespace llvm;
@@ -322,8 +321,8 @@ static bool getSCEVStartAndStride(const SCEVHandle &SH, Loop *L,
Start = SCEVAddExpr::get(Start, AddRec->getOperand(0));
if (!isa<SCEVConstant>(AddRec->getOperand(1)))
- DEBUG(std::cerr << "[" << L->getHeader()->getName()
- << "] Variable stride: " << *AddRec << "\n");
+ DOUT << "[" << L->getHeader()->getName()
+ << "] Variable stride: " << *AddRec << "\n";
Stride = AddRec->getOperand(1);
// Check that all constant strides are the unsigned type, we don't want to
@@ -422,12 +421,12 @@ bool LoopStrengthReduce::AddUsersIfInteresting(Instruction *I, Loop *L,
// don't recurse into it.
bool AddUserToIVUsers = false;
if (LI->getLoopFor(User->getParent()) != L) {
- DEBUG(std::cerr << "FOUND USER in other loop: " << *User
- << " OF SCEV: " << *ISE << "\n");
+ DOUT << "FOUND USER in other loop: " << *User
+ << " OF SCEV: " << *ISE << "\n";
AddUserToIVUsers = true;
} else if (!AddUsersIfInteresting(User, L, Processed)) {
- DEBUG(std::cerr << "FOUND USER: " << *User
- << " OF SCEV: " << *ISE << "\n");
+ DOUT << "FOUND USER: " << *User
+ << " OF SCEV: " << *ISE << "\n";
AddUserToIVUsers = true;
}
@@ -445,7 +444,7 @@ bool LoopStrengthReduce::AddUsersIfInteresting(Instruction *I, Loop *L,
SCEVHandle NewStart = SCEV::getMinusSCEV(Start, Stride);
StrideUses.addUser(NewStart, User, I);
StrideUses.Users.back().isUseOfPostIncrementedValue = true;
- DEBUG(std::cerr << " USING POSTINC SCEV, START=" << *NewStart<< "\n");
+ DOUT << " USING POSTINC SCEV, START=" << *NewStart<< "\n";
} else {
StrideUses.addUser(Start, User, I);
}
@@ -508,12 +507,12 @@ namespace {
}
void BasedUser::dump() const {
- std::cerr << " Base=" << *Base;
- std::cerr << " Imm=" << *Imm;
+ llvm_cerr << " Base=" << *Base;
+ llvm_cerr << " Imm=" << *Imm;
if (EmittedBase)
- std::cerr << " EB=" << *EmittedBase;
+ llvm_cerr << " EB=" << *EmittedBase;
- std::cerr << " Inst: " << *Inst;
+ llvm_cerr << " Inst: " << *Inst;
}
Value *BasedUser::InsertCodeForBaseAtPosition(const SCEVHandle &NewBase,
@@ -561,7 +560,7 @@ void BasedUser::RewriteInstructionToUseNewBase(const SCEVHandle &NewBase,
Value *NewVal = InsertCodeForBaseAtPosition(NewBase, Rewriter, Inst, L);
// Replace the use of the operand Value with the new Phi we just created.
Inst->replaceUsesOfWith(OperandValToReplace, NewVal);
- DEBUG(std::cerr << " CHANGED: IMM =" << *Imm << " Inst = " << *Inst);
+ DOUT << " CHANGED: IMM =" << *Imm << " Inst = " << *Inst;
return;
}
@@ -610,7 +609,7 @@ void BasedUser::RewriteInstructionToUseNewBase(const SCEVHandle &NewBase,
Rewriter.clear();
}
}
- DEBUG(std::cerr << " CHANGED: IMM =" << *Imm << " Inst = " << *Inst);
+ DOUT << " CHANGED: IMM =" << *Imm << " Inst = " << *Inst;
}
@@ -961,8 +960,8 @@ void LoopStrengthReduce::StrengthReduceStridedIVUsers(const SCEVHandle &Stride,
unsigned RewriteFactor = CheckForIVReuse(Stride, ReuseIV,
CommonExprs->getType());
if (RewriteFactor != 0) {
- DEBUG(std::cerr << "BASED ON IV of STRIDE " << *ReuseIV.Stride
- << " and BASE " << *ReuseIV.Base << " :\n");
+ DOUT << "BASED ON IV of STRIDE " << *ReuseIV.Stride
+ << " and BASE " << *ReuseIV.Base << " :\n";
NewPHI = ReuseIV.PHI;
IncV = ReuseIV.IncV;
}
@@ -996,8 +995,8 @@ void LoopStrengthReduce::StrengthReduceStridedIVUsers(const SCEVHandle &Stride,
// Now that we know what we need to do, insert the PHI node itself.
//
- DEBUG(std::cerr << "INSERTING IV of STRIDE " << *Stride << " and BASE "
- << *CommonExprs << " :\n");
+ DOUT << "INSERTING IV of STRIDE " << *Stride << " and BASE "
+ << *CommonExprs << " :\n";
SCEVExpander Rewriter(*SE, *LI);
SCEVExpander PreheaderRewriter(*SE, *LI);
@@ -1085,7 +1084,7 @@ void LoopStrengthReduce::StrengthReduceStridedIVUsers(const SCEVHandle &Stride,
while (!UsersToProcess.empty()) {
SCEVHandle Base = UsersToProcess.back().Base;
- DEBUG(std::cerr << " INSERTING code for BASE = " << *Base << ":\n");
+ DOUT << " INSERTING code for BASE = " << *Base << ":\n";
// Emit the code for Base into the preheader.
Value *BaseV = PreheaderRewriter.expandCodeFor(Base, PreInsertPt,
@@ -1302,7 +1301,7 @@ void LoopStrengthReduce::runOnLoop(Loop *L) {
bool HasOneStride = IVUsesByStride.size() == 1;
#ifndef NDEBUG
- DEBUG(std::cerr << "\nLSR on ");
+ DOUT << "\nLSR on ";
DEBUG(L->dump());
#endif
diff --git a/lib/Transforms/Scalar/LoopUnroll.cpp b/lib/Transforms/Scalar/LoopUnroll.cpp
index 2fa3fcd7f3..9d14891e49 100644
--- a/lib/Transforms/Scalar/LoopUnroll.cpp
+++ b/lib/Transforms/Scalar/LoopUnroll.cpp
@@ -34,7 +34,6 @@
#include <cstdio>
#include <set>
#include <algorithm>
-#include <iostream>
using namespace llvm;
namespace {
@@ -134,7 +133,7 @@ BasicBlock* LoopUnroll::FoldBlockIntoPredecessor(BasicBlock* BB) {
if (OnlyPred->getTerminator()->getNumSuccessors() != 1)
return 0;
- 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
@@ -194,15 +193,15 @@ bool LoopUnroll::visitLoop(Loop *L) {
return Changed; // More than 2^32 iterations???
unsigned LoopSize = ApproximateLoopSize(L);
- DEBUG(std::cerr << "Loop Unroll: F[" << Header->getParent()->getName()
- << "] Loop %" << Header->getName() << " Loop Size = "
- << LoopSize << " Trip Count = " << TripCountFull << " - ");
+ DOUT << "Loop Unroll: F[" << Header->getParent()->getName()
+ << "] Loop %" << Header->getName() << " Loop Size = "
+ << LoopSize << " Trip Count = " << TripCountFull << " - ";
uint64_t Size = (uint64_t)LoopSize*TripCountFull;
if (Size > UnrollThreshold) {
- DEBUG(std::cerr << "TOO LARGE: " << Size << ">" << UnrollThreshold << "\n");
+ DOUT << "TOO LARGE: " << Size << ">" << UnrollThreshold << "\n";
return Changed;
}
- DEBUG(std::cerr << "UNROLLING!\n");
+ DOUT << "UNROLLING!\n";
std::vector<BasicBlock*> LoopBlocks = L->getBlocks();
diff --git a/lib/Transforms/Scalar/LoopUnswitch.cpp b/lib/Transforms/Scalar/LoopUnswitch.cpp
index a91d295540..8b2f6cfc5e 100644
--- a/lib/Transforms/Scalar/LoopUnswitch.cpp
+++ b/lib/Transforms/Scalar/LoopUnswitch.cpp
@@ -40,7 +40,6 @@
#include "llvm/Support/Debug.h"
#include "llvm/Support/CommandLine.h"
#include <algorithm>
-#include <iostream>
#include <set>
using namespace llvm;
@@ -369,9 +368,9 @@ bool LoopUnswitch::UnswitchIfProfitable(Value *LoopCond, Constant *Val,Loop *L){
// FIXME: this should estimate growth by the amount of code shared by the
// resultant unswitched loops.
//
- DEBUG(std::cerr << "NOT unswitching loop %"
- << L->getHeader()->getName() << ", cost too high: "
- << L->getBlocks().size() << "\n");
+ DOUT << "NOT unswitching loop %"
+ << L->getHeader()->getName() << ", cost too high: "
+ << L->getBlocks().size() << "\n";
return false;
}
@@ -508,10 +507,10 @@ static void EmitPreheaderBranchOnCondition(Value *LIC, Constant *Val,
void LoopUnswitch::UnswitchTrivialCondition(Loop *L, Value *Cond,
Constant *Val,
BasicBlock *ExitBlock) {
- DEBUG(std::cerr << "loop-unswitch: Trivial-Unswitch loop %"
- << L->getHeader()->getName() << " [" << L->getBlocks().size()
- << " blocks] in Function " << L->getHeader()->getParent()->getName()
- << " on cond: " << *Val << " == " << *Cond << "\n");
+ DOUT << "loop-unswitch: Trivial-Unswitch loop %"
+ << L->getHeader()->getName() << " [" << L->getBlocks().size()
+ << " blocks] in Function " << L->getHeader()->getParent()->getName()
+ << " on cond: " << *Val << " == " << *Cond << "\n";
// First step, split the preheader, so that we know that there is a safe place
// to insert the conditional branch. We will change 'OrigPH' to have a
@@ -553,10 +552,10 @@ void LoopUnswitch::UnswitchTrivialCondition(Loop *L, Value *Cond,
void LoopUnswitch::UnswitchNontrivialCondition(Value *LIC, Constant *Val,
Loop *L) {
Function *F = L->getHeader()->getParent();
- DEBUG(std::cerr << "loop-unswitch: Unswitching loop %"
- << L->getHeader()->getName() << " [" << L->getBlocks().size()
- << " blocks] in Function " << F->getName()
- << " when '" << *Val << "' == " << *LIC << "\n");
+ DOUT << "loop-unswitch: Unswitching loop %"
+ << L->getHeader()->getName() << " [" << L->getBlocks().size()
+ << " blocks] in Function " << F->getName()
+ << " when '" << *Val << "' == " << *LIC << "\n";
// LoopBlocks contains all of the basic blocks of the loop, including the
// preheader of the loop, the body of the loop, and the exit blocks of the
@@ -721,7 +720,7 @@ static void RemoveFromWorklist(Instruction *I,
/// program, replacing all uses with V and update the worklist.
static void ReplaceUsesOfWith(Instruction *I, Value *V,
std::vector<Instruction*> &Worklist) {
- DEBUG(std::cerr << "Replace with '" << *V << "': " << *I);
+ DOUT << "Replace with '" << *V << "': " << *I;
// Add uses to the worklist, which may be dead now.
for (unsigned i = 0, e = I->getNumOperands(); i != e; ++i)
@@ -780,7 +779,7 @@ void LoopUnswitch::RemoveBlockIfDead(BasicBlock *BB,
return;
}
- DEBUG(std::cerr << "Nuking dead block: " << *BB);
+ DOUT << "Nuking dead block: " << *BB;
// Remove the instructions in the basic block from the worklist.
for (BasicBlock::iterator I = BB->begin(), E = BB->end(); I != E; ++I) {
@@ -1013,7 +1012,7 @@ void LoopUnswitch::SimplifyCode(std::vector<Instruction*> &Worklist) {
// Simple DCE.
if (isInstructionTriviallyDead(I)) {
- DEBUG(std::cerr << "Remove dead instruction '" << *I);
+ DOUT << "Remove dead instruction '" << *I;
// Add uses to the worklist, which may be dead now.
for (unsigned i = 0, e = I->getNumOperands(); i != e; ++i)
@@ -1066,8 +1065,8 @@ void LoopUnswitch::SimplifyCode(std::vector<Instruction*> &Worklist) {
if (!SinglePred) continue; // Nothing to do.
assert(SinglePred == Pred && "CFG broken");
- DEBUG(std::cerr << "Merging blocks: " << Pred->getName() << " <- "
- << Succ->getName() << "\n");
+ DOUT << "Merging blocks: " << Pred->getName() << " <- "
+ << Succ->getName() << "\n";
// Resolve any single entry PHI nodes in Succ.
while (PHINode *PN = dyn_cast<PHINode>(Succ->begin()))
@@ -1092,7 +1091,7 @@ void LoopUnswitch::SimplifyCode(std::vector<Instruction*> &Worklist) {
// remove dead blocks.
break; // FIXME: Enable.
- DEBUG(std::cerr << "Folded branch: " << *BI);
+ DOUT << "Folded branch: " << *BI;
BasicBlock *DeadSucc = BI->getSuccessor(CB->getValue());
BasicBlock *LiveSucc = BI->getSuccessor(!CB->getValue());
DeadSucc->removePredecessor(BI->getParent(), true);
diff --git a/lib/Transforms/Scalar/LowerPacked.cpp b/lib/Transforms/Scalar/LowerPacked.cpp
index 5eb89115b0..ae8506e2fc 100644
--- a/lib/Transforms/Scalar/LowerPacked.cpp
+++ b/lib/Transforms/Scalar/LowerPacked.cpp
@@ -20,12 +20,11 @@
#include "llvm/Instructions.h"
#include "llvm/Pass.h"
#include "llvm/Support/InstVisitor.h"
+#include "llvm/Support/Streams.h"
#include "llvm/ADT/StringExtras.h"
#include <algorithm>
#include <map>
-#include <iostream>
#include <functional>
-
using namespace llvm;
namespace {
@@ -72,12 +71,10 @@ public:
///
/// @brief Asserts if PackedType instruction is not handled elsewhere.
/// @param I the unhandled instruction
- void visitInstruction(Instruction &I)
- {
- if(isa<PackedType>(I.getType())) {
- std::cerr << "Unhandled Instruction with Packed ReturnType: " <<
- I << '\n';
- }
+ void visitInstruction(Instruction &I) {
+ if (isa<PackedType>(I.getType()))
+ llvm_cerr << "Unhandled Instruction with Packed ReturnType: "
+ << I << '\n';
}
private:
/// @brief Retrieves lowered values for a packed value.
diff --git a/lib/Transforms/Scalar/SCCP.cpp b/lib/Transforms/Scalar/SCCP.cpp
index 8e585c2ab1..b0c25feae8 100644
--- a/lib/Transforms/Scalar/SCCP.cpp
+++ b/lib/Transforms/Scalar/SCCP.cpp
@@ -36,7 +36,6 @@
#include "llvm/ADT/Statistic.h"
#include "llvm/ADT/STLExtras.h"
#include <algorithm>
-#include <iostream>
#include <set>
using namespace llvm;
@@ -134,7 +133,7 @@ public:
/// MarkBlockExecutable - This method can be used by clients to mark all of
/// the blocks that are known to be intrinsically live in the processed unit.
void MarkBlockExecutable(BasicBlock *BB) {
- DEBUG(std::cerr << "Marking Block Executable: " << BB->getName() << "\n");
+ DOUT << "Marking Block Executable: " << BB->getName() << "\n";
BBExecutable.insert(BB); // Basic block is executable!
BBWorkList.push_back(BB); // Add the block to the work list!
}
@@ -204,7 +203,7 @@ private:
//
inline void markConstant(LatticeVal &IV, Value *V, Constant *C) {
if (IV.markConstant(C)) {
- DEBUG(std::cerr << "markConstant: " << *C << ": " << *V);
+ DOUT << "markConstant: " << *C << ": " << *V;
InstWorkList.push_back(V);
}
}
@@ -218,11 +217,11 @@ private:
inline void markOverdefined(LatticeVal &IV, Value *V) {
if (IV.markOverdefined()) {
- DEBUG(std::cerr << "markOverdefined: ";
+ DEBUG(DOUT << "markOverdefined: ";
if (Function *F = dyn_cast<Function>(V))
- std::cerr << "Function '" << F->getName() << "'\n";
+ DOUT << "Function '" << F->getName() << "'\n";
else
- std::cerr << *V);
+ DOUT << *V);
// Only instructions go on the work list
OverdefinedInstWorkList.push_back(V);
}
@@ -276,8 +275,8 @@ private:
return; // This edge is already known to be executable!
if (BBExecutable.count(Dest)) {
- DEBUG(std::cerr << "Marking Edge Executable: " << Source->getName()
- << " -> " << Dest->getName() << "\n");
+ DOUT << "Marking Edge Executable: " << Source->getName()
+ << " -> " << Dest->getName() << "\n";
// The destination is already executable, but we just made an edge
// feasible that wasn't before. Revisit the PHI nodes in the block
@@ -351,7 +350,7 @@ private:
void visitInstruction(Instruction &I) {
// If a new instruction is added to LLVM that we don't handle...
- std::cerr << "SCCP: Don't know how to handle: " << I;
+ llvm_cerr << "SCCP: Don't know how to handle: " << I;
markOverdefined(&I); // Just in case
}
};
@@ -401,7 +400,7 @@ void SCCPSolver::getFeasibleSuccessors(TerminatorInst &TI,
Succs[0] = true;
}
} else {
- std::cerr << "SCCP: Don't know how to handle: " << TI;
+ llvm_cerr << "SCCP: Don't know how to handle: " << TI;
Succs.assign(TI.getNumSuccessors(), true);
}
}
@@ -460,7 +459,7 @@ bool SCCPSolver::isEdgeFeasible(BasicBlock *From, BasicBlock *To) {
}
return false;
} else {
- std::cerr << "Unknown terminator instruction: " << *TI;
+ llvm_cerr << "Unknown terminator instruction: " << *TI;
abort();
}
}
@@ -971,7 +970,7 @@ void SCCPSolver::Solve() {
Value *I = OverdefinedInstWorkList.back();
OverdefinedInstWorkList.pop_back();
- DEBUG(std::cerr << "\nPopped off OI-WL: " << *I);
+ DOUT << "\nPopped off OI-WL: " << *I;
// "I" got into the work list because it either made the transition from
// bottom to constant
@@ -989,7 +988,7 @@ void SCCPSolver::Solve() {
Value *I = InstWorkList.back();
InstWorkList.pop_back();
- DEBUG(std::cerr << "\nPopped off I-WL: " << *I);
+ DOUT << "\nPopped off I-WL: " << *I;
// "I" got into the work list because it either made the transition from
// bottom to constant
@@ -1009,7 +1008,7 @@ void SCCPSolver::Solve() {
BasicBlock *BB = BBWorkList.back();
BBWorkList.pop_back();
- DEBUG(std::cerr << "\nPopped off BBWL: " << *BB);
+ DOUT << "\nPopped off BBWL: " << *BB;
// Notify all instructions in this basic block that they are newly
// executable.
@@ -1098,7 +1097,7 @@ FunctionPass *llvm::createSCCPPass() {
// and return true if the function was modified.
//
bool SCCP::runOnFunction(Function &F) {
- DEBUG(std::cerr << "SCCP on function '" << F.getName() << "'\n");
+ DOUT << "SCCP on function '" << F.getName() << "'\n";
SCCPSolver Solver;
// Mark the first block of the function as being executable.
@@ -1113,7 +1112,7 @@ bool SCCP::runOnFunction(Function &F) {
bool ResolvedBranches = true;
while (ResolvedBranches) {
Solver.Solve();
- DEBUG(std::cerr << "RESOLVING UNDEF BRANCHES\n");
+ DOUT << "RESOLVING UNDEF BRANCHES\n";
ResolvedBranches = Solver.ResolveBranchesIn(F);
}
@@ -1126,7 +1125,7 @@ bool SCCP::runOnFunction(Function &F) {
std::set<BasicBlock*> &ExecutableBBs = Solver.getExecutableBlocks();
for (Function::iterator BB = F.begin(), E = F.end(); BB != E; ++BB)
if (!ExecutableBBs.count(BB)) {
- DEBUG(std::cerr << " BasicBlock Dead:" << *BB);
+ DOUT << " BasicBlock Dead:" << *BB;
++NumDeadBlocks;
// Delete the instructions backwards, as it has a reduced likelihood of
@@ -1156,7 +1155,7 @@ bool SCCP::runOnFunction(Function &F) {
!isa<TerminatorInst>(Inst)) {
Constant *Const = IV.isConstant()
? IV.getConstant() : UndefValue::get(Inst->getType());
- DEBUG(std::cerr << " Constant: " << *Const << " = " << *Inst);
+ DOUT << " Constant: " << *Const << " = " << *Inst;
// Replaces all of the uses of a variable with uses of the constant.
Inst->replaceAllUsesWith(Const);
@@ -1258,7 +1257,7 @@ bool IPSCCP::runOnModule(Module &M) {
while (ResolvedBranches) {
Solver.Solve();
- DEBUG(std::cerr << "RESOLVING UNDEF BRANCHES\n");
+ DOUT << "RESOLVING UNDEF BRANCHES\n";
ResolvedBranches = false;
for (Module::iterator F = M.begin(), E = M.end(); F != E; ++F)
ResolvedBranches |= Solver.ResolveBranchesIn(*F);
@@ -1278,7 +1277,7 @@ bool IPSCCP::runOnModule(Module &M) {
if (IV.isConstant() || IV.isUndefined()) {
Constant *CST = IV.isConstant() ?
IV.getConstant() : UndefValue::get(AI->getType());
- DEBUG(std::cerr << "*** Arg " << *AI << " = " << *CST <<"\n");
+ DOUT << "*** Arg " << *AI << " = " << *CST <<"\n";
// Replaces all of the uses of a variable with uses of the
// constant.
@@ -1290,7 +1289,7 @@ bool IPSCCP::runOnModule(Module &M) {
std::vector<BasicBlock*> BlocksToErase;
for (Function::iterator BB = F->begin(), E = F->end(); BB != E; ++BB)
if (!ExecutableBBs.count(BB)) {
- DEBUG(std::cerr << " BasicBlock Dead:" << *BB);
+ DOUT << " BasicBlock Dead:" << *BB;
++IPNumDeadBlocks;
// Delete the instructions backwards, as it has a reduced likelihood of
@@ -1333,7 +1332,7 @@ bool IPSCCP::runOnModule(Module &M) {
!isa<TerminatorInst>(Inst)) {
Constant *Const = IV.isConstant()
? IV.getConstant() : UndefValue::get(Inst->getType());
- DEBUG(std::cerr << " Constant: " << *Const << " = " << *Inst);
+ DOUT << " Constant: " << *Const << " = " << *Inst;
// Replaces all of the uses of a variable with uses of the
// constant.
@@ -1415,7 +1414,7 @@ bool IPSCCP::runOnModule(Module &M) {
GlobalVariable *GV = I->first;
assert(!I->second.isOverdefined() &&
"Overdefined values should have been taken out of the map!");
- DEBUG(std::cerr << "Found that GV '" << GV->getName()<< "' is constant!\n");
+ DOUT << "Found that GV '" << GV->getName()<< "' is constant!\n";
while (!GV->use_empty()) {
StoreInst *SI = cast<StoreInst>(GV->use_back());
SI->eraseFromParent();
diff --git a/lib/Transforms/Scalar/ScalarReplAggregates.cpp b/lib/Transforms/Scalar/ScalarReplAggregates.cpp
index c1071797b9..a0c516402b 100644
--- a/lib/Transforms/Scalar/ScalarReplAggregates.cpp
+++ b/lib/Transforms/Scalar/ScalarReplAggregates.cpp
@@ -34,7 +34,6 @@
#include "llvm/Support/Compiler.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/ADT/StringExtras.h"
-#include <iostream>
using namespace llvm;
namespace {
@@ -170,7 +169,7 @@ bool SROA::performScalarRepl(Function &F) {
break;
}
- DEBUG(std::cerr << "Found inst to xform: " << *AI);
+ DOUT << "Found inst to xform: " << *AI;
Changed = true;
std::vector<AllocaInst*> ElementAllocas;
@@ -265,7 +264,7 @@ int SROA::isSafeElementUse(Value *Ptr) {
break;
}
default:
- DEBUG(std::cerr << " Transformation preventing inst: " << *User);
+ DOUT << " Transformation preventing inst: " << *User;
return 0;
}
}
@@ -358,8 +357,7 @@ int SROA::isSafeAllocaToScalarRepl(AllocationInst *AI) {
I != E; ++I) {
isSafe &= isSafeUseOfAllocation(cast<Instruction>(*I));
if (isSafe == 0) {
- DEBUG(std::cerr << "Cannot transform: " << *AI << " due to user: "
- << **I);
+ DOUT << "Cannot transform: " << *AI << " due to user: " << **I;
return 0;
}
}
@@ -572,8 +570,8 @@ const Type *SROA::CanConvertToScalar(Value *V, bool &IsNotTrivial) {
/// predicate and is non-trivial. Convert it to something that can be trivially
/// promoted into a register by mem2reg.
void SROA::ConvertToScalar(AllocationInst *AI, const Type *ActualTy) {
- DEBUG(std::cerr << "CONVERT TO SCALAR: " << *AI << " TYPE = "
- << *ActualTy << "\n");
+ DOUT << "CONVERT TO SCALAR: " << *AI << " TYPE = "
+ << *ActualTy << "\n";
++NumConverted;
BasicBlock *EntryBlock = AI->getParent();
diff --git a/lib/Transforms/Scalar/TailDuplication.cpp b/lib/Transforms/Scalar/TailDuplication.cpp
index 329632f8dc..9e9827377d 100644
--- a/lib/Transforms/Scalar/TailDuplication.cpp
+++ b/lib/Transforms/Scalar/TailDuplication.cpp
@@ -31,7 +31,6 @@
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Debug.h"
#include "llvm/ADT/Statistic.h"
-#include <iostream>
using namespace llvm;
namespace {
@@ -215,14 +214,13 @@ void TailDup::eliminateUnconditionalBranch(BranchInst *Branch) {
BasicBlock *DestBlock = Branch->getSuccessor(0);
assert(SourceBlock != DestBlock && "Our predicate is broken!");
- DEBUG(std::cerr << "TailDuplication[" << SourceBlock->getParent()->getName()
- << "]: Eliminating branch: " << *Branch);
+ DOUT << "TailDuplication[" << SourceBlock->getParent()->getName()
+ << "]: Eliminating branch: " << *Branch;
// See if we can avoid duplicating code by moving it up to a dominator of both
// blocks.
if (BasicBlock *DomBlock = FindObviousSharedDomOf(SourceBlock, DestBlock)) {
- DEBUG(std::cerr << "Found shared dominator: " << DomBlock->getName()
- << "\n");
+ DOUT << "Found shared dominator: " << DomBlock->getName() << "\n";
// If there are non-phi instructions in DestBlock that have no operands
// defined in DestBlock, and if the instruction has no side effects, we can
@@ -245,7 +243,7 @@ void TailDup::eliminateUnconditionalBranch(BranchInst *Branch) {
// Remove from DestBlock, move right before the term in DomBlock.
DestBlock->getInstList().remove(I);
DomBlock->getInstList().insert(DomBlock->getTerminator(), I);
- DEBUG(std::cerr << "Hoisted: " << *I);
+ DOUT << "Hoisted: " << *I;
}
}
}