#include "llvm/ADT/Statistic.h"
#include "llvm/ADT/STLExtras.h"
#include <algorithm>
-#include <iostream>
using namespace llvm;
namespace {
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()));
}
};
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...
}
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;
}
});
#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 {
#include "llvm/ADT/Statistic.h"
#include "llvm/ADT/STLExtras.h"
#include <algorithm>
-#include <iostream>
using namespace llvm;
using namespace llvm::PatternMatch;
// Add operands to the worklist.
AddUsesToWorkList(*User);
++NumDeadInst;
- DEBUG(std::cerr << "IC: DCE: " << *User);
+ DOUT << "IC: DCE: " << *User;
User->eraseFromParent();
removeFromWorkList(User);
// 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...
// DCE instruction if trivially dead.
if (isInstructionTriviallyDead(Inst)) {
++NumDeadInst;
- DEBUG(std::cerr << "IC: DCE: " << *Inst);
+ DOUT << "IC: DCE: " << *Inst;
Inst->eraseFromParent();
continue;
}
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();
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())
AddUsesToWorkList(*I);
++NumDeadInst;
- DEBUG(std::cerr << "IC: DCE: " << *I);
+ DOUT << "IC: DCE: " << *I;
I->eraseFromParent();
removeFromWorkList(I);
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);
++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);
// 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.
#include "llvm/Support/Debug.h"
#include "llvm/ADT/Statistic.h"
#include <algorithm>
-#include <iostream>
using namespace llvm;
namespace {
/// 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);
/// 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.
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";
}
}
}
#include "llvm/Support/Compiler.h"
#include "llvm/Target/TargetLowering.h"
#include <algorithm>
-#include <iostream>
#include <set>
using namespace llvm;
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
// 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;
}
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);
}
}
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,
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;
}
Rewriter.clear();
}
}
- DEBUG(std::cerr << " CHANGED: IMM =" << *Imm << " Inst = " << *Inst);
+ DOUT << " CHANGED: IMM =" << *Imm << " Inst = " << *Inst;
}
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;
}
// 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);
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,
bool HasOneStride = IVUsesByStride.size() == 1;
#ifndef NDEBUG
- DEBUG(std::cerr << "\nLSR on ");
+ DOUT << "\nLSR on ";
DEBUG(L->dump());
#endif
#include <cstdio>
#include <set>
#include <algorithm>
-#include <iostream>
using namespace llvm;
namespace {
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
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();
#include "llvm/Support/Debug.h"
#include "llvm/Support/CommandLine.h"
#include <algorithm>
-#include <iostream>
#include <set>
using namespace llvm;
// 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;
}
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
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
/// 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)
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) {
// 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)
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()))
// 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);
#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 {
///
/// @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.
#include "llvm/ADT/Statistic.h"
#include "llvm/ADT/STLExtras.h"
#include <algorithm>
-#include <iostream>
#include <set>
using namespace llvm;
/// 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!
}
//
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);
}
}
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);
}
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
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
}
};
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);
}
}
}
return false;
} else {
- std::cerr << "Unknown terminator instruction: " << *TI;
+ llvm_cerr << "Unknown terminator instruction: " << *TI;
abort();
}
}
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
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
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.
// 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.
bool ResolvedBranches = true;
while (ResolvedBranches) {
Solver.Solve();
- DEBUG(std::cerr << "RESOLVING UNDEF BRANCHES\n");
+ DOUT << "RESOLVING UNDEF BRANCHES\n";
ResolvedBranches = Solver.ResolveBranchesIn(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
!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);
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);
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.
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
!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.
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();
#include "llvm/Support/Compiler.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/ADT/StringExtras.h"
-#include <iostream>
using namespace llvm;
namespace {
break;
}
- DEBUG(std::cerr << "Found inst to xform: " << *AI);
+ DOUT << "Found inst to xform: " << *AI;
Changed = true;
std::vector<AllocaInst*> ElementAllocas;
break;
}
default:
- DEBUG(std::cerr << " Transformation preventing inst: " << *User);
+ DOUT << " Transformation preventing inst: " << *User;
return 0;
}
}
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;
}
}
/// 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();
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Debug.h"
#include "llvm/ADT/Statistic.h"
-#include <iostream>
using namespace llvm;
namespace {
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
// 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;
}
}
}