#include "llvm/Support/InstIterator.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Compiler.h"
-#include "llvm/Support/Streams.h"
+#include "llvm/Support/raw_ostream.h"
#include <set>
#include <sstream>
using namespace llvm;
WriteAsOperand(s2, V2, true, M);
std::string o1(s1.str()), o2(s2.str());
if (o2 < o1)
- std::swap(o1, o2);
- cerr << " " << Msg << ":\t"
- << o1 << ", "
- << o2 << "\n";
+ std::swap(o1, o2);
+ errs() << " " << Msg << ":\t"
+ << o1 << ", "
+ << o2 << "\n";
}
}
PrintModRefResults(const char *Msg, bool P, Instruction *I, Value *Ptr,
Module *M) {
if (P) {
- cerr << " " << Msg << ": Ptr: ";
- WriteAsOperand(*cerr.stream(), Ptr, true, M);
- cerr << "\t<->" << *I;
+ errs() << " " << Msg << ": Ptr: ";
+ WriteAsOperand(errs(), Ptr, true, M);
+ errs() << "\t<->" << *I;
}
}
if (PrintNoAlias || PrintMayAlias || PrintMustAlias ||
PrintNoModRef || PrintMod || PrintRef || PrintModRef)
- cerr << "Function: " << F.getName() << ": " << Pointers.size()
- << " pointers, " << CallSites.size() << " call sites\n";
+ errs() << "Function: " << F.getName() << ": " << Pointers.size()
+ << " pointers, " << CallSites.size() << " call sites\n";
// iterate over the worklist, and run the full (n^2)/2 disambiguations
for (std::set<Value *>::iterator I1 = Pointers.begin(), E = Pointers.end();
PrintResults("MustAlias", PrintMustAlias, *I1, *I2, F.getParent());
++MustAlias; break;
default:
- cerr << "Unknown alias query result!\n";
+ errs() << "Unknown alias query result!\n";
}
}
}
PrintModRefResults(" ModRef", PrintModRef, I, *V, F.getParent());
++ModRef; break;
default:
- cerr << "Unknown alias query result!\n";
+ errs() << "Unknown alias query result!\n";
}
}
}
}
static void PrintPercent(unsigned Num, unsigned Sum) {
- cerr << "(" << Num*100ULL/Sum << "."
- << ((Num*1000ULL/Sum) % 10) << "%)\n";
+ errs() << "(" << Num*100ULL/Sum << "."
+ << ((Num*1000ULL/Sum) % 10) << "%)\n";
}
bool AAEval::doFinalization(Module &M) {
unsigned AliasSum = NoAlias + MayAlias + MustAlias;
- cerr << "===== Alias Analysis Evaluator Report =====\n";
+ errs() << "===== Alias Analysis Evaluator Report =====\n";
if (AliasSum == 0) {
- cerr << " Alias Analysis Evaluator Summary: No pointers!\n";
+ errs() << " Alias Analysis Evaluator Summary: No pointers!\n";
} else {
- cerr << " " << AliasSum << " Total Alias Queries Performed\n";
- cerr << " " << NoAlias << " no alias responses ";
+ errs() << " " << AliasSum << " Total Alias Queries Performed\n";
+ errs() << " " << NoAlias << " no alias responses ";
PrintPercent(NoAlias, AliasSum);
- cerr << " " << MayAlias << " may alias responses ";
+ errs() << " " << MayAlias << " may alias responses ";
PrintPercent(MayAlias, AliasSum);
- cerr << " " << MustAlias << " must alias responses ";
+ errs() << " " << MustAlias << " must alias responses ";
PrintPercent(MustAlias, AliasSum);
- cerr << " Alias Analysis Evaluator Pointer Alias Summary: "
- << NoAlias*100/AliasSum << "%/" << MayAlias*100/AliasSum << "%/"
- << MustAlias*100/AliasSum << "%\n";
+ errs() << " Alias Analysis Evaluator Pointer Alias Summary: "
+ << NoAlias*100/AliasSum << "%/" << MayAlias*100/AliasSum << "%/"
+ << MustAlias*100/AliasSum << "%\n";
}
// Display the summary for mod/ref analysis
unsigned ModRefSum = NoModRef + Mod + Ref + ModRef;
if (ModRefSum == 0) {
- cerr << " Alias Analysis Mod/Ref Evaluator Summary: no mod/ref!\n";
+ errs() << " Alias Analysis Mod/Ref Evaluator Summary: no mod/ref!\n";
} else {
- cerr << " " << ModRefSum << " Total ModRef Queries Performed\n";
- cerr << " " << NoModRef << " no mod/ref responses ";
+ errs() << " " << ModRefSum << " Total ModRef Queries Performed\n";
+ errs() << " " << NoModRef << " no mod/ref responses ";
PrintPercent(NoModRef, ModRefSum);
- cerr << " " << Mod << " mod responses ";
+ errs() << " " << Mod << " mod responses ";
PrintPercent(Mod, ModRefSum);
- cerr << " " << Ref << " ref responses ";
+ errs() << " " << Ref << " ref responses ";
PrintPercent(Ref, ModRefSum);
- cerr << " " << ModRef << " mod & ref responses ";
+ errs() << " " << ModRef << " mod & ref responses ";
PrintPercent(ModRef, ModRefSum);
- cerr << " Alias Analysis Evaluator Mod/Ref Summary: "
- << NoModRef*100/ModRefSum << "%/" << Mod*100/ModRefSum << "%/"
- << Ref*100/ModRefSum << "%/" << ModRef*100/ModRefSum << "%\n";
+ errs() << " Alias Analysis Evaluator Mod/Ref Summary: "
+ << NoModRef*100/ModRefSum << "%/" << Mod*100/ModRefSum << "%/"
+ << Ref*100/ModRefSum << "%/" << ModRef*100/ModRefSum << "%\n";
}
return false;
virtual void print(std::ostream &o, const Module *M) const {
o << "CallGraph Root is: ";
if (Function *F = getRoot()->getFunction())
- o << F->getName() << "\n";
+ o << F->getNameStr() << "\n";
else
o << "<<null function: 0x" << getRoot() << ">>\n";
void CallGraphNode::print(std::ostream &OS) const {
if (Function *F = getFunction())
- OS << "Call graph node for function: '" << F->getName() <<"'\n";
+ OS << "Call graph node for function: '" << F->getNameStr() <<"'\n";
else
OS << "Call graph node <<null function: 0x" << this << ">>:\n";
for (const_iterator I = begin(), E = end(); I != E; ++I)
if (Function *FI = I->second->getFunction())
- OS << " Calls function '" << FI->getName() <<"'\n";
+ OS << " Calls function '" << FI->getNameStr() <<"'\n";
else
OS << " Calls external node\n";
OS << "\n";
if (!AddRecStride->dominates(Preheader, DT))
return false;
- DOUT << "[" << L->getHeader()->getName()
- << "] Variable stride: " << *AddRec << "\n";
+ DEBUG(errs() << "[" << L->getHeader()->getName()
+ << "] Variable stride: " << *AddRec << "\n");
}
Stride = AddRecStride;
///
void Trace::print(std::ostream &O) const {
Function *F = getFunction ();
- O << "; Trace from function " << F->getName() << ", blocks:\n";
+ O << "; Trace from function " << F->getNameStr() << ", blocks:\n";
for (const_iterator i = begin(), e = end(); i != e; ++i) {
O << "; ";
WriteAsOperand(O, *i, true, getModule());
#include "llvm/Target/TargetAsmInfo.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/ErrorHandling.h"
+#include "llvm/Support/raw_ostream.h"
//===----------------------------------------------------------------------===//
// ELFCodeEmitter Implementation
/// startFunction - This callback is invoked when a new machine function is
/// about to be emitted.
void ELFCodeEmitter::startFunction(MachineFunction &MF) {
- DOUT << "processing function: " << MF.getFunction()->getName() << "\n";
+ DEBUG(errs() << "processing function: "
+ << MF.getFunction()->getName() << "\n");
// Get the ELF Section that this function belongs in.
ES = &EW.getTextSection();
TII = MF.getTarget().getInstrInfo();
if (!TII) return false;
- DOUT << "\nIfcvt: function (" << ++FnNum << ") \'"
- << MF.getFunction()->getName() << "\'";
+ DEBUG(errs() << "\nIfcvt: function (" << ++FnNum << ") \'"
+ << MF.getFunction()->getName() << "\'");
if (FnNum < IfCvtFnStart || (IfCvtFnStop != -1 && FnNum > IfCvtFnStop)) {
DOUT << " skipped\n";
O << "********** MACHINEINSTRS **********\n";
for (MachineFunction::iterator mbbi = mf_->begin(), mbbe = mf_->end();
mbbi != mbbe; ++mbbi) {
- O << ((Value*)mbbi->getBasicBlock())->getName() << ":\n";
+ O << ((Value*)mbbi->getBasicBlock())->getNameStr() << ":\n";
for (MachineBasicBlock::iterator mii = mbbi->begin(),
mie = mbbi->end(); mii != mie; ++mii) {
O << getInstructionIndex(mii) << '\t' << *mii;
/// which a variable is live
void LiveIntervals::computeIntervals() {
- DOUT << "********** COMPUTING LIVE INTERVALS **********\n"
- << "********** Function: "
- << ((Value*)mf_->getFunction())->getName() << '\n';
+ DEBUG(errs() << "********** COMPUTING LIVE INTERVALS **********\n"
+ << "********** Function: "
+ << ((Value*)mf_->getFunction())->getName() << '\n');
SmallVector<unsigned, 8> UndefUses;
for (MachineFunction::iterator MBBI = mf_->begin(), E = mf_->end();
MachineBasicBlock *MBB = MBBI;
// Track the index of the current machine instr.
unsigned MIIndex = getMBBStartIdx(MBB);
- DOUT << ((Value*)MBB->getBasicBlock())->getName() << ":\n";
+ DEBUG(errs() << ((Value*)MBB->getBasicBlock())->getName() << ":\n");
MachineBasicBlock::iterator MI = MBB->begin(), miEnd = MBB->end();
#include "llvm/Target/TargetMachine.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/Compiler.h"
+#include "llvm/Support/raw_ostream.h"
using namespace llvm;
namespace {
bool MadeChange = false;
DOUT << "********** LOWERING SUBREG INSTRS **********\n";
- DOUT << "********** Function: " << MF.getFunction()->getName() << '\n';
+ DEBUG(errs() << "********** Function: "
+ << MF.getFunction()->getName() << '\n');
for (MachineFunction::iterator mbbi = MF.begin(), mbbe = MF.end();
mbbi != mbbe; ++mbbi) {
}
void MachineFunction::print(std::ostream &OS) const {
- OS << "# Machine code for " << Fn->getName () << "():\n";
+ OS << "# Machine code for " << Fn->getNameStr () << "():\n";
// Print Frame Information
FrameInfo->print(*this, OS);
for (const_iterator BB = begin(); BB != end(); ++BB)
BB->print(OS);
- OS << "\n# End machine code for " << Fn->getName () << "().\n\n";
+ OS << "\n# End machine code for " << Fn->getNameStr () << "().\n\n";
}
namespace llvm {
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/Debug.h"
+#include "llvm/Support/raw_ostream.h"
using namespace llvm;
// Now move the instructions to the predecessor, inserting it before any
// terminator instructions.
DEBUG({
- DOUT << "Hoisting " << MI;
+ errs() << "Hoisting " << MI;
if (CurPreheader->getBasicBlock())
- DOUT << " to MachineBasicBlock "
- << CurPreheader->getBasicBlock()->getName();
+ errs() << " to MachineBasicBlock "
+ << CurPreheader->getBasicBlock()->getName();
if (MI.getParent()->getBasicBlock())
- DOUT << " from MachineBasicBlock "
- << MI.getParent()->getBasicBlock()->getName();
- DOUT << "\n";
+ errs() << " from MachineBasicBlock "
+ << MI.getParent()->getBasicBlock()->getName();
+ errs() << "\n";
});
// Look for opportunity to CSE the hoisted instruction.
if (!foundErrors++)
MF->print(OS);
*OS << "*** Bad machine code: " << msg << " ***\n"
- << "- function: " << MF->getFunction()->getName() << "\n";
+ << "- function: " << MF->getFunction()->getNameStr() << "\n";
}
void
{
assert(MBB);
report(msg, MBB->getParent());
- *OS << "- basic block: " << MBB->getBasicBlock()->getName()
+ *OS << "- basic block: " << MBB->getBasicBlock()->getNameStr()
<< " " << (void*)MBB
<< " (#" << MBB->getNumber() << ")\n";
}
const TargetInstrInfo &TII = *TM->getInstrInfo();
DEBUG(const BasicBlock *LBB = MBB.getBasicBlock();
- if (LBB) DOUT << "\nStarting RegAlloc of BB: " << LBB->getName());
+ if (LBB) errs() << "\nStarting RegAlloc of BB: " << LBB->getName());
// If this is the first basic block in the machine function, add live-in
// registers as active.
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/ErrorHandling.h"
+#include "llvm/Support/raw_ostream.h"
#include <algorithm>
#include <set>
#include <queue>
{
// linear scan algorithm
DOUT << "********** LINEAR SCAN **********\n";
- DOUT << "********** Function: " << mf_->getFunction()->getName() << '\n';
+ DEBUG(errs() << "********** Function: "
+ << mf_->getFunction()->getName() << '\n');
DEBUG(printIntervals("fixed", fixed_.begin(), fixed_.end()));
MachineBasicBlock::iterator MII = MBB.begin();
DEBUG(const BasicBlock *LBB = MBB.getBasicBlock();
- if (LBB) DOUT << "\nStarting RegAlloc of BB: " << LBB->getName());
+ if (LBB) errs() << "\nStarting RegAlloc of BB: " << LBB->getName());
// Add live-in registers as active.
for (MachineBasicBlock::livein_iterator I = MBB.livein_begin(),
#include "llvm/CodeGen/RegAllocRegistry.h"
#include "llvm/CodeGen/RegisterCoalescer.h"
#include "llvm/Support/Debug.h"
+#include "llvm/Support/raw_ostream.h"
#include "llvm/Target/TargetInstrInfo.h"
#include "llvm/Target/TargetMachine.h"
#include <limits>
vrm = &getAnalysis<VirtRegMap>();
- DOUT << "PBQP Register Allocating for " << mf->getFunction()->getName() << "\n";
+ DEBUG(errs() << "PBQP Register Allocating for "
+ << mf->getFunction()->getName() << "\n");
// Allocator main loop:
//
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/MathExtras.h"
#include "llvm/Support/Timer.h"
+#include "llvm/Support/raw_ostream.h"
#include <algorithm>
using namespace llvm;
else
GFI = 0;
RegInfo = &MF->getRegInfo();
- DOUT << "\n\n\n=== " << Fn.getName() << "\n";
+ DEBUG(errs() << "\n\n\n=== " << Fn.getName() << "\n");
MachineModuleInfo *MMI = getAnalysisIfAvailable<MachineModuleInfo>();
DwarfWriter *DW = getAnalysisIfAvailable<DwarfWriter>();
// via --shrink-wrap-func=<funcname>.
#ifndef NDEBUG
if (ShrinkWrapFunc != "") {
- std::string MFName = MF->getFunction()->getName();
+ std::string MFName = MF->getFunction()->getNameStr();
ShrinkWrapThisFunction = (MFName == ShrinkWrapFunc);
}
#endif
initShrinkWrappingInfo();
DEBUG(if (ShrinkWrapThisFunction) {
- DOUT << "Place CSR spills/restores for "
- << MF->getFunction()->getName() << "\n";
+ errs() << "Place CSR spills/restores for "
+ << MF->getFunction()->getName() << "\n";
});
if (calculateSets(Fn))
// If no CSRs used, we are done.
if (CSI.empty()) {
DEBUG(if (ShrinkWrapThisFunction)
- DOUT << "DISABLED: " << Fn.getFunction()->getName()
- << ": uses no callee-saved registers\n");
+ errs() << "DISABLED: " << Fn.getFunction()->getName()
+ << ": uses no callee-saved registers\n");
return false;
}
// implementation to functions with <= 500 MBBs.
if (Fn.size() > 500) {
DEBUG(if (ShrinkWrapThisFunction)
- DOUT << "DISABLED: " << Fn.getFunction()->getName()
- << ": too large (" << Fn.size() << " MBBs)\n");
+ errs() << "DISABLED: " << Fn.getFunction()->getName()
+ << ": too large (" << Fn.size() << " MBBs)\n");
ShrinkWrapThisFunction = false;
}
}
if (allCSRUsesInEntryBlock) {
- DEBUG(DOUT << "DISABLED: " << Fn.getFunction()->getName()
+ DEBUG(errs() << "DISABLED: " << Fn.getFunction()->getName()
<< ": all CSRs used in EntryBlock\n");
ShrinkWrapThisFunction = false;
} else {
allCSRsUsedInEntryFanout = false;
}
if (allCSRsUsedInEntryFanout) {
- DEBUG(DOUT << "DISABLED: " << Fn.getFunction()->getName()
+ DEBUG(errs() << "DISABLED: " << Fn.getFunction()->getName()
<< ": all CSRs used in imm successors of EntryBlock\n");
ShrinkWrapThisFunction = false;
}
if (dominatesExitNodes) {
CSRUsedInChokePoints |= CSRUsed[MBB];
if (CSRUsedInChokePoints == UsedCSRegs) {
- DEBUG(DOUT << "DISABLED: " << Fn.getFunction()->getName()
+ DEBUG(errs() << "DISABLED: " << Fn.getFunction()->getName()
<< ": all CSRs used in choke point(s) at "
<< getBasicBlockName(MBB) << "\n");
ShrinkWrapThisFunction = false;
return false;
DEBUG({
- DOUT << "ENABLED: " << Fn.getFunction()->getName();
+ errs() << "ENABLED: " << Fn.getFunction()->getName();
if (HasFastExitPath)
- DOUT << " (fast exit path)";
- DOUT << "\n";
+ errs() << " (fast exit path)";
+ errs() << "\n";
if (ShrinkWrapDebugging >= BasicInfo) {
- DOUT << "------------------------------"
+ errs() << "------------------------------"
<< "-----------------------------\n";
- DOUT << "UsedCSRegs = " << stringifyCSRegSet(UsedCSRegs) << "\n";
+ errs() << "UsedCSRegs = " << stringifyCSRegSet(UsedCSRegs) << "\n";
if (ShrinkWrapDebugging >= Details) {
- DOUT << "------------------------------"
+ errs() << "------------------------------"
<< "-----------------------------\n";
dumpAllUsed();
}
addedUses = true;
blks.push_back(SUCC);
DEBUG(if (ShrinkWrapDebugging >= Iterations)
- DOUT << getBasicBlockName(MBB)
+ errs() << getBasicBlockName(MBB)
<< "(" << stringifyCSRegSet(prop) << ")->"
<< "successor " << getBasicBlockName(SUCC) << "\n");
}
addedUses = true;
blks.push_back(PRED);
DEBUG(if (ShrinkWrapDebugging >= Iterations)
- DOUT << getBasicBlockName(MBB)
+ errs() << getBasicBlockName(MBB)
<< "(" << stringifyCSRegSet(prop) << ")->"
<< "predecessor " << getBasicBlockName(PRED) << "\n");
}
CSRUsed[EXB] |= loopSpills;
addedUses = true;
DEBUG(if (ShrinkWrapDebugging >= Iterations)
- DOUT << "LOOP " << getBasicBlockName(MBB)
+ errs() << "LOOP " << getBasicBlockName(MBB)
<< "(" << stringifyCSRegSet(loopSpills) << ")->"
<< getBasicBlockName(EXB) << "\n");
if (EXB->succ_size() > 1 || EXB->pred_size() > 1)
blks.push_back(MBB);
DEBUG(if (! CSRSave[MBB].empty() && ShrinkWrapDebugging >= Iterations)
- DOUT << "SAVE[" << getBasicBlockName(MBB) << "] = "
+ errs() << "SAVE[" << getBasicBlockName(MBB) << "] = "
<< stringifyCSRegSet(CSRSave[MBB]) << "\n");
return placedSpills;
blks.push_back(MBB);
DEBUG(if (! CSRRestore[MBB].empty() && ShrinkWrapDebugging >= Iterations)
- DOUT << "RESTORE[" << getBasicBlockName(MBB) << "] = "
+ errs() << "RESTORE[" << getBasicBlockName(MBB) << "] = "
<< stringifyCSRegSet(CSRRestore[MBB]) << "\n");
return placedRestores;
++iterations;
DEBUG(if (ShrinkWrapDebugging >= Iterations)
- DOUT << "iter " << iterations
+ errs() << "iter " << iterations
<< " --------------------------------------------------\n");
// Calculate CSR{Save,Restore} sets using Antic, Avail on the MCFG,
unsigned numSRReducedThisFunc = notSpilledInEntryBlock.count();
numSRReduced += numSRReducedThisFunc;
DEBUG(if (ShrinkWrapDebugging >= BasicInfo) {
- DOUT << "-----------------------------------------------------------\n";
- DOUT << "total iterations = " << iterations << " ( "
+ errs() << "-----------------------------------------------------------\n";
+ errs() << "total iterations = " << iterations << " ( "
<< Fn.getFunction()->getName()
<< " " << numSRReducedThisFunc
<< " " << Fn.size()
<< " )\n";
- DOUT << "-----------------------------------------------------------\n";
+ errs() << "-----------------------------------------------------------\n";
dumpSRSets();
- DOUT << "-----------------------------------------------------------\n";
+ errs() << "-----------------------------------------------------------\n";
if (numSRReducedThisFunc)
verifySpillRestorePlacement();
});
// Check the immediate successors.
if (isReturnBlock(SUCC)) {
if (ShrinkWrapDebugging >= BasicInfo)
- DOUT << "Fast exit path: " << getBasicBlockName(EntryBlock)
+ errs() << "Fast exit path: " << getBasicBlockName(EntryBlock)
<< "->" << getBasicBlockName(SUCC) << "\n";
break;
}
}
if (HasFastExitPath) {
if (ShrinkWrapDebugging >= BasicInfo)
- DOUT << "Fast exit path: " << getBasicBlockName(EntryBlock)
+ errs() << "Fast exit path: " << getBasicBlockName(EntryBlock)
<< "->" << exitPath << "\n";
break;
}
if (isReturnBlock(SBB) || SBB->succ_size() == 0) {
if (restored != spilled) {
CSRegSet notRestored = (spilled - restored);
- DOUT << MF->getFunction()->getName() << ": "
- << stringifyCSRegSet(notRestored)
- << " spilled at " << getBasicBlockName(MBB)
- << " are never restored on path to return "
- << getBasicBlockName(SBB) << "\n";
+ DEBUG(errs() << MF->getFunction()->getName() << ": "
+ << stringifyCSRegSet(notRestored)
+ << " spilled at " << getBasicBlockName(MBB)
+ << " are never restored on path to return "
+ << getBasicBlockName(SBB) << "\n");
}
restored.clear();
}
}
if (spilled != restored) {
CSRegSet notSpilled = (restored - spilled);
- DOUT << MF->getFunction()->getName() << ": "
- << stringifyCSRegSet(notSpilled)
- << " restored at " << getBasicBlockName(MBB)
- << " are never spilled\n";
+ DEBUG(errs() << MF->getFunction()->getName() << ": "
+ << stringifyCSRegSet(notSpilled)
+ << " restored at " << getBasicBlockName(MBB)
+ << " are never spilled\n");
}
}
}
// Debugging print methods.
std::string PEI::getBasicBlockName(const MachineBasicBlock* MBB) {
+ if (!MBB)
+ return "";
+
+ if (MBB->getBasicBlock())
+ return MBB->getBasicBlock()->getNameStr();
+
std::ostringstream name;
- if (MBB) {
- if (MBB->getBasicBlock())
- name << MBB->getBasicBlock()->getName();
- else
- name << "_MBB_" << MBB->getNumber();
- }
+ name << "_MBB_" << MBB->getNumber();
return name.str();
}
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/ErrorHandling.h"
+#include "llvm/Support/raw_ostream.h"
#include "llvm/ADT/SmallSet.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/ADT/STLExtras.h"
DstSubRC = DstRC->getSubRegisterRegClass(DstSubIdx);
assert(DstSubRC && "Illegal subregister index");
if (!DstSubRC->contains(SrcSubReg)) {
- DOUT << "\tIncompatible destination regclass: "
- << tri_->getName(SrcSubReg) << " not in " << DstSubRC->getName()
- << ".\n";
+ DEBUG(errs() << "\tIncompatible destination regclass: "
+ << tri_->getName(SrcSubReg) << " not in " << DstSubRC->getName()
+ << ".\n");
return false; // Not coalescable.
}
}
SrcSubRC = SrcRC->getSubRegisterRegClass(SrcSubIdx);
assert(SrcSubRC && "Illegal subregister index");
if (!SrcSubRC->contains(DstReg)) {
- DOUT << "\tIncompatible source regclass: "
- << tri_->getName(DstSubReg) << " not in " << SrcSubRC->getName()
- << ".\n";
+ DEBUG(errs() << "\tIncompatible source regclass: "
+ << tri_->getName(DstSubReg) << " not in " << SrcSubRC->getName()
+ << ".\n");
return false; // Not coalescable.
}
}
} else if (!SrcIsPhys && !DstIsPhys) {
NewRC = getCommonSubClass(SrcRC, DstRC);
if (!NewRC) {
- DOUT << "\tDisjoint regclasses: "
- << SrcRC->getName() << ", "
- << DstRC->getName() << ".\n";
+ DEBUG(errs() << "\tDisjoint regclasses: "
+ << SrcRC->getName() << ", "
+ << DstRC->getName() << ".\n");
return false; // Not coalescable.
}
if (DstRC->getSize() > SrcRC->getSize())
void SimpleRegisterCoalescing::CopyCoalesceInMBB(MachineBasicBlock *MBB,
std::vector<CopyRec> &TryAgain) {
- DOUT << ((Value*)MBB->getBasicBlock())->getName() << ":\n";
+ DEBUG(errs() << ((Value*)MBB->getBasicBlock())->getName() << ":\n");
std::vector<CopyRec> VirtCopies;
std::vector<CopyRec> PhysCopies;
li_ = &getAnalysis<LiveIntervals>();
loopInfo = &getAnalysis<MachineLoopInfo>();
- DOUT << "********** SIMPLE REGISTER COALESCING **********\n"
- << "********** Function: "
- << ((Value*)mf_->getFunction())->getName() << '\n';
+ DEBUG(errs() << "********** SIMPLE REGISTER COALESCING **********\n"
+ << "********** Function: "
+ << ((Value*)mf_->getFunction())->getName() << '\n');
allocatableRegs_ = tri_->getAllocatableSet(fn);
for (TargetRegisterInfo::regclass_iterator I = tri_->regclass_begin(),
bool MadeChange = false;
DOUT << "********** REWRITING TWO-ADDR INSTRS **********\n";
- DOUT << "********** Function: " << MF.getFunction()->getName() << '\n';
+ DEBUG(errs() << "********** Function: "
+ << MF.getFunction()->getName() << '\n');
// ReMatRegs - Keep track of the registers whose def's are remat'ed.
BitVector ReMatRegs;
#include "VirtRegRewriter.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/ErrorHandling.h"
+#include "llvm/Support/raw_ostream.h"
#include "llvm/ADT/DepthFirstIterator.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/ADT/STLExtras.h"
bool runOnMachineFunction(MachineFunction &MF, VirtRegMap &VRM,
LiveIntervals* LIs) {
DOUT << "********** REWRITE MACHINE CODE **********\n";
- DOUT << "********** Function: " << MF.getFunction()->getName() << '\n';
+ DEBUG(errs() << "********** Function: "
+ << MF.getFunction()->getName() << '\n');
MachineRegisterInfo *mri = &MF.getRegInfo();
bool changed = false;
TRI = MF.getTarget().getRegisterInfo();
TII = MF.getTarget().getInstrInfo();
AllocatableRegs = TRI->getAllocatableSet(MF);
- DOUT << "\n**** Local spiller rewriting function '"
- << MF.getFunction()->getName() << "':\n";
+ DEBUG(errs() << "\n**** Local spiller rewriting function '"
+ << MF.getFunction()->getName() << "':\n");
DOUT << "**** Machine Instrs (NOTE! Does not include spills and reloads!)"
" ****\n";
DEBUG(MF.dump());
AvailableSpills &Spills, BitVector &RegKills,
std::vector<MachineOperand*> &KillOps) {
- DOUT << "\n**** Local spiller rewriting MBB '"
- << MBB.getBasicBlock()->getName() << "':\n";
+ DEBUG(errs() << "\n**** Local spiller rewriting MBB '"
+ << MBB.getBasicBlock()->getName() << "':\n");
MachineFunction &MF = *MBB.getParent();
TheJIT->updateGlobalMapping(F, Stub);
}
- DOUT << "JIT: Stub emitted at [" << Stub << "] for function '"
- << F->getName() << "'\n";
+ DEBUG(errs() << "JIT: Stub emitted at [" << Stub << "] for function '"
+ << F->getName() << "'\n");
// Finally, keep track of the stub-to-Function mapping so that the
// JITCompilerFn knows which function to compile!
IndirectSym = TheJIT->getJITInfo().emitGlobalValueIndirectSym(GV, GVAddress,
*TheJIT->getCodeEmitter());
- DOUT << "JIT: Indirect symbol emitted at [" << IndirectSym << "] for GV '"
- << GV->getName() << "'\n";
+ DEBUG(errs() << "JIT: Indirect symbol emitted at [" << IndirectSym
+ << "] for GV '" << GV->getName() << "'\n");
return IndirectSym;
}
// it needs to call.
//JR.state.getStubToFunctionMap(locked).erase(I);
- DOUT << "JIT: Lazily resolving function '" << F->getName()
- << "' In stub ptr = " << Stub << " actual ptr = "
- << ActualPtr << "\n";
+ DEBUG(errs() << "JIT: Lazily resolving function '" << F->getName()
+ << "' In stub ptr = " << Stub << " actual ptr = "
+ << ActualPtr << "\n");
Result = TheJIT->getPointerToFunction(F);
}
}
void JITEmitter::startFunction(MachineFunction &F) {
- DOUT << "JIT: Starting CodeGen of Function "
- << F.getFunction()->getName() << "\n";
+ DEBUG(errs() << "JIT: Starting CodeGen of Function "
+ << F.getFunction()->getName() << "\n");
uintptr_t ActualSize = 0;
// Set the memory writable, if it's not already
TheJIT->NotifyFunctionEmitted(*F.getFunction(), FnStart, FnEnd-FnStart,
EmissionDetails);
- DOUT << "JIT: Finished CodeGen of [" << (void*)FnStart
- << "] Function: " << F.getFunction()->getName()
- << ": " << (FnEnd-FnStart) << " bytes of text, "
- << Relocations.size() << " relocations\n";
+ DEBUG(errs() << "JIT: Finished CodeGen of [" << (void*)FnStart
+ << "] Function: " << F.getFunction()->getName()
+ << ": " << (FnEnd-FnStart) << " bytes of text, "
+ << Relocations.size() << " relocations\n");
Relocations.clear();
ConstPoolAddresses.clear();
JTI->Initialize(MF, IsPIC);
do {
- DOUT << "JITTing function '" << MF.getFunction()->getName() << "'\n";
+ DEBUG(errs() << "JITTing function '"
+ << MF.getFunction()->getName() << "'\n");
MCE.startFunction(MF);
for (MachineFunction::iterator MBB = MF.begin(), E = MF.end();
MBB != E; ++MBB) {
} else {
Constant *CV = MCPE.Val.ConstVal;
-#ifndef NDEBUG
- DOUT << " ** Constant pool #" << CPI << " @ "
- << (void*)MCE.getCurrentPCValue() << " ";
- if (const Function *F = dyn_cast<Function>(CV))
- DOUT << F->getName();
- else
- DOUT << *CV;
- DOUT << '\n';
-#endif
+ DEBUG({
+ errs() << " ** Constant pool #" << CPI << " @ "
+ << (void*)MCE.getCurrentPCValue() << " ";
+ if (const Function *F = dyn_cast<Function>(CV))
+ errs() << F->getName();
+ else
+ errs() << *CV;
+ errs() << '\n';
+ });
if (GlobalValue *GV = dyn_cast<GlobalValue>(CV)) {
emitGlobalAddress(GV, ARM::reloc_arm_absolute, isa<Function>(GV));
#include "llvm/Support/Debug.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/Streams.h"
+#include "llvm/Support/raw_ostream.h"
#include "llvm/System/Memory.h"
#include <cstdlib>
using namespace llvm;
if (!LazyPtr) {
// In PIC mode, the function stub is loading a lazy-ptr.
LazyPtr= (intptr_t)emitGlobalValueIndirectSym((GlobalValue*)F, Fn, JCE);
- if (F)
- DOUT << "JIT: Indirect symbol emitted at [" << LazyPtr << "] for GV '"
- << F->getName() << "'\n";
- else
- DOUT << "JIT: Stub emitted at [" << LazyPtr
- << "] for external function at '" << Fn << "'\n";
+ DEBUG(if (F)
+ errs() << "JIT: Indirect symbol emitted at [" << LazyPtr
+ << "] for GV '" << F->getName() << "'\n";
+ else
+ errs() << "JIT: Stub emitted at [" << LazyPtr
+ << "] for external function at '" << Fn << "'\n");
}
JCE.startGVStub(F, 16, 4);
intptr_t Addr = (intptr_t)JCE.getCurrentPCValue();
else if (const InvokeInst* Invoke = dyn_cast<InvokeInst>(Inst))
Name = getConvModopt(Invoke->getCallingConv());
else {
- cerr << "Instruction = " << Inst->getName() << '\n';
+ errs() << "Instruction = " << Inst->getName() << '\n';
llvm_unreachable("Need \"Invoke\" or \"Call\" instruction only");
}
if (const Function* F = dyn_cast<Function>(FnVal)) {
printSimpleInstruction("cpobj","[mscorlib]System.ArgIterator");
break;
default:
- cerr << "Intrinsic ID = " << Inst->getIntrinsicID() << '\n';
+ errs() << "Intrinsic ID = " << Inst->getIntrinsicID() << '\n';
llvm_unreachable("Invalid intrinsic function");
}
}
printBinaryInstruction("cgt",Left,Right);
break;
default:
- cerr << "Predicate = " << Predicate << '\n';
+ errs() << "Predicate = " << Predicate << '\n';
llvm_unreachable("Invalid icmp predicate");
}
}
printVAArgInstruction(cast<VAArgInst>(Inst));
break;
default:
- cerr << "Instruction = " << Inst->getName() << '\n';
+ errs() << "Instruction = " << Inst->getName() << '\n';
llvm_unreachable("Unsupported instruction");
}
}
printBinaryInstruction("shr",left,right);
break;
default:
- cerr << "Expression = " << *CE << "\n";
+ errs() << "Expression = " << *CE << "\n";
llvm_unreachable("Invalid constant expression");
}
}
postfix = "stind."+postfix;
printSimpleInstruction(postfix.c_str());
} else {
- cerr << "Constant = " << *I->constant << '\n';
+ errs() << "Constant = " << *I->constant << '\n';
llvm_unreachable("Invalid static initializer");
}
}
case 64:
return N;
default:
- cerr << "Bits = " << N << '\n';
+ errs() << "Bits = " << N << '\n';
llvm_unreachable("Unsupported integer width");
}
return 0; // Not reached
}
break;
default:
- cerr << "TypeID = " << Ty->getTypeID() << '\n';
+ errs() << "TypeID = " << Ty->getTypeID() << '\n';
llvm_unreachable("Invalid type in printStaticConstant()");
}
// Increase offset.
Out << getTypeName(C->getType());
break;
default:
- cerr << "Type = " << *C << "\n";
+ errs() << "Type = " << *C << "\n";
llvm_unreachable("Invalid constant type");
}
// Print initializer
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/ErrorHandling.h"
+#include "llvm/Support/raw_ostream.h"
#include "llvm/ADT/BitVector.h"
#include "llvm/ADT/STLExtras.h"
}
#ifndef NDEBUG
- DOUT << "\nFunction : " << MF.getFunction()->getName() << "\n";
+ DEBUG(errs() << "\nFunction : " << MF.getFunction()->getName() << "\n");
DOUT << "<--------->\n";
MI.print(DOUT);
#endif
#include "llvm/Support/Compiler.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/ErrorHandling.h"
+#include "llvm/Support/raw_ostream.h"
#include "llvm/Target/TargetOptions.h"
using namespace llvm;
IsPIC = TM.getRelocationModel() == Reloc::PIC_;
do {
- DOUT << "JITTing function '" << MF.getFunction()->getName() << "'\n";
+ DEBUG(errs() << "JITTing function '"
+ << MF.getFunction()->getName() << "'\n");
MCE.startFunction(MF);
for (MachineFunction::iterator MBB = MF.begin(), E = MF.end();
MBB != E; ++MBB) {
if (!Desc->isVariadic() && CurOp != NumOps) {
#ifndef NDEBUG
- cerr << "Cannot encode: " << MI << "\n";
+ errs() << "Cannot encode: " << MI << "\n";
#endif
llvm_unreachable(0);
}
#include "llvm/CodeGen/ValueTypes.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/ErrorHandling.h"
+#include "llvm/Support/raw_ostream.h"
#include "llvm/ADT/VectorExtras.h"
#include <queue>
#include <set>
const Type *Ty = cast<PointerType>(GV->getType())->getElementType();
if (!Ty->isSized() || isZeroLengthArray(Ty)) {
#ifndef NDEBUG
- cerr << "Size of thread local object " << GVar->getName()
- << " is unknown\n";
+ errs() << "Size of thread local object " << GVar->getName()
+ << " is unknown\n";
#endif
llvm_unreachable(0);
}
default:
{
#ifndef NDEBUG
- cerr << "LowerFORMAL_ARGUMENTS Unhandled argument type: "
- << RegVT.getSimpleVT() << "\n";
+ errs() << "LowerFORMAL_ARGUMENTS Unhandled argument type: "
+ << RegVT.getSimpleVT() << "\n";
#endif
llvm_unreachable(0);
}
// Load the argument to a virtual register
unsigned ObjSize = VA.getLocVT().getSizeInBits()/8;
if (ObjSize > StackSlotSize) {
- cerr << "LowerFORMAL_ARGUMENTS Unhandled argument type: "
- << VA.getLocVT().getSimpleVT()
- << "\n";
+ errs() << "LowerFORMAL_ARGUMENTS Unhandled argument type: "
+ << VA.getLocVT().getSimpleVT()
+ << "\n";
}
// Create the frame index object for this incoming parameter...
int FI = MFI->CreateFixedObject(ObjSize,
int StackSize = MF.getFrameInfo()->getStackSize();
#ifndef NDEBUG
- DOUT << "\nFunction : " << MF.getFunction()->getName() << "\n";
+ DEBUG(errs() << "\nFunction : "
+ << MF.getFunction()->getName() << "\n");
DOUT << "<--------->\n";
MI.print(DOUT);
DOUT << "FrameIndex : " << FrameIndex << "\n";
#include "llvm/Analysis/CallGraph.h"
#include "llvm/Target/TargetData.h"
#include "llvm/Support/CallSite.h"
+#include "llvm/Support/Compiler.h"
#include "llvm/Support/CFG.h"
#include "llvm/Support/Debug.h"
+#include "llvm/Support/raw_ostream.h"
#include "llvm/ADT/DepthFirstIterator.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/ADT/StringExtras.h"
-#include "llvm/Support/Compiler.h"
#include <set>
using namespace llvm;
const Type *AgTy = cast<PointerType>(PtrArg->getType())->getElementType();
if (const StructType *STy = dyn_cast<StructType>(AgTy)) {
if (maxElements > 0 && STy->getNumElements() > maxElements) {
- DOUT << "argpromotion disable promoting argument '"
- << PtrArg->getName() << "' because it would require adding more "
- << "than " << maxElements << " arguments to the function.\n";
+ DEBUG(errs() << "argpromotion disable promoting argument '"
+ << PtrArg->getName() << "' because it would require adding more"
+ << " than " << maxElements << " arguments to the function.\n");
} else {
// If all the elements are single-value types, we can promote it.
bool AllSimple = true;
// to do.
if (ToPromote.find(Operands) == ToPromote.end()) {
if (maxElements > 0 && ToPromote.size() == maxElements) {
- DOUT << "argpromotion not promoting argument '"
- << Arg->getName() << "' because it would require adding more "
- << "than " << maxElements << " arguments to the function.\n";
+ DEBUG(errs() << "argpromotion not promoting argument '"
+ << Arg->getName() << "' because it would require adding more "
+ << "than " << maxElements << " arguments to the function.\n");
// We limit aggregate promotion to only promoting up to a fixed number
// of elements of the aggregate.
return false;
LI->replaceAllUsesWith(I2);
AA.replaceWithNewValue(LI, I2);
LI->eraseFromParent();
- DOUT << "*** Promoted load of argument '" << I->getName()
- << "' in function '" << F->getName() << "'\n";
+ DEBUG(errs() << "*** Promoted load of argument '" << I->getName()
+ << "' in function '" << F->getName() << "'\n");
} else {
GetElementPtrInst *GEP = cast<GetElementPtrInst>(I->use_back());
IndicesVector Operands;
NewName += ".val";
TheArg->setName(NewName);
- DOUT << "*** Promoted agg argument '" << TheArg->getName()
- << "' of function '" << NF->getName() << "'\n";
+ DEBUG(errs() << "*** Promoted agg argument '" << TheArg->getName()
+ << "' of function '" << NF->getName() << "'\n");
// All of the uses must be load instructions. Replace them all with
// the argument specified by ArgNo.
#include "llvm/Pass.h"
#include "llvm/Support/CallSite.h"
#include "llvm/Support/Debug.h"
+#include "llvm/Support/raw_ostream.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/ADT/StringExtras.h"
return;
}
- DOUT << "DAE - Inspecting callers for fn: " << F.getName() << "\n";
+ DEBUG(errs() << "DAE - Inspecting callers for fn: " << F.getName() << "\n");
// Keep track of the number of live retvals, so we can skip checks once all
// of them turn out to be live.
unsigned NumLiveRetVals = 0;
for (unsigned i = 0; i != RetCount; ++i)
MarkValue(CreateRet(&F, i), RetValLiveness[i], MaybeLiveRetUses[i]);
- DOUT << "DAE - Inspecting args for fn: " << F.getName() << "\n";
+ DEBUG(errs() << "DAE - Inspecting args for fn: " << F.getName() << "\n");
// Now, check all of our arguments.
unsigned i = 0;
/// mark any values that are used as this function's parameters or by its return
/// values (according to Uses) live as well.
void DAE::MarkLive(const Function &F) {
- DOUT << "DAE - Intrinsically live fn: " << F.getName() << "\n";
+ DEBUG(errs() << "DAE - Intrinsically live fn: " << F.getName() << "\n");
// Mark the function as live.
LiveFunctions.insert(&F);
// Mark all arguments as live.
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/GetElementPtrTypeIterator.h"
#include "llvm/Support/MathExtras.h"
+#include "llvm/Support/raw_ostream.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/ADT/SmallVector.h"
CallStack, MutatedMemory, AllocaTmps);
if (EvalSuccess) {
// We succeeded at evaluation: commit the result.
- DOUT << "FULLY EVALUATED GLOBAL CTOR FUNCTION '"
- << F->getName() << "' to " << MutatedMemory.size()
- << " stores.\n";
+ DEBUG(errs() << "FULLY EVALUATED GLOBAL CTOR FUNCTION '"
+ << F->getName() << "' to " << MutatedMemory.size()
+ << " stores.\n");
for (DenseMap<Constant*, Constant*>::iterator I = MutatedMemory.begin(),
E = MutatedMemory.end(); I != E; ++I)
CommitValueTo(I->second, I->first, F->getContext());
#include "llvm/Transforms/Utils/Cloning.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Debug.h"
+#include "llvm/Support/raw_ostream.h"
#include "llvm/ADT/Statistic.h"
#include <set>
using namespace llvm;
if (Callee->use_empty() && (Callee->hasLocalLinkage() ||
Callee->hasAvailableExternallyLinkage()) &&
!SCCFunctions.count(Callee)) {
- DOUT << " -> Deleting dead function: " << Callee->getName() << "\n";
+ DEBUG(errs() << " -> Deleting dead function: "
+ << Callee->getName() << "\n");
CallGraphNode *CalleeNode = CG[Callee];
// Remove any call graph edges from the callee to its callees.
for (unsigned i = 0, e = SCC.size(); i != e; ++i) {
Function *F = SCC[i]->getFunction();
if (F) SCCFunctions.insert(F);
- DOUT << " " << (F ? F->getName() : "INDIRECTNODE");
+ DEBUG(errs() << " " << (F ? F->getName() : "INDIRECTNODE"));
}
// Scan through and identify all call sites ahead of time so that we only
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/Debug.h"
+#include "llvm/Support/raw_ostream.h"
#include "llvm/ADT/Statistic.h"
#include <fstream>
#include <set>
if (ExternalNode) ExternalNode->removeOneAbstractEdgeTo((*CG)[I]);
Changed = true;
++NumFunctions;
- DOUT << "Internalizing func " << I->getName() << "\n";
+ DEBUG(errs() << "Internalizing func " << I->getName() << "\n");
}
// Never internalize the llvm.used symbol. It is used to implement
I->setLinkage(GlobalValue::InternalLinkage);
Changed = true;
++NumGlobals;
- DOUT << "Internalized gvar " << I->getName() << "\n";
+ DEBUG(errs() << "Internalized gvar " << I->getName() << "\n");
}
// Mark all aliases that are not in the api as internal as well.
I->setLinkage(GlobalValue::InternalLinkage);
Changed = true;
++NumAliases;
- DOUT << "Internalized alias " << I->getName() << "\n";
+ DEBUG(errs() << "Internalized alias " << I->getName() << "\n");
}
return Changed;
#include "llvm/Support/Compiler.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/ErrorHandling.h"
+#include "llvm/Support/raw_ostream.h"
#include <map>
#include <vector>
using namespace llvm;
for (int j = i + 1; j != e; ++j) {
bool isEqual = equals(FnVec[i], FnVec[j]);
- DOUT << " " << FnVec[i]->getName()
- << (isEqual ? " == " : " != ")
- << FnVec[j]->getName() << "\n";
+ DEBUG(errs() << " " << FnVec[i]->getName()
+ << (isEqual ? " == " : " != ")
+ << FnVec[j]->getName() << "\n");
if (isEqual) {
if (fold(FnVec, i, j)) {
#include "llvm/Support/Compiler.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/ErrorHandling.h"
+#include "llvm/Support/raw_ostream.h"
#include "llvm/Transforms/Instrumentation.h"
#include "RSProfiling.h"
#include <set>
std::map<BasicBlock*, int> finish;
int time = 0;
recBackEdge(&F.getEntryBlock(), BackEdges, color, depth, finish, time);
- DOUT << F.getName() << " " << BackEdges.size() << "\n";
+ DEBUG(errs() << F.getName() << " " << BackEdges.size() << "\n");
}
#include "llvm/Support/Compiler.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/ErrorHandling.h"
+#include "llvm/Support/raw_ostream.h"
#include "llvm/Transforms/Utils/BasicBlockUtils.h"
#include "llvm/Transforms/Utils/Local.h"
#include <cstdio>
// non-PHI instruction in this block, we don't know how to recompute it above.
if (Instruction *LPInst = dyn_cast<Instruction>(LoadPtr))
if (!DT->dominates(LPInst->getParent(), UnavailablePred)) {
- DEBUG(cerr << "COULDN'T PRE LOAD BECAUSE PTR IS UNAVAILABLE IN PRED: "
- << *LPInst << *LI << "\n");
+ DEBUG(errs() << "COULDN'T PRE LOAD BECAUSE PTR IS UNAVAILABLE IN PRED: "
+ << *LPInst << *LI << "\n");
return false;
}
// We don't currently handle critical edges :(
if (UnavailablePred->getTerminator()->getNumSuccessors() != 1) {
- DEBUG(cerr << "COULD NOT PRE LOAD BECAUSE OF CRITICAL EDGE '"
- << UnavailablePred->getName() << "': " << *LI);
+ DEBUG(errs() << "COULD NOT PRE LOAD BECAUSE OF CRITICAL EDGE '"
+ << UnavailablePred->getName() << "': " << *LI);
return false;
}
#include "llvm/Support/MathExtras.h"
#include "llvm/Support/PatternMatch.h"
#include "llvm/Support/Compiler.h"
+#include "llvm/Support/raw_ostream.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/SmallPtrSet.h"
// If we are removing arguments to the function, emit an obnoxious warning...
if (FT->getNumParams() < NumActualArgs) {
if (!FT->isVarArg()) {
- cerr << "WARNING: While resolving call to function '"
- << Callee->getName() << "' arguments were dropped!\n";
+ errs() << "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...
for (unsigned i = FT->getNumParams(); i != NumActualArgs; ++i, ++AI) {
bool Changed = false;
TD = getAnalysisIfAvailable<TargetData>();
- DEBUG(DOUT << "\n\nINSTCOMBINE ITERATION #" << Iteration << " on "
- << F.getNameStr() << "\n");
+ DEBUG(errs() << "\n\nINSTCOMBINE ITERATION #" << Iteration << " on "
+ << F.getNameStr() << "\n");
{
// Do a depth-first traversal of the function, populate the worklist with
#include "llvm/Support/CFG.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/CommandLine.h"
+#include "llvm/Support/raw_ostream.h"
#include "llvm/Support/Debug.h"
#include "llvm/ADT/Statistic.h"
#include <algorithm>
/// that is safe to hoist, this instruction is called to do the dirty work.
///
void LICM::hoist(Instruction &I) {
- DOUT << "LICM hoisting to " << Preheader->getName() << ": " << I;
+ DEBUG(errs() << "LICM hoisting to " << Preheader->getName() << ": " << I);
// Remove the instruction from its current basic block... but don't delete the
// instruction.
#include "llvm/Support/Compiler.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Debug.h"
+#include "llvm/Support/raw_ostream.h"
#include "llvm/Transforms/Utils/UnrollLoop.h"
#include <climits>
LoopInfo *LI = &getAnalysis<LoopInfo>();
BasicBlock *Header = L->getHeader();
- DOUT << "Loop Unroll: F[" << Header->getParent()->getName()
- << "] Loop %" << Header->getName() << "\n";
+ DEBUG(errs() << "Loop Unroll: F[" << Header->getParent()->getName()
+ << "] Loop %" << Header->getName() << "\n");
// Find trip count
unsigned TripCount = L->getSmallConstantTripCount();
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/Debug.h"
+#include "llvm/Support/raw_ostream.h"
#include <algorithm>
#include <set>
using namespace llvm;
// FIXME: this should estimate growth by the amount of code shared by the
// resultant unswitched loops.
//
- DOUT << "NOT unswitching loop %"
- << currentLoop->getHeader()->getName() << ", cost too high: "
- << currentLoop->getBlocks().size() << "\n";
+ DEBUG(errs() << "NOT unswitching loop %"
+ << currentLoop->getHeader()->getName() << ", cost too high: "
+ << currentLoop->getBlocks().size() << "\n");
return false;
}
void LoopUnswitch::UnswitchTrivialCondition(Loop *L, Value *Cond,
Constant *Val,
BasicBlock *ExitBlock) {
- DOUT << "loop-unswitch: Trivial-Unswitch loop %"
- << loopHeader->getName() << " [" << L->getBlocks().size()
- << " blocks] in Function " << L->getHeader()->getParent()->getName()
- << " on cond: " << *Val << " == " << *Cond << "\n";
+ DEBUG(errs() << "loop-unswitch: Trivial-Unswitch loop %"
+ << loopHeader->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 loopPreheader to have a
void LoopUnswitch::UnswitchNontrivialCondition(Value *LIC, Constant *Val,
Loop *L) {
Function *F = loopHeader->getParent();
- DOUT << "loop-unswitch: Unswitching loop %"
- << loopHeader->getName() << " [" << L->getBlocks().size()
- << " blocks] in Function " << F->getName()
- << " when '" << *Val << "' == " << *LIC << "\n";
+ DEBUG(errs() << "loop-unswitch: Unswitching loop %"
+ << loopHeader->getName() << " [" << L->getBlocks().size()
+ << " blocks] in Function " << F->getName()
+ << " when '" << *Val << "' == " << *LIC << "\n");
LoopBlocks.clear();
NewBlocks.clear();
if (!SinglePred) continue; // Nothing to do.
assert(SinglePred == Pred && "CFG broken");
- DOUT << "Merging blocks: " << Pred->getName() << " <- "
- << Succ->getName() << "\n";
+ DEBUG(errs() << "Merging blocks: " << Pred->getName() << " <- "
+ << Succ->getName() << "\n");
// Resolve any single entry PHI nodes in Succ.
while (PHINode *PN = dyn_cast<PHINode>(Succ->begin()))
#include "llvm/Support/ConstantRange.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/InstVisitor.h"
+#include "llvm/Support/raw_ostream.h"
#include "llvm/Target/TargetData.h"
#include "llvm/Transforms/Utils/Local.h"
#include <algorithm>
for (int i = 0; i < depth; ++i) { os << " "; }
os << "[" << depth << "] ";
- os << N->getBlock()->getName() << " (" << N->getDFSNumIn()
+ os << N->getBlock()->getNameStr() << " (" << N->getDFSNumIn()
<< ", " << N->getDFSNumOut() << ")\n";
for (Node::iterator I = N->begin(), E = N->end(); I != E; ++I)
E = DeadBlocks.end(); I != E; ++I) {
BasicBlock *BB = *I;
- DOUT << "unreachable block: " << BB->getName() << "\n";
+ DEBUG(errs() << "unreachable block: " << BB->getName() << "\n");
for (succ_iterator SI = succ_begin(BB), SE = succ_end(BB);
SI != SE; ++SI) {
bool makeEqual(Value *V1, Value *V2) {
DOUT << "makeEqual(" << *V1 << ", " << *V2 << ")\n";
DOUT << "context is ";
- if (TopInst) DOUT << "I: " << *TopInst << "\n";
- else DOUT << "BB: " << TopBB->getName()
- << "(" << Top->getDFSNumIn() << ")\n";
+ DEBUG(if (TopInst)
+ errs() << "I: " << *TopInst << "\n";
+ else
+ errs() << "BB: " << TopBB->getName()
+ << "(" << Top->getDFSNumIn() << ")\n");
assert(V1->getType() == V2->getType() &&
"Can't make two values with different types equal.");
assert(O.LHS == VN.canonicalize(O.LHS, Top) && "Canonicalize isn't.");
assert(O.RHS == VN.canonicalize(O.RHS, Top) && "Canonicalize isn't.");
- DOUT << "solving " << *O.LHS << " " << O.Op << " " << *O.RHS;
- if (O.ContextInst) DOUT << " context inst: " << *O.ContextInst;
- else DOUT << " context block: " << O.ContextBB->getName();
- DOUT << "\n";
+ DEBUG(errs() << "solving " << *O.LHS << " " << O.Op << " " << *O.RHS;
+ if (O.ContextInst)
+ errs() << " context inst: " << *O.ContextInst;
+ else
+ errs() << " context block: " << O.ContextBB->getName();
+ errs() << "\n";
- DEBUG(VN.dump());
- DEBUG(IG.dump());
- DEBUG(VR.dump());
+ VN.dump();
+ IG.dump();
+ VR.dump(););
// If they're both Constant, skip it. Check for contradiction and mark
// the BB as unreachable if so.
// Visits each instruction in the basic block.
void visitBasicBlock(DomTreeDFS::Node *Node) {
BasicBlock *BB = Node->getBlock();
- DOUT << "Entering Basic Block: " << BB->getName()
- << " (" << Node->getDFSNumIn() << ")\n";
+ DEBUG(errs() << "Entering Basic Block: " << BB->getName()
+ << " (" << Node->getDFSNumIn() << ")\n");
for (BasicBlock::iterator I = BB->begin(), E = BB->end(); I != E;) {
visitInstruction(I++, Node);
}
TargetData *TD = &getAnalysis<TargetData>();
Context = &F.getContext();
- DOUT << "Entering Function: " << F.getName() << "\n";
+ DEBUG(errs() << "Entering Function: " << F.getName() << "\n");
modified = false;
DomTreeDFS::Node *Root = DTDFS->getRootNode();
for (DomTreeDFS::Node::iterator I = DTNode->begin(), E = DTNode->end();
I != E; ++I) {
BasicBlock *Dest = (*I)->getBlock();
- DOUT << "Branch thinking about %" << Dest->getName()
- << "(" << PS->DTDFS->getNodeForBlock(Dest)->getDFSNumIn() << ")\n";
+ DEBUG(errs() << "Branch thinking about %" << Dest->getName()
+ << "(" << PS->DTDFS->getNodeForBlock(Dest)->getDFSNumIn() << ")\n");
if (Dest == TrueDest) {
- DOUT << "(" << DTNode->getBlock()->getName() << ") true set:\n";
+ DEBUG(errs() << "(" << DTNode->getBlock()->getName()
+ << ") true set:\n");
VRPSolver VRP(VN, IG, UB, VR, PS->DTDFS, PS->modified, Dest);
VRP.add(Context->getTrue(), Condition, ICmpInst::ICMP_EQ);
VRP.solve();
DEBUG(IG.dump());
DEBUG(VR.dump());
} else if (Dest == FalseDest) {
- DOUT << "(" << DTNode->getBlock()->getName() << ") false set:\n";
+ DEBUG(errs() << "(" << DTNode->getBlock()->getName()
+ << ") false set:\n");
VRPSolver VRP(VN, IG, UB, VR, PS->DTDFS, PS->modified, Dest);
VRP.add(Context->getFalse(), Condition, ICmpInst::ICMP_EQ);
VRP.solve();
for (DomTreeDFS::Node::iterator I = DTNode->begin(), E = DTNode->end();
I != E; ++I) {
BasicBlock *BB = (*I)->getBlock();
- DOUT << "Switch thinking about BB %" << BB->getName()
- << "(" << PS->DTDFS->getNodeForBlock(BB)->getDFSNumIn() << ")\n";
+ DEBUG(errs() << "Switch thinking about BB %" << BB->getName()
+ << "(" << PS->DTDFS->getNodeForBlock(BB)->getDFSNumIn() << ")\n");
VRPSolver VRP(VN, IG, UB, VR, PS->DTDFS, PS->modified, BB);
if (BB == SI.getDefaultDest()) {
#include "llvm/Support/Debug.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/InstVisitor.h"
+#include "llvm/Support/raw_ostream.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/DenseSet.h"
#include "llvm/ADT/SmallSet.h"
// work list so that the users of the instruction are updated later.
inline void markOverdefined(LatticeVal &IV, Value *V) {
if (IV.markOverdefined()) {
- DEBUG(DOUT << "markOverdefined: ";
+ DEBUG(errs() << "markOverdefined: ";
if (Function *F = dyn_cast<Function>(V))
- DOUT << "Function '" << F->getName() << "'\n";
+ errs() << "Function '" << F->getName() << "'\n";
else
- DOUT << *V);
+ errs() << *V);
// Only instructions go on the work list
OverdefinedInstWorkList.push_back(V);
}
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/Debug.h"
+#include "llvm/Support/raw_ostream.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/ADT/SmallPtrSet.h"
#include <map>
BasicBlock *DestBlock = Branch->getSuccessor(0);
assert(SourceBlock != DestBlock && "Our predicate is broken!");
- DOUT << "TailDuplication[" << SourceBlock->getParent()->getName()
- << "]: Eliminating branch: " << *Branch;
+ DEBUG(errs() << "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)) {
- DOUT << "Found shared dominator: " << DomBlock->getName() << "\n";
+ DEBUG(errs() << "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
#include "llvm/GlobalVariable.h"
#include "llvm/Support/CFG.h"
#include "llvm/Support/Debug.h"
+#include "llvm/Support/raw_ostream.h"
#include "llvm/Analysis/ConstantFolding.h"
#include "llvm/Transforms/Utils/BasicBlockUtils.h"
#include "llvm/ADT/SmallVector.h"
if (NumPhis > 2)
return false;
- DOUT << "FOUND IF CONDITION! " << *IfCond << " T: "
- << IfTrue->getName() << " F: " << IfFalse->getName() << "\n";
+ DEBUG(errs() << "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
#include "llvm/Analysis/ConstantFolding.h"
#include "llvm/Analysis/LoopPass.h"
#include "llvm/Support/Debug.h"
+#include "llvm/Support/raw_ostream.h"
#include "llvm/Transforms/Utils/BasicBlockUtils.h"
#include "llvm/Transforms/Utils/Cloning.h"
#include "llvm/Transforms/Utils/Local.h"
}
if (CompletelyUnroll) {
- DOUT << "COMPLETELY UNROLLING loop %" << Header->getName()
- << " with trip count " << TripCount << "!\n";
+ DEBUG(errs() << "COMPLETELY UNROLLING loop %" << Header->getName()
+ << " with trip count " << TripCount << "!\n");
} else {
- DOUT << "UNROLLING loop %" << Header->getName()
- << " by " << Count;
+ DEBUG(errs() << "UNROLLING loop %" << Header->getName()
+ << " by " << Count);
if (TripMultiple == 0 || BreakoutTrip != TripMultiple) {
DOUT << " with a breakout at trip " << BreakoutTrip;
} else if (TripMultiple != 1) {