Cleanup dump() functions.

We had various variants of defining dump() functions in LLVM. Normalize
them (this should just consistently implement the things discussed in
http://lists.llvm.org/pipermail/cfe-dev/2014-January/034323.html

For reference:
- Public headers should just declare the dump() method but not use
  LLVM_DUMP_METHOD or #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
- The definition of a dump method should look like this:
  #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
  LLVM_DUMP_METHOD void MyClass::dump() {
    // print stuff to dbgs()...
  }
  #endif

llvm-svn: 293359
This commit is contained in:
Matthias Braun 2017-01-28 02:02:38 +00:00
parent cfa5dc4a1d
commit 8c209aa877
94 changed files with 376 additions and 195 deletions

View File

@ -229,7 +229,7 @@ public:
void print(raw_ostream &os, ModuleSlotTracker &MST, void print(raw_ostream &os, ModuleSlotTracker &MST,
const TargetRegisterInfo *TRI = nullptr, const TargetRegisterInfo *TRI = nullptr,
const TargetIntrinsicInfo *IntrinsicInfo = nullptr) const; const TargetIntrinsicInfo *IntrinsicInfo = nullptr) const;
LLVM_DUMP_METHOD void dump() const; void dump() const;
//===--------------------------------------------------------------------===// //===--------------------------------------------------------------------===//
// Accessors that tell you what kind of MachineOperand you're looking at. // Accessors that tell you what kind of MachineOperand you're looking at.

View File

@ -146,7 +146,7 @@ public:
void addPressureChange(unsigned RegUnit, bool IsDec, void addPressureChange(unsigned RegUnit, bool IsDec,
const MachineRegisterInfo *MRI); const MachineRegisterInfo *MRI);
LLVM_DUMP_METHOD void dump(const TargetRegisterInfo &TRI) const; void dump(const TargetRegisterInfo &TRI) const;
}; };
/// List of registers defined and used by a machine instruction. /// List of registers defined and used by a machine instruction.

View File

@ -445,6 +445,9 @@ void AnnotateIgnoreWritesEnd(const char *file, int line);
/// \brief Mark debug helper function definitions like dump() that should not be /// \brief Mark debug helper function definitions like dump() that should not be
/// stripped from debug builds. /// stripped from debug builds.
/// Note that you should also surround dump() functions with
/// `#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)` so they do always
/// get stripped in release builds.
// FIXME: Move this to a private config.h as it's not usable in public headers. // FIXME: Move this to a private config.h as it's not usable in public headers.
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
#define LLVM_DUMP_METHOD LLVM_ATTRIBUTE_NOINLINE LLVM_ATTRIBUTE_USED #define LLVM_DUMP_METHOD LLVM_ATTRIBUTE_NOINLINE LLVM_ATTRIBUTE_USED

View File

@ -248,6 +248,7 @@ public:
bool readGCNO(GCOVBuffer &Buffer); bool readGCNO(GCOVBuffer &Buffer);
bool readGCDA(GCOVBuffer &Buffer); bool readGCDA(GCOVBuffer &Buffer);
uint32_t getChecksum() const { return Checksum; } uint32_t getChecksum() const { return Checksum; }
void print(raw_ostream &OS) const;
void dump() const; void dump() const;
void collectLineCounts(FileInfo &FI); void collectLineCounts(FileInfo &FI);
@ -290,6 +291,7 @@ public:
return make_range(block_begin(), block_end()); return make_range(block_begin(), block_end());
} }
void print(raw_ostream &OS) const;
void dump() const; void dump() const;
void collectLineCounts(FileInfo &FI); void collectLineCounts(FileInfo &FI);
@ -361,6 +363,7 @@ public:
return make_range(dst_begin(), dst_end()); return make_range(dst_begin(), dst_end());
} }
void print(raw_ostream &OS) const;
void dump() const; void dump() const;
void collectLineCounts(FileInfo &FI); void collectLineCounts(FileInfo &FI);

View File

@ -1462,6 +1462,7 @@ public:
ResolveFirst = b; ResolveFirst = b;
} }
void print(raw_ostream &OS) const;
void dump() const; void dump() const;
//===--------------------------------------------------------------------===// //===--------------------------------------------------------------------===//

View File

@ -28,7 +28,9 @@ ScaledNumber<uint64_t> BlockMass::toScaled() const {
return ScaledNumber<uint64_t>(getMass() + 1, -64); return ScaledNumber<uint64_t>(getMass() + 1, -64);
} }
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
LLVM_DUMP_METHOD void BlockMass::dump() const { print(dbgs()); } LLVM_DUMP_METHOD void BlockMass::dump() const { print(dbgs()); }
#endif
static char getHexDigit(int N) { static char getHexDigit(int N) {
assert(N < 16); assert(N < 16);

View File

@ -125,8 +125,9 @@ void CallGraph::print(raw_ostream &OS) const {
CN->print(OS); CN->print(OS);
} }
LLVM_DUMP_METHOD #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
void CallGraph::dump() const { print(dbgs()); } LLVM_DUMP_METHOD void CallGraph::dump() const { print(dbgs()); }
#endif
// removeFunctionFromModule - Unlink the function from this module, returning // removeFunctionFromModule - Unlink the function from this module, returning
// it. Because this removes the function from the module, the call graph node // it. Because this removes the function from the module, the call graph node
@ -194,8 +195,9 @@ void CallGraphNode::print(raw_ostream &OS) const {
OS << '\n'; OS << '\n';
} }
LLVM_DUMP_METHOD #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
void CallGraphNode::dump() const { print(dbgs()); } LLVM_DUMP_METHOD void CallGraphNode::dump() const { print(dbgs()); }
#endif
/// removeCallEdgeFor - This method removes the edge in the node for the /// removeCallEdgeFor - This method removes the edge in the node for the
/// specified call site. Note that this method takes linear time, so it /// specified call site. Note that this method takes linear time, so it
@ -307,8 +309,10 @@ void CallGraphWrapperPass::print(raw_ostream &OS, const Module *) const {
G->print(OS); G->print(OS);
} }
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
LLVM_DUMP_METHOD LLVM_DUMP_METHOD
void CallGraphWrapperPass::dump() const { print(dbgs(), nullptr); } void CallGraphWrapperPass::dump() const { print(dbgs(), nullptr); }
#endif
namespace { namespace {
struct CallGraphPrinterLegacyPass : public ModulePass { struct CallGraphPrinterLegacyPass : public ModulePass {

View File

@ -385,9 +385,9 @@ void DependenceInfo::Constraint::setAny(ScalarEvolution *NewSE) {
Kind = Any; Kind = Any;
} }
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
// For debugging purposes. Dumps the constraint out to OS. // For debugging purposes. Dumps the constraint out to OS.
void DependenceInfo::Constraint::dump(raw_ostream &OS) const { LLVM_DUMP_METHOD void DependenceInfo::Constraint::dump(raw_ostream &OS) const {
if (isEmpty()) if (isEmpty())
OS << " Empty\n"; OS << " Empty\n";
else if (isAny()) else if (isAny())
@ -403,6 +403,7 @@ void DependenceInfo::Constraint::dump(raw_ostream &OS) const {
else else
llvm_unreachable("unknown constraint type in Constraint::dump"); llvm_unreachable("unknown constraint type in Constraint::dump");
} }
#endif
// Updates X with the intersection // Updates X with the intersection

View File

@ -108,9 +108,11 @@ void LazyCallGraph::Node::removeEdgeInternal(Function &Target) {
EdgeIndexMap.erase(IndexMapI); EdgeIndexMap.erase(IndexMapI);
} }
void LazyCallGraph::Node::dump() const { #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
LLVM_DUMP_METHOD void LazyCallGraph::Node::dump() const {
dbgs() << *this << '\n'; dbgs() << *this << '\n';
} }
#endif
LazyCallGraph::LazyCallGraph(Module &M) : NextDFSNumber(0) { LazyCallGraph::LazyCallGraph(Module &M) : NextDFSNumber(0) {
DEBUG(dbgs() << "Building CG for module: " << M.getModuleIdentifier() DEBUG(dbgs() << "Building CG for module: " << M.getModuleIdentifier()
@ -167,9 +169,11 @@ LazyCallGraph &LazyCallGraph::operator=(LazyCallGraph &&G) {
return *this; return *this;
} }
void LazyCallGraph::SCC::dump() const { #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
LLVM_DUMP_METHOD void LazyCallGraph::SCC::dump() const {
dbgs() << *this << '\n'; dbgs() << *this << '\n';
} }
#endif
#ifndef NDEBUG #ifndef NDEBUG
void LazyCallGraph::SCC::verify() { void LazyCallGraph::SCC::verify() {
@ -243,9 +247,11 @@ bool LazyCallGraph::SCC::isAncestorOf(const SCC &TargetC) const {
LazyCallGraph::RefSCC::RefSCC(LazyCallGraph &G) : G(&G) {} LazyCallGraph::RefSCC::RefSCC(LazyCallGraph &G) : G(&G) {}
void LazyCallGraph::RefSCC::dump() const { #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
LLVM_DUMP_METHOD void LazyCallGraph::RefSCC::dump() const {
dbgs() << *this << '\n'; dbgs() << *this << '\n';
} }
#endif
#ifndef NDEBUG #ifndef NDEBUG
void LazyCallGraph::RefSCC::verify() { void LazyCallGraph::RefSCC::verify() {

View File

@ -149,11 +149,12 @@ static cl::opt<unsigned> MaxConstantEvolvingDepth(
// Implementation of the SCEV class. // Implementation of the SCEV class.
// //
LLVM_DUMP_METHOD #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
void SCEV::dump() const { LLVM_DUMP_METHOD void SCEV::dump() const {
print(dbgs()); print(dbgs());
dbgs() << '\n'; dbgs() << '\n';
} }
#endif
void SCEV::print(raw_ostream &OS) const { void SCEV::print(raw_ostream &OS) const {
switch (static_cast<SCEVTypes>(getSCEVType())) { switch (static_cast<SCEVTypes>(getSCEVType())) {

View File

@ -432,12 +432,14 @@ unsigned ValueEnumerator::getValueID(const Value *V) const {
return I->second-1; return I->second-1;
} }
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
LLVM_DUMP_METHOD void ValueEnumerator::dump() const { LLVM_DUMP_METHOD void ValueEnumerator::dump() const {
print(dbgs(), ValueMap, "Default"); print(dbgs(), ValueMap, "Default");
dbgs() << '\n'; dbgs() << '\n';
print(dbgs(), MetadataMap, "MetaData"); print(dbgs(), MetadataMap, "MetaData");
dbgs() << '\n'; dbgs() << '\n';
} }
#endif
void ValueEnumerator::print(raw_ostream &OS, const ValueMapType &Map, void ValueEnumerator::print(raw_ostream &OS, const ValueMapType &Map,
const char *Name) const { const char *Name) const {
@ -452,7 +454,8 @@ void ValueEnumerator::print(raw_ostream &OS, const ValueMapType &Map,
OS << "Value: " << V->getName(); OS << "Value: " << V->getName();
else else
OS << "Value: [null]\n"; OS << "Value: [null]\n";
V->dump(); V->print(errs());
errs() << '\n';
OS << " Uses(" << std::distance(V->use_begin(),V->use_end()) << "):"; OS << " Uses(" << std::distance(V->use_begin(),V->use_end()) << "):";
for (const Use &U : V->uses()) { for (const Use &U : V->uses()) {

View File

@ -112,8 +112,11 @@ void DIEAbbrev::print(raw_ostream &O) {
} }
} }
LLVM_DUMP_METHOD #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
void DIEAbbrev::dump() { print(dbgs()); } LLVM_DUMP_METHOD void DIEAbbrev::dump() {
print(dbgs());
}
#endif
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// DIEAbbrevSet Implementation // DIEAbbrevSet Implementation
@ -249,10 +252,11 @@ void DIE::print(raw_ostream &O, unsigned IndentCount) const {
O << "\n"; O << "\n";
} }
LLVM_DUMP_METHOD #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
void DIE::dump() { LLVM_DUMP_METHOD void DIE::dump() {
print(dbgs()); print(dbgs());
} }
#endif
unsigned DIE::computeOffsetsAndAbbrevs(const AsmPrinter *AP, unsigned DIE::computeOffsetsAndAbbrevs(const AsmPrinter *AP,
DIEAbbrevSet &AbbrevSet, DIEAbbrevSet &AbbrevSet,
@ -340,10 +344,11 @@ void DIEValue::print(raw_ostream &O) const {
} }
} }
LLVM_DUMP_METHOD #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
void DIEValue::dump() const { LLVM_DUMP_METHOD void DIEValue::dump() const {
print(dbgs()); print(dbgs());
} }
#endif
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// DIEInteger Implementation // DIEInteger Implementation

View File

@ -126,14 +126,16 @@ void BranchRelaxation::verify() {
#endif #endif
} }
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
/// print block size and offset information - debugging /// print block size and offset information - debugging
void BranchRelaxation::dumpBBs() { LLVM_DUMP_METHOD void BranchRelaxation::dumpBBs() {
for (auto &MBB : *MF) { for (auto &MBB : *MF) {
const BasicBlockInfo &BBI = BlockInfo[MBB.getNumber()]; const BasicBlockInfo &BBI = BlockInfo[MBB.getNumber()];
dbgs() << format("BB#%u\toffset=%08x\t", MBB.getNumber(), BBI.Offset) dbgs() << format("BB#%u\toffset=%08x\t", MBB.getNumber(), BBI.Offset)
<< format("size=%#x\n", BBI.Size); << format("size=%#x\n", BBI.Size);
} }
} }
#endif
/// scanFunction - Do the initial scan of the function, building up /// scanFunction - Do the initial scan of the function, building up
/// information about each block. /// information about each block.

View File

@ -968,10 +968,12 @@ bool RegBankSelect::MappingCost::operator==(const MappingCost &Cost) const {
LocalFreq == Cost.LocalFreq; LocalFreq == Cost.LocalFreq;
} }
void RegBankSelect::MappingCost::dump() const { #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
LLVM_DUMP_METHOD void RegBankSelect::MappingCost::dump() const {
print(dbgs()); print(dbgs());
dbgs() << '\n'; dbgs() << '\n';
} }
#endif
void RegBankSelect::MappingCost::print(raw_ostream &OS) const { void RegBankSelect::MappingCost::print(raw_ostream &OS) const {
if (*this == ImpossibleCost()) { if (*this == ImpossibleCost()) {

View File

@ -76,9 +76,11 @@ bool RegisterBank::operator==(const RegisterBank &OtherRB) const {
return &OtherRB == this; return &OtherRB == this;
} }
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
LLVM_DUMP_METHOD void RegisterBank::dump(const TargetRegisterInfo *TRI) const { LLVM_DUMP_METHOD void RegisterBank::dump(const TargetRegisterInfo *TRI) const {
print(dbgs(), /* IsForDebug */ true, TRI); print(dbgs(), /* IsForDebug */ true, TRI);
} }
#endif
void RegisterBank::print(raw_ostream &OS, bool IsForDebug, void RegisterBank::print(raw_ostream &OS, bool IsForDebug,
const TargetRegisterInfo *TRI) const { const TargetRegisterInfo *TRI) const {

View File

@ -402,10 +402,12 @@ unsigned RegisterBankInfo::getSizeInBits(unsigned Reg,
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// Helper classes implementation. // Helper classes implementation.
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
LLVM_DUMP_METHOD void RegisterBankInfo::PartialMapping::dump() const { LLVM_DUMP_METHOD void RegisterBankInfo::PartialMapping::dump() const {
print(dbgs()); print(dbgs());
dbgs() << '\n'; dbgs() << '\n';
} }
#endif
bool RegisterBankInfo::PartialMapping::verify() const { bool RegisterBankInfo::PartialMapping::verify() const {
assert(RegBank && "Register bank not set"); assert(RegBank && "Register bank not set");
@ -453,10 +455,12 @@ bool RegisterBankInfo::ValueMapping::verify(unsigned MeaningfulBitWidth) const {
return true; return true;
} }
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
LLVM_DUMP_METHOD void RegisterBankInfo::ValueMapping::dump() const { LLVM_DUMP_METHOD void RegisterBankInfo::ValueMapping::dump() const {
print(dbgs()); print(dbgs());
dbgs() << '\n'; dbgs() << '\n';
} }
#endif
void RegisterBankInfo::ValueMapping::print(raw_ostream &OS) const { void RegisterBankInfo::ValueMapping::print(raw_ostream &OS) const {
OS << "#BreakDown: " << NumBreakDowns << " "; OS << "#BreakDown: " << NumBreakDowns << " ";
@ -505,10 +509,12 @@ bool RegisterBankInfo::InstructionMapping::verify(
return true; return true;
} }
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
LLVM_DUMP_METHOD void RegisterBankInfo::InstructionMapping::dump() const { LLVM_DUMP_METHOD void RegisterBankInfo::InstructionMapping::dump() const {
print(dbgs()); print(dbgs());
dbgs() << '\n'; dbgs() << '\n';
} }
#endif
void RegisterBankInfo::InstructionMapping::print(raw_ostream &OS) const { void RegisterBankInfo::InstructionMapping::print(raw_ostream &OS) const {
OS << "ID: " << getID() << " Cost: " << getCost() << " Mapping: "; OS << "ID: " << getID() << " Cost: " << getCost() << " Mapping: ";
@ -621,10 +627,12 @@ RegisterBankInfo::OperandsMapper::getVRegs(unsigned OpIdx,
return Res; return Res;
} }
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
LLVM_DUMP_METHOD void RegisterBankInfo::OperandsMapper::dump() const { LLVM_DUMP_METHOD void RegisterBankInfo::OperandsMapper::dump() const {
print(dbgs(), true); print(dbgs(), true);
dbgs() << '\n'; dbgs() << '\n';
} }
#endif
void RegisterBankInfo::OperandsMapper::print(raw_ostream &OS, void RegisterBankInfo::OperandsMapper::print(raw_ostream &OS,
bool ForDebug) const { bool ForDebug) const {

View File

@ -299,9 +299,8 @@ bool LexicalScopes::dominates(const DILocation *DL, MachineBasicBlock *MBB) {
return Result; return Result;
} }
/// dump - Print data structures. #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
void LexicalScope::dump(unsigned Indent) const { LLVM_DUMP_METHOD void LexicalScope::dump(unsigned Indent) const {
#ifndef NDEBUG
raw_ostream &err = dbgs(); raw_ostream &err = dbgs();
err.indent(Indent); err.indent(Indent);
err << "DFSIn: " << DFSIn << " DFSOut: " << DFSOut << "\n"; err << "DFSIn: " << DFSIn << " DFSOut: " << DFSOut << "\n";
@ -316,5 +315,5 @@ void LexicalScope::dump(unsigned Indent) const {
for (unsigned i = 0, e = Children.size(); i != e; ++i) for (unsigned i = 0, e = Children.size(); i != e; ++i)
if (Children[i] != this) if (Children[i] != this)
Children[i]->dump(Indent + 2); Children[i]->dump(Indent + 2);
#endif
} }
#endif

View File

@ -1005,7 +1005,7 @@ bool LiveDebugVariables::doInitialization(Module &M) {
return Pass::doInitialization(M); return Pass::doInitialization(M);
} }
#ifndef NDEBUG #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
LLVM_DUMP_METHOD void LiveDebugVariables::dump() { LLVM_DUMP_METHOD void LiveDebugVariables::dump() {
if (pImpl) if (pImpl)
static_cast<LDVImpl*>(pImpl)->print(dbgs()); static_cast<LDVImpl*>(pImpl)->print(dbgs());

View File

@ -1032,6 +1032,7 @@ void LiveInterval::verify(const MachineRegisterInfo *MRI) const {
// When they exist, Spills.back().start <= LastStart, // When they exist, Spills.back().start <= LastStart,
// and WriteI[-1].start <= LastStart. // and WriteI[-1].start <= LastStart.
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
void LiveRangeUpdater::print(raw_ostream &OS) const { void LiveRangeUpdater::print(raw_ostream &OS) const {
if (!isDirty()) { if (!isDirty()) {
if (LR) if (LR)
@ -1058,6 +1059,7 @@ void LiveRangeUpdater::print(raw_ostream &OS) const {
LLVM_DUMP_METHOD void LiveRangeUpdater::dump() const { LLVM_DUMP_METHOD void LiveRangeUpdater::dump() const {
print(errs()); print(errs());
} }
#endif
// Determine if A and B should be coalesced. // Determine if A and B should be coalesced.
static inline bool coalescable(const LiveRange::Segment &A, static inline bool coalescable(const LiveRange::Segment &A,

View File

@ -162,7 +162,7 @@ void LiveIntervals::printInstrs(raw_ostream &OS) const {
} }
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
void LiveIntervals::dumpInstrs() const { LLVM_DUMP_METHOD void LiveIntervals::dumpInstrs() const {
printInstrs(dbgs()); printInstrs(dbgs());
} }
#endif #endif

View File

@ -120,12 +120,11 @@ void LivePhysRegs::print(raw_ostream &OS) const {
OS << "\n"; OS << "\n";
} }
/// Dumps the currently live registers to the debug output.
LLVM_DUMP_METHOD void LivePhysRegs::dump() const {
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
LLVM_DUMP_METHOD void LivePhysRegs::dump() const {
dbgs() << " " << *this; dbgs() << " " << *this;
#endif
} }
#endif
bool LivePhysRegs::available(const MachineRegisterInfo &MRI, bool LivePhysRegs::available(const MachineRegisterInfo &MRI,
unsigned Reg) const { unsigned Reg) const {

View File

@ -64,8 +64,8 @@ LiveVariables::VarInfo::findKill(const MachineBasicBlock *MBB) const {
return nullptr; return nullptr;
} }
LLVM_DUMP_METHOD void LiveVariables::VarInfo::dump() const {
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
LLVM_DUMP_METHOD void LiveVariables::VarInfo::dump() const {
dbgs() << " Alive in blocks: "; dbgs() << " Alive in blocks: ";
for (SparseBitVector<>::iterator I = AliveBlocks.begin(), for (SparseBitVector<>::iterator I = AliveBlocks.begin(),
E = AliveBlocks.end(); I != E; ++I) E = AliveBlocks.end(); I != E; ++I)
@ -78,8 +78,8 @@ LLVM_DUMP_METHOD void LiveVariables::VarInfo::dump() const {
dbgs() << "\n #" << i << ": " << *Kills[i]; dbgs() << "\n #" << i << ": " << *Kills[i];
dbgs() << "\n"; dbgs() << "\n";
} }
#endif
} }
#endif
/// getVarInfo - Get (possibly creating) a VarInfo object for the given vreg. /// getVarInfo - Get (possibly creating) a VarInfo object for the given vreg.
LiveVariables::VarInfo &LiveVariables::getVarInfo(unsigned RegIdx) { LiveVariables::VarInfo &LiveVariables::getVarInfo(unsigned RegIdx) {

View File

@ -956,7 +956,7 @@ void MachineFrameInfo::print(const MachineFunction &MF, raw_ostream &OS) const{
} }
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
void MachineFrameInfo::dump(const MachineFunction &MF) const { LLVM_DUMP_METHOD void MachineFrameInfo::dump(const MachineFunction &MF) const {
print(MF, dbgs()); print(MF, dbgs());
} }
#endif #endif

View File

@ -1692,12 +1692,12 @@ void MachineInstr::copyImplicitOps(MachineFunction &MF,
} }
} }
LLVM_DUMP_METHOD void MachineInstr::dump(const TargetInstrInfo *TII) const {
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
LLVM_DUMP_METHOD void MachineInstr::dump(const TargetInstrInfo *TII) const {
dbgs() << " "; dbgs() << " ";
print(dbgs(), false /* SkipOpers */, TII); print(dbgs(), false /* SkipOpers */, TII);
#endif
} }
#endif
void MachineInstr::print(raw_ostream &OS, bool SkipOpers, void MachineInstr::print(raw_ostream &OS, bool SkipOpers,
const TargetInstrInfo *TII) const { const TargetInstrInfo *TII) const {

View File

@ -552,7 +552,9 @@ public:
os << "\n"; os << "\n";
} }
void dump() const { print(dbgs()); } #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
LLVM_DUMP_METHOD void dump() const { print(dbgs()); }
#endif
}; };
/// This class repesents the scheduled code. The main data structure is a /// This class repesents the scheduled code. The main data structure is a
@ -3980,5 +3982,7 @@ void SMSchedule::print(raw_ostream &os) const {
} }
} }
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
/// Utility function used for debugging to print the schedule. /// Utility function used for debugging to print the schedule.
void SMSchedule::dump() const { print(dbgs()); } LLVM_DUMP_METHOD void SMSchedule::dump() const { print(dbgs()); }
#endif

View File

@ -444,8 +444,8 @@ LaneBitmask MachineRegisterInfo::getMaxLaneMaskForVReg(unsigned Reg) const {
return TRC.getLaneMask(); return TRC.getLaneMask();
} }
#ifndef NDEBUG #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
void MachineRegisterInfo::dumpUses(unsigned Reg) const { LLVM_DUMP_METHOD void MachineRegisterInfo::dumpUses(unsigned Reg) const {
for (MachineInstr &I : use_instructions(Reg)) for (MachineInstr &I : use_instructions(Reg))
I.dump(); I.dump();
} }

View File

@ -504,13 +504,14 @@ void MachineSchedulerBase::print(raw_ostream &O, const Module* m) const {
// unimplemented // unimplemented
} }
LLVM_DUMP_METHOD #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
void ReadyQueue::dump() { LLVM_DUMP_METHOD void ReadyQueue::dump() {
dbgs() << "Queue " << Name << ": "; dbgs() << "Queue " << Name << ": ";
for (unsigned i = 0, e = Queue.size(); i < e; ++i) for (unsigned i = 0, e = Queue.size(); i < e; ++i)
dbgs() << Queue[i]->NodeNum << " "; dbgs() << Queue[i]->NodeNum << " ";
dbgs() << "\n"; dbgs() << "\n";
} }
#endif
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// ScheduleDAGMI - Basic machine instruction scheduling. This is // ScheduleDAGMI - Basic machine instruction scheduling. This is
@ -841,7 +842,7 @@ void ScheduleDAGMI::placeDebugValues() {
} }
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
void ScheduleDAGMI::dumpSchedule() const { LLVM_DUMP_METHOD void ScheduleDAGMI::dumpSchedule() const {
for (MachineBasicBlock::iterator MI = begin(), ME = end(); MI != ME; ++MI) { for (MachineBasicBlock::iterator MI = begin(), ME = end(); MI != ME; ++MI) {
if (SUnit *SU = getSUnit(&(*MI))) if (SUnit *SU = getSUnit(&(*MI)))
SU->dump(this); SU->dump(this);
@ -2323,10 +2324,10 @@ SUnit *SchedBoundary::pickOnlyChoice() {
return nullptr; return nullptr;
} }
#ifndef NDEBUG #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
// This is useful information to dump after bumpNode. // This is useful information to dump after bumpNode.
// Note that the Queue contents are more useful before pickNodeFromQueue. // Note that the Queue contents are more useful before pickNodeFromQueue.
void SchedBoundary::dumpScheduledState() { LLVM_DUMP_METHOD void SchedBoundary::dumpScheduledState() {
unsigned ResFactor; unsigned ResFactor;
unsigned ResCount; unsigned ResCount;
if (ZoneCritResIdx) { if (ZoneCritResIdx) {
@ -2666,11 +2667,14 @@ void GenericScheduler::initPolicy(MachineBasicBlock::iterator Begin,
} }
void GenericScheduler::dumpPolicy() { void GenericScheduler::dumpPolicy() {
// Cannot completely remove virtual function even in release mode.
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
dbgs() << "GenericScheduler RegionPolicy: " dbgs() << "GenericScheduler RegionPolicy: "
<< " ShouldTrackPressure=" << RegionPolicy.ShouldTrackPressure << " ShouldTrackPressure=" << RegionPolicy.ShouldTrackPressure
<< " OnlyTopDown=" << RegionPolicy.OnlyTopDown << " OnlyTopDown=" << RegionPolicy.OnlyTopDown
<< " OnlyBottomUp=" << RegionPolicy.OnlyBottomUp << " OnlyBottomUp=" << RegionPolicy.OnlyBottomUp
<< "\n"; << "\n";
#endif
} }
/// Set IsAcyclicLatencyLimited if the acyclic path is longer than the cyclic /// Set IsAcyclicLatencyLimited if the acyclic path is longer than the cyclic

View File

@ -253,7 +253,7 @@ void SchedulePostRATDList::exitRegion() {
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
/// dumpSchedule - dump the scheduled Sequence. /// dumpSchedule - dump the scheduled Sequence.
void SchedulePostRATDList::dumpSchedule() const { LLVM_DUMP_METHOD void SchedulePostRATDList::dumpSchedule() const {
for (unsigned i = 0, e = Sequence.size(); i != e; i++) { for (unsigned i = 0, e = Sequence.size(); i != e; i++) {
if (SUnit *SU = Sequence[i]) if (SUnit *SU = Sequence[i])
SU->dump(this); SU->dump(this);

View File

@ -840,7 +840,8 @@ static Printable PrintNodeInfo(PBQP::RegAlloc::PBQPRAGraph::NodeId NId,
}); });
} }
void PBQP::RegAlloc::PBQPRAGraph::dump(raw_ostream &OS) const { #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
LLVM_DUMP_METHOD void PBQP::RegAlloc::PBQPRAGraph::dump(raw_ostream &OS) const {
for (auto NId : nodeIds()) { for (auto NId : nodeIds()) {
const Vector &Costs = getNodeCosts(NId); const Vector &Costs = getNodeCosts(NId);
assert(Costs.getLength() != 0 && "Empty vector in graph."); assert(Costs.getLength() != 0 && "Empty vector in graph.");
@ -861,7 +862,10 @@ void PBQP::RegAlloc::PBQPRAGraph::dump(raw_ostream &OS) const {
} }
} }
LLVM_DUMP_METHOD void PBQP::RegAlloc::PBQPRAGraph::dump() const { dump(dbgs()); } LLVM_DUMP_METHOD void PBQP::RegAlloc::PBQPRAGraph::dump() const {
dump(dbgs());
}
#endif
void PBQP::RegAlloc::PBQPRAGraph::printDot(raw_ostream &OS) const { void PBQP::RegAlloc::PBQPRAGraph::printDot(raw_ostream &OS) const {
OS << "graph {\n"; OS << "graph {\n";

View File

@ -52,6 +52,7 @@ static void decreaseSetPressure(std::vector<unsigned> &CurrSetPressure,
} }
} }
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
LLVM_DUMP_METHOD LLVM_DUMP_METHOD
void llvm::dumpRegSetPressure(ArrayRef<unsigned> SetPressure, void llvm::dumpRegSetPressure(ArrayRef<unsigned> SetPressure,
const TargetRegisterInfo *TRI) { const TargetRegisterInfo *TRI) {
@ -97,6 +98,7 @@ void RegPressureTracker::dump() const {
P.dump(TRI); P.dump(TRI);
} }
LLVM_DUMP_METHOD
void PressureDiff::dump(const TargetRegisterInfo &TRI) const { void PressureDiff::dump(const TargetRegisterInfo &TRI) const {
const char *sep = ""; const char *sep = "";
for (const PressureChange &Change : *this) { for (const PressureChange &Change : *this) {
@ -108,6 +110,7 @@ void PressureDiff::dump(const TargetRegisterInfo &TRI) const {
} }
dbgs() << '\n'; dbgs() << '\n';
} }
#endif
void RegPressureTracker::increaseRegPressure(unsigned RegUnit, void RegPressureTracker::increaseRegPressure(unsigned RegUnit,
LaneBitmask PreviousMask, LaneBitmask PreviousMask,

View File

@ -236,6 +236,7 @@ void StackColoring::calculateLiveIntervals() {
} }
} }
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
LLVM_DUMP_METHOD void StackColoring::dumpAllocas() { LLVM_DUMP_METHOD void StackColoring::dumpAllocas() {
dbgs() << "Allocas:\n"; dbgs() << "Allocas:\n";
for (unsigned AllocaNo = 0; AllocaNo < NumAllocas; ++AllocaNo) for (unsigned AllocaNo = 0; AllocaNo < NumAllocas; ++AllocaNo)
@ -262,6 +263,7 @@ LLVM_DUMP_METHOD void StackColoring::dumpLiveRanges() {
dbgs() << " " << AllocaNo << ": " << Range << "\n"; dbgs() << " " << AllocaNo << ": " << Range << "\n";
} }
} }
#endif
void StackColoring::run() { void StackColoring::run() {
DEBUG(dumpAllocas()); DEBUG(dumpAllocas());

View File

@ -310,6 +310,7 @@ void SUnit::biasCriticalPath() {
} }
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
LLVM_DUMP_METHOD
void SUnit::print(raw_ostream &OS, const ScheduleDAG *DAG) const { void SUnit::print(raw_ostream &OS, const ScheduleDAG *DAG) const {
if (this == &DAG->ExitSU) if (this == &DAG->ExitSU)
OS << "ExitSU"; OS << "ExitSU";
@ -321,13 +322,13 @@ void SUnit::print(raw_ostream &OS, const ScheduleDAG *DAG) const {
/// SUnit - Scheduling unit. It's an wrapper around either a single SDNode or /// SUnit - Scheduling unit. It's an wrapper around either a single SDNode or
/// a group of nodes flagged together. /// a group of nodes flagged together.
void SUnit::dump(const ScheduleDAG *G) const { LLVM_DUMP_METHOD void SUnit::dump(const ScheduleDAG *G) const {
print(dbgs(), G); print(dbgs(), G);
dbgs() << ": "; dbgs() << ": ";
G->dumpNode(this); G->dumpNode(this);
} }
void SUnit::dumpAll(const ScheduleDAG *G) const { LLVM_DUMP_METHOD void SUnit::dumpAll(const ScheduleDAG *G) const {
dump(G); dump(G);
dbgs() << " # preds left : " << NumPredsLeft << "\n"; dbgs() << " # preds left : " << NumPredsLeft << "\n";

View File

@ -1297,6 +1297,7 @@ void ScheduleDAGInstrs::fixupKills(MachineBasicBlock *MBB) {
} }
void ScheduleDAGInstrs::dumpNode(const SUnit *SU) const { void ScheduleDAGInstrs::dumpNode(const SUnit *SU) const {
// Cannot completely remove virtual function even in release mode.
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
SU->getInstr()->dump(); SU->getInstr()->dump();
#endif #endif
@ -1604,8 +1605,8 @@ void SchedDFSResult::scheduleTree(unsigned SubtreeID) {
} }
} }
LLVM_DUMP_METHOD #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
void ILPValue::print(raw_ostream &OS) const { LLVM_DUMP_METHOD void ILPValue::print(raw_ostream &OS) const {
OS << InstrCount << " / " << Length << " = "; OS << InstrCount << " / " << Length << " = ";
if (!Length) if (!Length)
OS << "BADILP"; OS << "BADILP";
@ -1613,8 +1614,7 @@ void ILPValue::print(raw_ostream &OS) const {
OS << format("%g", ((double)InstrCount / Length)); OS << format("%g", ((double)InstrCount / Length));
} }
LLVM_DUMP_METHOD LLVM_DUMP_METHOD void ILPValue::dump() const {
void ILPValue::dump() const {
dbgs() << *this << '\n'; dbgs() << *this << '\n';
} }
@ -1627,3 +1627,4 @@ raw_ostream &operator<<(raw_ostream &OS, const ILPValue &Val) {
} }
} // end namespace llvm } // end namespace llvm
#endif

View File

@ -1787,7 +1787,7 @@ public:
} }
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
void dump(ScheduleDAG *DAG) const override { LLVM_DUMP_METHOD void dump(ScheduleDAG *DAG) const override {
// Emulate pop() without clobbering NodeQueueIds. // Emulate pop() without clobbering NodeQueueIds.
std::vector<SUnit*> DumpQueue = Queue; std::vector<SUnit*> DumpQueue = Queue;
SF DumpPicker = Picker; SF DumpPicker = Picker;
@ -1923,8 +1923,8 @@ unsigned RegReductionPQBase::getNodePriority(const SUnit *SU) const {
// Register Pressure Tracking // Register Pressure Tracking
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
void RegReductionPQBase::dumpRegPressure() const {
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
LLVM_DUMP_METHOD void RegReductionPQBase::dumpRegPressure() const {
for (const TargetRegisterClass *RC : TRI->regclasses()) { for (const TargetRegisterClass *RC : TRI->regclasses()) {
unsigned Id = RC->getID(); unsigned Id = RC->getID();
unsigned RP = RegPressure[Id]; unsigned RP = RegPressure[Id];
@ -1932,8 +1932,8 @@ void RegReductionPQBase::dumpRegPressure() const {
DEBUG(dbgs() << TRI->getRegClassName(RC) << ": " << RP << " / " DEBUG(dbgs() << TRI->getRegClassName(RC) << ": " << RP << " / "
<< RegLimit[Id] << '\n'); << RegLimit[Id] << '\n');
} }
#endif
} }
#endif
bool RegReductionPQBase::HighRegPressure(const SUnit *SU) const { bool RegReductionPQBase::HighRegPressure(const SUnit *SU) const {
if (!TLI) if (!TLI)
@ -2089,7 +2089,7 @@ void RegReductionPQBase::scheduledNode(SUnit *SU) {
RegPressure[RCId] -= Cost; RegPressure[RCId] -= Cost;
} }
} }
dumpRegPressure(); DEBUG(dumpRegPressure());
} }
void RegReductionPQBase::unscheduledNode(SUnit *SU) { void RegReductionPQBase::unscheduledNode(SUnit *SU) {
@ -2169,7 +2169,7 @@ void RegReductionPQBase::unscheduledNode(SUnit *SU) {
} }
} }
dumpRegPressure(); DEBUG(dumpRegPressure());
} }
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//

View File

@ -650,6 +650,7 @@ void ScheduleDAGSDNodes::computeOperandLatency(SDNode *Def, SDNode *Use,
} }
void ScheduleDAGSDNodes::dumpNode(const SUnit *SU) const { void ScheduleDAGSDNodes::dumpNode(const SUnit *SU) const {
// Cannot completely remove virtual function even in release mode.
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
if (!SU->getNode()) { if (!SU->getNode()) {
dbgs() << "PHYS REG COPY\n"; dbgs() << "PHYS REG COPY\n";

View File

@ -366,11 +366,13 @@ static Printable PrintNodeId(const SDNode &Node) {
}); });
} }
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
LLVM_DUMP_METHOD void SDNode::dump() const { dump(nullptr); } LLVM_DUMP_METHOD void SDNode::dump() const { dump(nullptr); }
void SDNode::dump(const SelectionDAG *G) const { LLVM_DUMP_METHOD void SDNode::dump(const SelectionDAG *G) const {
print(dbgs(), G); print(dbgs(), G);
dbgs() << '\n'; dbgs() << '\n';
} }
#endif
void SDNode::print_types(raw_ostream &OS, const SelectionDAG *G) const { void SDNode::print_types(raw_ostream &OS, const SelectionDAG *G) const {
for (unsigned i = 0, e = getNumValues(); i != e; ++i) { for (unsigned i = 0, e = getNumValues(); i != e; ++i) {
@ -416,7 +418,7 @@ void SDNode::print_details(raw_ostream &OS, const SelectionDAG *G) const {
OS << '<' << CSDN->getValueAPF().convertToDouble() << '>'; OS << '<' << CSDN->getValueAPF().convertToDouble() << '>';
else { else {
OS << "<APFloat("; OS << "<APFloat(";
CSDN->getValueAPF().bitcastToAPInt().dump(); CSDN->getValueAPF().bitcastToAPInt().print(OS, false);
OS << ")>"; OS << ")>";
} }
} else if (const GlobalAddressSDNode *GADN = } else if (const GlobalAddressSDNode *GADN =
@ -566,6 +568,7 @@ static bool shouldPrintInline(const SDNode &Node) {
return Node.getNumOperands() == 0; return Node.getNumOperands() == 0;
} }
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
static void DumpNodes(const SDNode *N, unsigned indent, const SelectionDAG *G) { static void DumpNodes(const SDNode *N, unsigned indent, const SelectionDAG *G) {
for (const SDValue &Op : N->op_values()) { for (const SDValue &Op : N->op_values()) {
if (shouldPrintInline(*Op.getNode())) if (shouldPrintInline(*Op.getNode()))
@ -592,6 +595,7 @@ LLVM_DUMP_METHOD void SelectionDAG::dump() const {
if (getRoot().getNode()) DumpNodes(getRoot().getNode(), 2, this); if (getRoot().getNode()) DumpNodes(getRoot().getNode(), 2, this);
dbgs() << "\n\n"; dbgs() << "\n\n";
} }
#endif
void SDNode::printr(raw_ostream &OS, const SelectionDAG *G) const { void SDNode::printr(raw_ostream &OS, const SelectionDAG *G) const {
OS << PrintNodeId(*this) << ": "; OS << PrintNodeId(*this) << ": ";
@ -618,6 +622,7 @@ static bool printOperand(raw_ostream &OS, const SelectionDAG *G,
} }
} }
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
typedef SmallPtrSet<const SDNode *, 32> VisitedSDNodeSet; typedef SmallPtrSet<const SDNode *, 32> VisitedSDNodeSet;
static void DumpNodesr(raw_ostream &OS, const SDNode *N, unsigned indent, static void DumpNodesr(raw_ostream &OS, const SDNode *N, unsigned indent,
const SelectionDAG *G, VisitedSDNodeSet &once) { const SelectionDAG *G, VisitedSDNodeSet &once) {
@ -646,15 +651,16 @@ static void DumpNodesr(raw_ostream &OS, const SDNode *N, unsigned indent,
DumpNodesr(OS, Op.getNode(), indent+2, G, once); DumpNodesr(OS, Op.getNode(), indent+2, G, once);
} }
void SDNode::dumpr() const { LLVM_DUMP_METHOD void SDNode::dumpr() const {
VisitedSDNodeSet once; VisitedSDNodeSet once;
DumpNodesr(dbgs(), this, 0, nullptr, once); DumpNodesr(dbgs(), this, 0, nullptr, once);
} }
void SDNode::dumpr(const SelectionDAG *G) const { LLVM_DUMP_METHOD void SDNode::dumpr(const SelectionDAG *G) const {
VisitedSDNodeSet once; VisitedSDNodeSet once;
DumpNodesr(dbgs(), this, 0, G, once); DumpNodesr(dbgs(), this, 0, G, once);
} }
#endif
static void printrWithDepthHelper(raw_ostream &OS, const SDNode *N, static void printrWithDepthHelper(raw_ostream &OS, const SDNode *N,
const SelectionDAG *G, unsigned depth, const SelectionDAG *G, unsigned depth,
@ -688,14 +694,17 @@ void SDNode::printrFull(raw_ostream &OS, const SelectionDAG *G) const {
printrWithDepth(OS, G, 10); printrWithDepth(OS, G, 10);
} }
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
LLVM_DUMP_METHOD
void SDNode::dumprWithDepth(const SelectionDAG *G, unsigned depth) const { void SDNode::dumprWithDepth(const SelectionDAG *G, unsigned depth) const {
printrWithDepth(dbgs(), G, depth); printrWithDepth(dbgs(), G, depth);
} }
void SDNode::dumprFull(const SelectionDAG *G) const { LLVM_DUMP_METHOD void SDNode::dumprFull(const SelectionDAG *G) const {
// Don't print impossibly deep things. // Don't print impossibly deep things.
dumprWithDepth(G, 10); dumprWithDepth(G, 10);
} }
#endif
void SDNode::print(raw_ostream &OS, const SelectionDAG *G) const { void SDNode::print(raw_ostream &OS, const SelectionDAG *G) const {
printr(OS, G); printr(OS, G);

View File

@ -1535,7 +1535,7 @@ void SelectionDAGISel::SelectAllBasicBlocks(const Function &Fn) {
if (EnableFastISelVerbose || EnableFastISelAbort) { if (EnableFastISelVerbose || EnableFastISelAbort) {
dbgs() << "FastISel missed call: "; dbgs() << "FastISel missed call: ";
Inst->dump(); Inst->print(dbgs());
} }
if (EnableFastISelAbort > 2) if (EnableFastISelAbort > 2)
// FastISel selector couldn't handle something and bailed. // FastISel selector couldn't handle something and bailed.
@ -1579,7 +1579,7 @@ void SelectionDAGISel::SelectAllBasicBlocks(const Function &Fn) {
} else { } else {
dbgs() << "FastISel miss: "; dbgs() << "FastISel miss: ";
} }
Inst->dump(); Inst->print(dbgs());
} }
if (ShouldAbort) if (ShouldAbort)
// FastISel selector couldn't handle something and bailed. // FastISel selector couldn't handle something and bailed.

View File

@ -385,14 +385,13 @@ void StackColoring::getAnalysisUsage(AnalysisUsage &AU) const {
MachineFunctionPass::getAnalysisUsage(AU); MachineFunctionPass::getAnalysisUsage(AU);
} }
#ifndef NDEBUG #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
LLVM_DUMP_METHOD void StackColoring::dumpBV(const char *tag, LLVM_DUMP_METHOD void StackColoring::dumpBV(const char *tag,
const BitVector &BV) const { const BitVector &BV) const {
DEBUG(dbgs() << tag << " : { "); dbgs() << tag << " : { ";
for (unsigned I = 0, E = BV.size(); I != E; ++I) for (unsigned I = 0, E = BV.size(); I != E; ++I)
DEBUG(dbgs() << BV.test(I) << " "); dbgs() << BV.test(I) << " ";
DEBUG(dbgs() << "}\n"); dbgs() << "}\n";
} }
LLVM_DUMP_METHOD void StackColoring::dumpBB(MachineBasicBlock *MBB) const { LLVM_DUMP_METHOD void StackColoring::dumpBB(MachineBasicBlock *MBB) const {
@ -408,20 +407,19 @@ LLVM_DUMP_METHOD void StackColoring::dumpBB(MachineBasicBlock *MBB) const {
LLVM_DUMP_METHOD void StackColoring::dump() const { LLVM_DUMP_METHOD void StackColoring::dump() const {
for (MachineBasicBlock *MBB : depth_first(MF)) { for (MachineBasicBlock *MBB : depth_first(MF)) {
DEBUG(dbgs() << "Inspecting block #" << MBB->getNumber() << " [" dbgs() << "Inspecting block #" << MBB->getNumber() << " ["
<< MBB->getName() << "]\n"); << MBB->getName() << "]\n";
DEBUG(dumpBB(MBB)); dumpBB(MBB);
} }
} }
LLVM_DUMP_METHOD void StackColoring::dumpIntervals() const { LLVM_DUMP_METHOD void StackColoring::dumpIntervals() const {
for (unsigned I = 0, E = Intervals.size(); I != E; ++I) { for (unsigned I = 0, E = Intervals.size(); I != E; ++I) {
DEBUG(dbgs() << "Interval[" << I << "]:\n"); dbgs() << "Interval[" << I << "]:\n";
DEBUG(Intervals[I]->dump()); Intervals[I]->dump();
} }
} }
#endif
#endif // not NDEBUG
static inline int getStartOrEndSlot(const MachineInstr &MI) static inline int getStartOrEndSlot(const MachineInstr &MI)
{ {

View File

@ -413,9 +413,9 @@ bool TargetRegisterInfo::regmaskSubsetEqual(const uint32_t *mask0,
} }
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
void LLVM_DUMP_METHOD
TargetRegisterInfo::dumpReg(unsigned Reg, unsigned SubRegIndex, void TargetRegisterInfo::dumpReg(unsigned Reg, unsigned SubRegIndex,
const TargetRegisterInfo *TRI) { const TargetRegisterInfo *TRI) {
dbgs() << PrintReg(Reg, TRI, SubRegIndex) << "\n"; dbgs() << PrintReg(Reg, TRI, SubRegIndex) << "\n";
} }
#endif #endif

View File

@ -46,7 +46,7 @@ bool DWARFAcceleratorTable::extract() {
return true; return true;
} }
void DWARFAcceleratorTable::dump(raw_ostream &OS) const { LLVM_DUMP_METHOD void DWARFAcceleratorTable::dump(raw_ostream &OS) const {
// Dump the header. // Dump the header.
OS << "Magic = " << format("0x%08x", Hdr.Magic) << '\n' OS << "Magic = " << format("0x%08x", Hdr.Magic) << '\n'
<< "Version = " << format("0x%04x", Hdr.Version) << '\n' << "Version = " << format("0x%04x", Hdr.Version) << '\n'

View File

@ -3535,6 +3535,7 @@ void Metadata::print(raw_ostream &OS, ModuleSlotTracker &MST,
printMetadataImpl(OS, *this, MST, M, /* OnlyAsOperand */ false); printMetadataImpl(OS, *this, MST, M, /* OnlyAsOperand */ false);
} }
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
// Value::dump - allow easy printing of Values from the debugger. // Value::dump - allow easy printing of Values from the debugger.
LLVM_DUMP_METHOD LLVM_DUMP_METHOD
void Value::dump() const { print(dbgs(), /*IsForDebug=*/true); dbgs() << '\n'; } void Value::dump() const { print(dbgs(), /*IsForDebug=*/true); dbgs() << '\n'; }
@ -3566,3 +3567,4 @@ void Metadata::dump(const Module *M) const {
print(dbgs(), M, /*IsForDebug=*/true); print(dbgs(), M, /*IsForDebug=*/true);
dbgs() << '\n'; dbgs() << '\n';
} }
#endif

View File

@ -581,9 +581,11 @@ std::string AttributeSetNode::getAsString(bool InAttrGrp) const {
// AttributeSetImpl Definition // AttributeSetImpl Definition
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
LLVM_DUMP_METHOD void AttributeSetImpl::dump() const { LLVM_DUMP_METHOD void AttributeSetImpl::dump() const {
AttributeSet(const_cast<AttributeSetImpl *>(this)).dump(); AttributeSet(const_cast<AttributeSetImpl *>(this)).dump();
} }
#endif
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// AttributeSet Construction and Mutation Methods // AttributeSet Construction and Mutation Methods
@ -1115,6 +1117,7 @@ AttributeSet AttributeSet::getSlotAttributes(unsigned Slot) const {
return pImpl->getSlotAttributes(Slot); return pImpl->getSlotAttributes(Slot);
} }
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
LLVM_DUMP_METHOD void AttributeSet::dump() const { LLVM_DUMP_METHOD void AttributeSet::dump() const {
dbgs() << "PAL[\n"; dbgs() << "PAL[\n";
@ -1130,6 +1133,7 @@ LLVM_DUMP_METHOD void AttributeSet::dump() const {
dbgs() << "]\n"; dbgs() << "]\n";
} }
#endif
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// AttrBuilder Method Implementations // AttrBuilder Method Implementations

View File

@ -996,11 +996,13 @@ void ConstantRange::print(raw_ostream &OS) const {
OS << "[" << Lower << "," << Upper << ")"; OS << "[" << Lower << "," << Upper << ")";
} }
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
/// dump - Allow printing from a debugger easily... /// dump - Allow printing from a debugger easily...
/// ///
LLVM_DUMP_METHOD void ConstantRange::dump() const { LLVM_DUMP_METHOD void ConstantRange::dump() const {
print(dbgs()); print(dbgs());
} }
#endif
ConstantRange llvm::getConstantRangeFromMetadata(const MDNode &Ranges) { ConstantRange llvm::getConstantRangeFromMetadata(const MDNode &Ranges) {
const unsigned NumRanges = Ranges.getNumOperands() / 2; const unsigned NumRanges = Ranges.getNumOperands() / 2;

View File

@ -258,9 +258,11 @@ void LLVMSetTarget(LLVMModuleRef M, const char *Triple) {
unwrap(M)->setTargetTriple(Triple); unwrap(M)->setTargetTriple(Triple);
} }
void LLVMDumpModule(LLVMModuleRef M) { #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
LLVM_DUMP_METHOD void LLVMDumpModule(LLVMModuleRef M) {
unwrap(M)->dump(); unwrap(M)->dump();
} }
#endif
LLVMBool LLVMPrintModuleToFile(LLVMModuleRef M, const char *Filename, LLVMBool LLVMPrintModuleToFile(LLVMModuleRef M, const char *Filename,
char **ErrorMessage) { char **ErrorMessage) {
@ -358,9 +360,11 @@ LLVMContextRef LLVMGetTypeContext(LLVMTypeRef Ty) {
return wrap(&unwrap(Ty)->getContext()); return wrap(&unwrap(Ty)->getContext());
} }
void LLVMDumpType(LLVMTypeRef Ty) { #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
LLVM_DUMP_METHOD void LLVMDumpType(LLVMTypeRef Ty) {
return unwrap(Ty)->dump(); return unwrap(Ty)->dump();
} }
#endif
char *LLVMPrintTypeToString(LLVMTypeRef Ty) { char *LLVMPrintTypeToString(LLVMTypeRef Ty) {
std::string buf; std::string buf;
@ -640,9 +644,11 @@ void LLVMSetValueName(LLVMValueRef Val, const char *Name) {
unwrap(Val)->setName(Name); unwrap(Val)->setName(Name);
} }
void LLVMDumpValue(LLVMValueRef Val) { #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
LLVM_DUMP_METHOD void LLVMDumpValue(LLVMValueRef Val) {
unwrap(Val)->dump(); unwrap(Val)->dump();
} }
#endif
char* LLVMPrintValueToString(LLVMValueRef Val) { char* LLVMPrintValueToString(LLVMValueRef Val) {
std::string buf; std::string buf;

View File

@ -66,8 +66,8 @@ DebugLoc DebugLoc::get(unsigned Line, unsigned Col, const MDNode *Scope,
const_cast<MDNode *>(InlinedAt)); const_cast<MDNode *>(InlinedAt));
} }
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
LLVM_DUMP_METHOD void DebugLoc::dump() const { LLVM_DUMP_METHOD void DebugLoc::dump() const {
#ifndef NDEBUG
if (!Loc) if (!Loc)
return; return;
@ -79,8 +79,8 @@ LLVM_DUMP_METHOD void DebugLoc::dump() const {
InlinedAtDL.dump(); InlinedAtDL.dump();
} else } else
dbgs() << "\n"; dbgs() << "\n";
#endif
} }
#endif
void DebugLoc::print(raw_ostream &OS) const { void DebugLoc::print(raw_ostream &OS) const {
if (!Loc) if (!Loc)

View File

@ -103,11 +103,17 @@ bool GCOVFile::readGCDA(GCOVBuffer &Buffer) {
return true; return true;
} }
void GCOVFile::print(raw_ostream &OS) const {
for (const auto &FPtr : Functions)
FPtr->print(OS);
}
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
/// dump - Dump GCOVFile content to dbgs() for debugging purposes. /// dump - Dump GCOVFile content to dbgs() for debugging purposes.
LLVM_DUMP_METHOD void GCOVFile::dump() const { LLVM_DUMP_METHOD void GCOVFile::dump() const {
for (const auto &FPtr : Functions) print(dbgs());
FPtr->dump();
} }
#endif
/// collectLineCounts - Collect line counts. This must be used after /// collectLineCounts - Collect line counts. This must be used after
/// reading .gcno and .gcda files. /// reading .gcno and .gcda files.
@ -343,13 +349,19 @@ uint64_t GCOVFunction::getExitCount() const {
return Blocks.back()->getCount(); return Blocks.back()->getCount();
} }
void GCOVFunction::print(raw_ostream &OS) const {
OS << "===== " << Name << " (" << Ident << ") @ " << Filename << ":"
<< LineNumber << "\n";
for (const auto &Block : Blocks)
Block->print(OS);
}
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
/// dump - Dump GCOVFunction content to dbgs() for debugging purposes. /// dump - Dump GCOVFunction content to dbgs() for debugging purposes.
LLVM_DUMP_METHOD void GCOVFunction::dump() const { LLVM_DUMP_METHOD void GCOVFunction::dump() const {
dbgs() << "===== " << Name << " (" << Ident << ") @ " << Filename << ":" print(dbgs());
<< LineNumber << "\n";
for (const auto &Block : Blocks)
Block->dump();
} }
#endif
/// collectLineCounts - Collect line counts. This must be used after /// collectLineCounts - Collect line counts. This must be used after
/// reading .gcno and .gcda files. /// reading .gcno and .gcda files.
@ -400,29 +412,35 @@ void GCOVBlock::collectLineCounts(FileInfo &FI) {
FI.addBlockLine(Parent.getFilename(), N, this); FI.addBlockLine(Parent.getFilename(), N, this);
} }
/// dump - Dump GCOVBlock content to dbgs() for debugging purposes. void GCOVBlock::print(raw_ostream &OS) const {
LLVM_DUMP_METHOD void GCOVBlock::dump() const { OS << "Block : " << Number << " Counter : " << Counter << "\n";
dbgs() << "Block : " << Number << " Counter : " << Counter << "\n";
if (!SrcEdges.empty()) { if (!SrcEdges.empty()) {
dbgs() << "\tSource Edges : "; OS << "\tSource Edges : ";
for (const GCOVEdge *Edge : SrcEdges) for (const GCOVEdge *Edge : SrcEdges)
dbgs() << Edge->Src.Number << " (" << Edge->Count << "), "; OS << Edge->Src.Number << " (" << Edge->Count << "), ";
dbgs() << "\n"; OS << "\n";
} }
if (!DstEdges.empty()) { if (!DstEdges.empty()) {
dbgs() << "\tDestination Edges : "; OS << "\tDestination Edges : ";
for (const GCOVEdge *Edge : DstEdges) for (const GCOVEdge *Edge : DstEdges)
dbgs() << Edge->Dst.Number << " (" << Edge->Count << "), "; OS << Edge->Dst.Number << " (" << Edge->Count << "), ";
dbgs() << "\n"; OS << "\n";
} }
if (!Lines.empty()) { if (!Lines.empty()) {
dbgs() << "\tLines : "; OS << "\tLines : ";
for (uint32_t N : Lines) for (uint32_t N : Lines)
dbgs() << (N) << ","; OS << (N) << ",";
dbgs() << "\n"; OS << "\n";
} }
} }
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
/// dump - Dump GCOVBlock content to dbgs() for debugging purposes.
LLVM_DUMP_METHOD void GCOVBlock::dump() const {
print(dbgs());
}
#endif
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// FileInfo implementation. // FileInfo implementation.

View File

@ -118,10 +118,12 @@ void Pass::print(raw_ostream &O,const Module*) const {
O << "Pass::print not implemented for pass: '" << getPassName() << "'!\n"; O << "Pass::print not implemented for pass: '" << getPassName() << "'!\n";
} }
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
// dump - call print(cerr); // dump - call print(cerr);
LLVM_DUMP_METHOD void Pass::dump() const { LLVM_DUMP_METHOD void Pass::dump() const {
print(dbgs(), nullptr); print(dbgs(), nullptr);
} }
#endif
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// ImmutablePass Implementation // ImmutablePass Implementation

View File

@ -99,13 +99,15 @@ ValueName *ValueSymbolTable::createValueName(StringRef Name, Value *V) {
return makeUniqueName(V, UniqueName); return makeUniqueName(V, UniqueName);
} }
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
// dump - print out the symbol table // dump - print out the symbol table
// //
LLVM_DUMP_METHOD void ValueSymbolTable::dump() const { LLVM_DUMP_METHOD void ValueSymbolTable::dump() const {
//DEBUG(dbgs() << "ValueSymbolTable:\n"); //dbgs() << "ValueSymbolTable:\n";
for (const auto &I : *this) { for (const auto &I : *this) {
//DEBUG(dbgs() << " '" << I->getKeyData() << "' = "); //dbgs() << " '" << I->getKeyData() << "' = ";
I.getValue()->dump(); I.getValue()->dump();
//DEBUG(dbgs() << "\n"); //dbgs() << "\n";
} }
} }
#endif

View File

@ -129,10 +129,12 @@ void MCExpr::print(raw_ostream &OS, const MCAsmInfo *MAI, bool InParens) const {
llvm_unreachable("Invalid expression kind!"); llvm_unreachable("Invalid expression kind!");
} }
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
LLVM_DUMP_METHOD void MCExpr::dump() const { LLVM_DUMP_METHOD void MCExpr::dump() const {
dbgs() << *this; dbgs() << *this;
dbgs() << '\n'; dbgs() << '\n';
} }
#endif
/* *** */ /* *** */

View File

@ -309,6 +309,7 @@ raw_ostream &operator<<(raw_ostream &OS, const MCFixup &AF) {
} }
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
LLVM_DUMP_METHOD void MCFragment::dump() { LLVM_DUMP_METHOD void MCFragment::dump() {
raw_ostream &OS = llvm::errs(); raw_ostream &OS = llvm::errs();
@ -468,3 +469,4 @@ LLVM_DUMP_METHOD void MCAssembler::dump() {
} }
OS << "]>\n"; OS << "]>\n";
} }
#endif

View File

@ -34,10 +34,12 @@ void MCOperand::print(raw_ostream &OS) const {
OS << ">"; OS << ">";
} }
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
LLVM_DUMP_METHOD void MCOperand::dump() const { LLVM_DUMP_METHOD void MCOperand::dump() const {
print(dbgs()); print(dbgs());
dbgs() << "\n"; dbgs() << "\n";
} }
#endif
void MCInst::print(raw_ostream &OS) const { void MCInst::print(raw_ostream &OS) const {
OS << "<MCInst " << getOpcode(); OS << "<MCInst " << getOpcode();
@ -63,7 +65,9 @@ void MCInst::dump_pretty(raw_ostream &OS, const MCInstPrinter *Printer,
OS << ">"; OS << ">";
} }
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
LLVM_DUMP_METHOD void MCInst::dump() const { LLVM_DUMP_METHOD void MCInst::dump() const {
print(dbgs()); print(dbgs());
dbgs() << "\n"; dbgs() << "\n";
} }
#endif

View File

@ -16,6 +16,8 @@ void MCLabel::print(raw_ostream &OS) const {
OS << '"' << getInstance() << '"'; OS << '"' << getInstance() << '"';
} }
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
LLVM_DUMP_METHOD void MCLabel::dump() const { LLVM_DUMP_METHOD void MCLabel::dump() const {
print(dbgs()); print(dbgs());
} }
#endif

View File

@ -137,6 +137,9 @@ bool MCAsmParser::parseExpression(const MCExpr *&Res) {
return parseExpression(Res, L); return parseExpression(Res, L);
} }
LLVM_DUMP_METHOD void MCParsedAsmOperand::dump() const { void MCParsedAsmOperand::dump() const {
// Cannot completely remove virtual function even in release mode.
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
dbgs() << " " << *this; dbgs() << " " << *this;
#endif
} }

View File

@ -85,6 +85,7 @@ MCSection::getSubsectionInsertionPoint(unsigned Subsection) {
return IP; return IP;
} }
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
LLVM_DUMP_METHOD void MCSection::dump() { LLVM_DUMP_METHOD void MCSection::dump() {
raw_ostream &OS = llvm::errs(); raw_ostream &OS = llvm::errs();
@ -97,3 +98,4 @@ LLVM_DUMP_METHOD void MCSection::dump() {
} }
OS << "]>"; OS << "]>";
} }
#endif

View File

@ -75,4 +75,8 @@ void MCSymbol::print(raw_ostream &OS, const MCAsmInfo *MAI) const {
OS << '"'; OS << '"';
} }
LLVM_DUMP_METHOD void MCSymbol::dump() const { dbgs() << *this; } #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
LLVM_DUMP_METHOD void MCSymbol::dump() const {
dbgs() << *this;
}
#endif

View File

@ -37,9 +37,11 @@ void MCValue::print(raw_ostream &OS) const {
OS << " + " << getConstant(); OS << " + " << getConstant();
} }
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
LLVM_DUMP_METHOD void MCValue::dump() const { LLVM_DUMP_METHOD void MCValue::dump() const {
print(dbgs()); print(dbgs());
} }
#endif
MCSymbolRefExpr::VariantKind MCValue::getAccessVariant() const { MCSymbolRefExpr::VariantKind MCValue::getAccessVariant() const {
const MCSymbolRefExpr *B = getSymB(); const MCSymbolRefExpr *B = getSymB();

View File

@ -282,11 +282,13 @@ void SubtargetFeatures::print(raw_ostream &OS) const {
OS << "\n"; OS << "\n";
} }
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
/// dump - Dump feature info. /// dump - Dump feature info.
/// ///
LLVM_DUMP_METHOD void SubtargetFeatures::dump() const { LLVM_DUMP_METHOD void SubtargetFeatures::dump() const {
print(dbgs()); print(dbgs());
} }
#endif
/// Adds the default features for the specified target triple. /// Adds the default features for the specified target triple.
/// ///

View File

@ -61,7 +61,9 @@ void Arg::print(raw_ostream& O) const {
O << "]>\n"; O << "]>\n";
} }
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
LLVM_DUMP_METHOD void Arg::dump() const { print(dbgs()); } LLVM_DUMP_METHOD void Arg::dump() const { print(dbgs()); }
#endif
std::string Arg::getAsString(const ArgList &Args) const { std::string Arg::getAsString(const ArgList &Args) const {
SmallString<256> Res; SmallString<256> Res;

View File

@ -353,7 +353,9 @@ void ArgList::print(raw_ostream &O) const {
} }
} }
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
LLVM_DUMP_METHOD void ArgList::dump() const { print(dbgs()); } LLVM_DUMP_METHOD void ArgList::dump() const { print(dbgs()); }
#endif
// //

View File

@ -83,7 +83,9 @@ void Option::print(raw_ostream &O) const {
O << ">\n"; O << ">\n";
} }
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
LLVM_DUMP_METHOD void Option::dump() const { print(dbgs()); } LLVM_DUMP_METHOD void Option::dump() const { print(dbgs()); }
#endif
bool Option::matches(OptSpecifier Opt) const { bool Option::matches(OptSpecifier Opt) const {
// Aliases are never considered in matching, look through them. // Aliases are never considered in matching, look through them.

View File

@ -74,7 +74,9 @@ raw_ostream &llvm::sampleprof::operator<<(raw_ostream &OS,
return OS; return OS;
} }
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
LLVM_DUMP_METHOD void LineLocation::dump() const { print(dbgs()); } LLVM_DUMP_METHOD void LineLocation::dump() const { print(dbgs()); }
#endif
/// \brief Print the sample record to the stream \p OS indented by \p Indent. /// \brief Print the sample record to the stream \p OS indented by \p Indent.
void SampleRecord::print(raw_ostream &OS, unsigned Indent) const { void SampleRecord::print(raw_ostream &OS, unsigned Indent) const {
@ -87,7 +89,9 @@ void SampleRecord::print(raw_ostream &OS, unsigned Indent) const {
OS << "\n"; OS << "\n";
} }
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
LLVM_DUMP_METHOD void SampleRecord::dump() const { print(dbgs(), 0); } LLVM_DUMP_METHOD void SampleRecord::dump() const { print(dbgs(), 0); }
#endif
raw_ostream &llvm::sampleprof::operator<<(raw_ostream &OS, raw_ostream &llvm::sampleprof::operator<<(raw_ostream &OS,
const SampleRecord &Sample) { const SampleRecord &Sample) {
@ -136,4 +140,6 @@ raw_ostream &llvm::sampleprof::operator<<(raw_ostream &OS,
return OS; return OS;
} }
void FunctionSamples::dump(void) const { print(dbgs(), 0); } #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
LLVM_DUMP_METHOD void FunctionSamples::dump(void) const { print(dbgs(), 0); }
#endif

View File

@ -4494,7 +4494,9 @@ void APFloat::print(raw_ostream &OS) const {
OS << Buffer << "\n"; OS << Buffer << "\n";
} }
void APFloat::dump() const { print(dbgs()); } #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
LLVM_DUMP_METHOD void APFloat::dump() const { print(dbgs()); }
#endif
void APFloat::Profile(FoldingSetNodeID &NID) const { void APFloat::Profile(FoldingSetNodeID &NID) const {
NID.Add(bitcastToAPInt()); NID.Add(bitcastToAPInt());

View File

@ -2241,7 +2241,7 @@ std::string APInt::toString(unsigned Radix = 10, bool Signed = true) const {
return S.str(); return S.str();
} }
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
LLVM_DUMP_METHOD void APInt::dump() const { LLVM_DUMP_METHOD void APInt::dump() const {
SmallString<40> S, U; SmallString<40> S, U;
this->toStringUnsigned(U); this->toStringUnsigned(U);
@ -2249,6 +2249,7 @@ LLVM_DUMP_METHOD void APInt::dump() const {
dbgs() << "APInt(" << BitWidth << "b, " dbgs() << "APInt(" << BitWidth << "b, "
<< U << "u " << S << "s)"; << U << "u " << S << "s)";
} }
#endif
void APInt::print(raw_ostream &OS, bool isSigned) const { void APInt::print(raw_ostream &OS, bool isSigned) const {
SmallString<40> S; SmallString<40> S;

View File

@ -32,7 +32,9 @@ raw_ostream &BranchProbability::print(raw_ostream &OS) const {
Percent); Percent);
} }
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
LLVM_DUMP_METHOD void BranchProbability::dump() const { print(dbgs()) << '\n'; } LLVM_DUMP_METHOD void BranchProbability::dump() const { print(dbgs()) << '\n'; }
#endif
BranchProbability::BranchProbability(uint32_t Numerator, uint32_t Denominator) { BranchProbability::BranchProbability(uint32_t Numerator, uint32_t Denominator) {
assert(Denominator > 0 && "Denominator cannot be 0!"); assert(Denominator > 0 && "Denominator cannot be 0!");

View File

@ -173,10 +173,12 @@ void Twine::printRepr(raw_ostream &OS) const {
OS << ")"; OS << ")";
} }
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
LLVM_DUMP_METHOD void Twine::dump() const { LLVM_DUMP_METHOD void Twine::dump() const {
print(dbgs()); print(dbgs());
} }
void Twine::dumpRepr() const { LLVM_DUMP_METHOD void Twine::dumpRepr() const {
printRepr(dbgs()); printRepr(dbgs());
} }
#endif

View File

@ -40,7 +40,9 @@ IntRecTy IntRecTy::Shared;
StringRecTy StringRecTy::Shared; StringRecTy StringRecTy::Shared;
DagRecTy DagRecTy::Shared; DagRecTy DagRecTy::Shared;
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
LLVM_DUMP_METHOD void RecTy::dump() const { print(errs()); } LLVM_DUMP_METHOD void RecTy::dump() const { print(errs()); }
#endif
ListRecTy *RecTy::getListTy() { ListRecTy *RecTy::getListTy() {
if (!ListTy) if (!ListTy)
@ -161,7 +163,9 @@ RecTy *llvm::resolveTypes(RecTy *T1, RecTy *T2) {
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
void Init::anchor() { } void Init::anchor() { }
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
LLVM_DUMP_METHOD void Init::dump() const { return print(errs()); } LLVM_DUMP_METHOD void Init::dump() const { return print(errs()); }
#endif
UnsetInit *UnsetInit::get() { UnsetInit *UnsetInit::get() {
static UnsetInit TheInit; static UnsetInit TheInit;
@ -1591,7 +1595,9 @@ StringRef RecordVal::getName() const {
return cast<StringInit>(getNameInit())->getValue(); return cast<StringInit>(getNameInit())->getValue();
} }
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
LLVM_DUMP_METHOD void RecordVal::dump() const { errs() << *this; } LLVM_DUMP_METHOD void RecordVal::dump() const { errs() << *this; }
#endif
void RecordVal::print(raw_ostream &OS, bool PrintSem) const { void RecordVal::print(raw_ostream &OS, bool PrintSem) const {
if (getPrefix()) OS << "field "; if (getPrefix()) OS << "field ";
@ -1673,7 +1679,9 @@ void Record::resolveReferencesTo(const RecordVal *RV) {
} }
} }
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
LLVM_DUMP_METHOD void Record::dump() const { errs() << *this; } LLVM_DUMP_METHOD void Record::dump() const { errs() << *this; }
#endif
raw_ostream &llvm::operator<<(raw_ostream &OS, const Record &R) { raw_ostream &llvm::operator<<(raw_ostream &OS, const Record &R) {
OS << R.getNameInitAsString(); OS << R.getNameInitAsString();
@ -1865,6 +1873,7 @@ DagInit *Record::getValueAsDag(StringRef FieldName) const {
FieldName + "' does not have a dag initializer!"); FieldName + "' does not have a dag initializer!");
} }
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
LLVM_DUMP_METHOD void MultiClass::dump() const { LLVM_DUMP_METHOD void MultiClass::dump() const {
errs() << "Record:\n"; errs() << "Record:\n";
Rec.dump(); Rec.dump();
@ -1875,6 +1884,7 @@ LLVM_DUMP_METHOD void MultiClass::dump() const {
} }
LLVM_DUMP_METHOD void RecordKeeper::dump() const { errs() << *this; } LLVM_DUMP_METHOD void RecordKeeper::dump() const { errs() << *this; }
#endif
raw_ostream &llvm::operator<<(raw_ostream &OS, const RecordKeeper &RK) { raw_ostream &llvm::operator<<(raw_ostream &OS, const RecordKeeper &RK) {
OS << "------------- Classes -----------------\n"; OS << "------------- Classes -----------------\n";

View File

@ -945,7 +945,7 @@ Init *TGParser::ParseOperation(Record *CurRec, RecTy *ItemType) {
else if (ListInit *Arg0 = dyn_cast<ListInit>(InitList[0])) else if (ListInit *Arg0 = dyn_cast<ListInit>(InitList[0]))
Type = Arg0->getType(); Type = Arg0->getType();
else { else {
InitList[0]->dump(); InitList[0]->print(errs());
Error(OpLoc, "expected a list"); Error(OpLoc, "expected a list");
return nullptr; return nullptr;
} }

View File

@ -832,7 +832,7 @@ SDValue AMDGPUTargetLowering::LowerOperation(SDValue Op,
SelectionDAG &DAG) const { SelectionDAG &DAG) const {
switch (Op.getOpcode()) { switch (Op.getOpcode()) {
default: default:
Op->dump(&DAG); Op->print(errs(), &DAG);
llvm_unreachable("Custom lowering code for this" llvm_unreachable("Custom lowering code for this"
"instruction is not implemented yet!"); "instruction is not implemented yet!");
break; break;

View File

@ -162,7 +162,7 @@ void AMDGPUAsmPrinter::EmitInstruction(const MachineInstr *MI) {
if (!STI.getInstrInfo()->verifyInstruction(*MI, Err)) { if (!STI.getInstrInfo()->verifyInstruction(*MI, Err)) {
LLVMContext &C = MI->getParent()->getParent()->getFunction()->getContext(); LLVMContext &C = MI->getParent()->getParent()->getFunction()->getContext();
C.emitError("Illegal instruction detected: " + Err); C.emitError("Illegal instruction detected: " + Err);
MI->dump(); MI->print(errs());
} }
if (MI->isBundle()) { if (MI->isBundle()) {

View File

@ -861,7 +861,7 @@ void AMDGPUPromoteAlloca::handleAlloca(AllocaInst &I) {
continue; continue;
} }
default: default:
Intr->dump(); Intr->print(errs());
llvm_unreachable("Don't know how to promote alloca intrinsic use."); llvm_unreachable("Don't know how to promote alloca intrinsic use.");
} }
} }

View File

@ -1255,7 +1255,7 @@ void ARMAsmPrinter::EmitUnwindingInstruction(const MachineInstr *MI) {
switch (Opc) { switch (Opc) {
default: default:
MI->dump(); MI->print(errs());
llvm_unreachable("Unsupported opcode for unwinding information"); llvm_unreachable("Unsupported opcode for unwinding information");
case ARM::tPUSH: case ARM::tPUSH:
// Special case here: no src & dst reg, but two extra imp ops. // Special case here: no src & dst reg, but two extra imp ops.
@ -1291,7 +1291,7 @@ void ARMAsmPrinter::EmitUnwindingInstruction(const MachineInstr *MI) {
int64_t Offset = 0; int64_t Offset = 0;
switch (Opc) { switch (Opc) {
default: default:
MI->dump(); MI->print(errs());
llvm_unreachable("Unsupported opcode for unwinding information"); llvm_unreachable("Unsupported opcode for unwinding information");
case ARM::MOVr: case ARM::MOVr:
case ARM::tMOVr: case ARM::tMOVr:
@ -1346,11 +1346,11 @@ void ARMAsmPrinter::EmitUnwindingInstruction(const MachineInstr *MI) {
} }
} }
} else if (DstReg == ARM::SP) { } else if (DstReg == ARM::SP) {
MI->dump(); MI->print(errs());
llvm_unreachable("Unsupported opcode for unwinding information"); llvm_unreachable("Unsupported opcode for unwinding information");
} }
else { else {
MI->dump(); MI->print(errs());
llvm_unreachable("Unsupported opcode for unwinding information"); llvm_unreachable("Unsupported opcode for unwinding information");
} }
} }

View File

@ -320,8 +320,9 @@ void ARMConstantIslands::verify() {
#endif #endif
} }
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
/// print block size and offset information - debugging /// print block size and offset information - debugging
void ARMConstantIslands::dumpBBs() { LLVM_DUMP_METHOD void ARMConstantIslands::dumpBBs() {
DEBUG({ DEBUG({
for (unsigned J = 0, E = BBInfo.size(); J !=E; ++J) { for (unsigned J = 0, E = BBInfo.size(); J !=E; ++J) {
const BasicBlockInfo &BBI = BBInfo[J]; const BasicBlockInfo &BBI = BBInfo[J];
@ -333,6 +334,7 @@ void ARMConstantIslands::dumpBBs() {
} }
}); });
} }
#endif
bool ARMConstantIslands::runOnMachineFunction(MachineFunction &mf) { bool ARMConstantIslands::runOnMachineFunction(MachineFunction &mf) {
MF = &mf; MF = &mf;

View File

@ -98,9 +98,11 @@ ARMConstantPoolValue::hasSameValue(ARMConstantPoolValue *ACPV) {
return false; return false;
} }
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
LLVM_DUMP_METHOD void ARMConstantPoolValue::dump() const { LLVM_DUMP_METHOD void ARMConstantPoolValue::dump() const {
errs() << " " << *this; errs() << " " << *this;
} }
#endif
void ARMConstantPoolValue::print(raw_ostream &O) const { void ARMConstantPoolValue::print(raw_ostream &O) const {
if (Modifier) O << "(" << getModifierText() << ")"; if (Modifier) O << "(" << getModifierText() << ")";

View File

@ -8729,7 +8729,7 @@ ARMTargetLowering::EmitInstrWithCustomInserter(MachineInstr &MI,
bool isThumb2 = Subtarget->isThumb2(); bool isThumb2 = Subtarget->isThumb2();
switch (MI.getOpcode()) { switch (MI.getOpcode()) {
default: { default: {
MI.dump(); MI.print(errs());
llvm_unreachable("Unexpected instr type to insert"); llvm_unreachable("Unexpected instr type to insert");
} }

View File

@ -138,7 +138,7 @@ void BPFDAGToDAGISel::Select(SDNode *Node) {
else else
errs() << "Error: "; errs() << "Error: ";
errs() << "Unsupport signed division for DAG: "; errs() << "Unsupport signed division for DAG: ";
Node->dump(CurDAG); Node->print(errs(), CurDAG);
errs() << "Please convert to unsigned div/mod.\n"; errs() << "Please convert to unsigned div/mod.\n";
break; break;
} }

View File

@ -54,7 +54,7 @@ void BPFMCInstLower::Lower(const MachineInstr *MI, MCInst &OutMI) const {
MCOperand MCOp; MCOperand MCOp;
switch (MO.getType()) { switch (MO.getType()) {
default: default:
MI->dump(); MI->print(errs());
llvm_unreachable("unknown operand type"); llvm_unreachable("unknown operand type");
case MachineOperand::MO_Register: case MachineOperand::MO_Register:
// Ignore all implicit register operands. // Ignore all implicit register operands.

View File

@ -109,7 +109,7 @@ void llvm::HexagonLowerToMC(const MCInstrInfo &MCII, const MachineInstr *MI,
switch (MO.getType()) { switch (MO.getType()) {
default: default:
MI->dump(); MI->print(errs());
llvm_unreachable("unknown operand type"); llvm_unreachable("unknown operand type");
case MachineOperand::MO_Register: case MachineOperand::MO_Register:
// Ignore all implicit register operands. // Ignore all implicit register operands.

View File

@ -131,13 +131,15 @@ namespace {
INITIALIZE_PASS(HexagonSplitDoubleRegs, "hexagon-split-double", INITIALIZE_PASS(HexagonSplitDoubleRegs, "hexagon-split-double",
"Hexagon Split Double Registers", false, false) "Hexagon Split Double Registers", false, false)
void HexagonSplitDoubleRegs::dump_partition(raw_ostream &os, #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
LLVM_DUMP_METHOD void HexagonSplitDoubleRegs::dump_partition(raw_ostream &os,
const USet &Part, const TargetRegisterInfo &TRI) { const USet &Part, const TargetRegisterInfo &TRI) {
dbgs() << '{'; dbgs() << '{';
for (auto I : Part) for (auto I : Part)
dbgs() << ' ' << PrintReg(I, &TRI); dbgs() << ' ' << PrintReg(I, &TRI);
dbgs() << " }"; dbgs() << " }";
} }
#endif
bool HexagonSplitDoubleRegs::isInduction(unsigned Reg, LoopRegMap &IRM) const { bool HexagonSplitDoubleRegs::isInduction(unsigned Reg, LoopRegMap &IRM) const {
for (auto I : IRM) { for (auto I : IRM) {

View File

@ -130,7 +130,7 @@ void LanaiMCInstLower::Lower(const MachineInstr *MI, MCInst &OutMI) const {
MCOp = LowerSymbolOperand(MO, GetConstantPoolIndexSymbol(MO)); MCOp = LowerSymbolOperand(MO, GetConstantPoolIndexSymbol(MO));
break; break;
default: default:
MI->dump(); MI->print(errs());
llvm_unreachable("unknown operand type"); llvm_unreachable("unknown operand type");
} }

View File

@ -119,7 +119,7 @@ void MSP430MCInstLower::Lower(const MachineInstr *MI, MCInst &OutMI) const {
MCOperand MCOp; MCOperand MCOp;
switch (MO.getType()) { switch (MO.getType()) {
default: default:
MI->dump(); MI->print(errs());
llvm_unreachable("unknown operand type"); llvm_unreachable("unknown operand type");
case MachineOperand::MO_Register: case MachineOperand::MO_Register:
// Ignore all implicit register operands. // Ignore all implicit register operands.

View File

@ -417,16 +417,16 @@ bool MipsConstantIslands::isOffsetInRange
return isOffsetInRange(UserOffset, TrialOffset, return isOffsetInRange(UserOffset, TrialOffset,
U.getMaxDisp(), U.NegOk); U.getMaxDisp(), U.NegOk);
} }
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
/// print block size and offset information - debugging /// print block size and offset information - debugging
void MipsConstantIslands::dumpBBs() { LLVM_DUMP_METHOD void MipsConstantIslands::dumpBBs() {
DEBUG({ for (unsigned J = 0, E = BBInfo.size(); J !=E; ++J) {
for (unsigned J = 0, E = BBInfo.size(); J !=E; ++J) { const BasicBlockInfo &BBI = BBInfo[J];
const BasicBlockInfo &BBI = BBInfo[J]; dbgs() << format("%08x BB#%u\t", BBI.Offset, J)
dbgs() << format("%08x BB#%u\t", BBI.Offset, J) << format(" size=%#x\n", BBInfo[J].Size);
<< format(" size=%#x\n", BBInfo[J].Size); }
}
});
} }
#endif
/// Returns a pass that converts branches to long branches. /// Returns a pass that converts branches to long branches.
FunctionPass *llvm::createMipsConstantIslandPass() { FunctionPass *llvm::createMipsConstantIslandPass() {
return new MipsConstantIslands(); return new MipsConstantIslands();

View File

@ -148,7 +148,7 @@ void llvm::LowerPPCMachineInstrToMCInst(const MachineInstr *MI, MCInst &OutMI,
MCOperand MCOp; MCOperand MCOp;
switch (MO.getType()) { switch (MO.getType()) {
default: default:
MI->dump(); MI->print(errs());
llvm_unreachable("unknown operand type"); llvm_unreachable("unknown operand type");
case MachineOperand::MO_Register: case MachineOperand::MO_Register:
assert(!MO.getSubReg() && "Subregs should be eliminated!"); assert(!MO.getSubReg() && "Subregs should be eliminated!");

View File

@ -522,7 +522,7 @@ bool PPCVSXSwapRemoval::gatherVectorInstructions() {
if (RelevantFunction) { if (RelevantFunction) {
DEBUG(dbgs() << "Swap vector when first built\n\n"); DEBUG(dbgs() << "Swap vector when first built\n\n");
dumpSwapVector(); DEBUG(dumpSwapVector());
} }
return RelevantFunction; return RelevantFunction;
@ -731,7 +731,7 @@ void PPCVSXSwapRemoval::recordUnoptimizableWebs() {
} }
DEBUG(dbgs() << "Swap vector after web analysis:\n\n"); DEBUG(dbgs() << "Swap vector after web analysis:\n\n");
dumpSwapVector(); DEBUG(dumpSwapVector());
} }
// Walk the swap vector entries looking for swaps fed by permuting loads // Walk the swap vector entries looking for swaps fed by permuting loads
@ -951,77 +951,78 @@ bool PPCVSXSwapRemoval::removeSwaps() {
return Changed; return Changed;
} }
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
// For debug purposes, dump the contents of the swap vector. // For debug purposes, dump the contents of the swap vector.
void PPCVSXSwapRemoval::dumpSwapVector() { LLVM_DUMP_METHOD void PPCVSXSwapRemoval::dumpSwapVector() {
for (unsigned EntryIdx = 0; EntryIdx < SwapVector.size(); ++EntryIdx) { for (unsigned EntryIdx = 0; EntryIdx < SwapVector.size(); ++EntryIdx) {
MachineInstr *MI = SwapVector[EntryIdx].VSEMI; MachineInstr *MI = SwapVector[EntryIdx].VSEMI;
int ID = SwapVector[EntryIdx].VSEId; int ID = SwapVector[EntryIdx].VSEId;
DEBUG(dbgs() << format("%6d", ID)); dbgs() << format("%6d", ID);
DEBUG(dbgs() << format("%6d", EC->getLeaderValue(ID))); dbgs() << format("%6d", EC->getLeaderValue(ID));
DEBUG(dbgs() << format(" BB#%3d", MI->getParent()->getNumber())); dbgs() << format(" BB#%3d", MI->getParent()->getNumber());
DEBUG(dbgs() << format(" %14s ", dbgs() << format(" %14s ", TII->getName(MI->getOpcode()).str().c_str());
TII->getName(MI->getOpcode()).str().c_str()));
if (SwapVector[EntryIdx].IsLoad) if (SwapVector[EntryIdx].IsLoad)
DEBUG(dbgs() << "load "); dbgs() << "load ";
if (SwapVector[EntryIdx].IsStore) if (SwapVector[EntryIdx].IsStore)
DEBUG(dbgs() << "store "); dbgs() << "store ";
if (SwapVector[EntryIdx].IsSwap) if (SwapVector[EntryIdx].IsSwap)
DEBUG(dbgs() << "swap "); dbgs() << "swap ";
if (SwapVector[EntryIdx].MentionsPhysVR) if (SwapVector[EntryIdx].MentionsPhysVR)
DEBUG(dbgs() << "physreg "); dbgs() << "physreg ";
if (SwapVector[EntryIdx].MentionsPartialVR) if (SwapVector[EntryIdx].MentionsPartialVR)
DEBUG(dbgs() << "partialreg "); dbgs() << "partialreg ";
if (SwapVector[EntryIdx].IsSwappable) { if (SwapVector[EntryIdx].IsSwappable) {
DEBUG(dbgs() << "swappable "); dbgs() << "swappable ";
switch(SwapVector[EntryIdx].SpecialHandling) { switch(SwapVector[EntryIdx].SpecialHandling) {
default: default:
DEBUG(dbgs() << "special:**unknown**"); dbgs() << "special:**unknown**";
break; break;
case SH_NONE: case SH_NONE:
break; break;
case SH_EXTRACT: case SH_EXTRACT:
DEBUG(dbgs() << "special:extract "); dbgs() << "special:extract ";
break; break;
case SH_INSERT: case SH_INSERT:
DEBUG(dbgs() << "special:insert "); dbgs() << "special:insert ";
break; break;
case SH_NOSWAP_LD: case SH_NOSWAP_LD:
DEBUG(dbgs() << "special:load "); dbgs() << "special:load ";
break; break;
case SH_NOSWAP_ST: case SH_NOSWAP_ST:
DEBUG(dbgs() << "special:store "); dbgs() << "special:store ";
break; break;
case SH_SPLAT: case SH_SPLAT:
DEBUG(dbgs() << "special:splat "); dbgs() << "special:splat ";
break; break;
case SH_XXPERMDI: case SH_XXPERMDI:
DEBUG(dbgs() << "special:xxpermdi "); dbgs() << "special:xxpermdi ";
break; break;
case SH_COPYWIDEN: case SH_COPYWIDEN:
DEBUG(dbgs() << "special:copywiden "); dbgs() << "special:copywiden ";
break; break;
} }
} }
if (SwapVector[EntryIdx].WebRejected) if (SwapVector[EntryIdx].WebRejected)
DEBUG(dbgs() << "rejected "); dbgs() << "rejected ";
if (SwapVector[EntryIdx].WillRemove) if (SwapVector[EntryIdx].WillRemove)
DEBUG(dbgs() << "remove "); dbgs() << "remove ";
DEBUG(dbgs() << "\n"); dbgs() << "\n";
// For no-asserts builds. // For no-asserts builds.
(void)MI; (void)MI;
(void)ID; (void)ID;
} }
DEBUG(dbgs() << "\n"); dbgs() << "\n";
} }
#endif
} // end default namespace } // end default namespace

View File

@ -357,7 +357,7 @@ X86MCInstLower::LowerMachineOperand(const MachineInstr *MI,
const MachineOperand &MO) const { const MachineOperand &MO) const {
switch (MO.getType()) { switch (MO.getType()) {
default: default:
MI->dump(); MI->print(errs());
llvm_unreachable("unknown operand type"); llvm_unreachable("unknown operand type");
case MachineOperand::MO_Register: case MachineOperand::MO_Register:
// Ignore all implicit register operands. // Ignore all implicit register operands.

View File

@ -133,6 +133,7 @@ struct SuspendCrossingInfo {
}; };
} // end anonymous namespace } // end anonymous namespace
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
LLVM_DUMP_METHOD void SuspendCrossingInfo::dump(StringRef Label, LLVM_DUMP_METHOD void SuspendCrossingInfo::dump(StringRef Label,
BitVector const &BV) const { BitVector const &BV) const {
dbgs() << Label << ":"; dbgs() << Label << ":";
@ -151,6 +152,7 @@ LLVM_DUMP_METHOD void SuspendCrossingInfo::dump() const {
} }
dbgs() << "\n"; dbgs() << "\n";
} }
#endif
SuspendCrossingInfo::SuspendCrossingInfo(Function &F, coro::Shape &Shape) SuspendCrossingInfo::SuspendCrossingInfo(Function &F, coro::Shape &Shape)
: Mapping(F) { : Mapping(F) {

View File

@ -598,8 +598,8 @@ PreservedAnalyses GVN::run(Function &F, FunctionAnalysisManager &AM) {
return PA; return PA;
} }
LLVM_DUMP_METHOD #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
void GVN::dump(DenseMap<uint32_t, Value*>& d) { LLVM_DUMP_METHOD void GVN::dump(DenseMap<uint32_t, Value*>& d) {
errs() << "{\n"; errs() << "{\n";
for (DenseMap<uint32_t, Value*>::iterator I = d.begin(), for (DenseMap<uint32_t, Value*>::iterator I = d.begin(),
E = d.end(); I != E; ++I) { E = d.end(); I != E; ++I) {
@ -608,6 +608,7 @@ void GVN::dump(DenseMap<uint32_t, Value*>& d) {
} }
errs() << "}\n"; errs() << "}\n";
} }
#endif
/// Return true if we can prove that the value /// Return true if we can prove that the value
/// we're analyzing is fully available in the specified block. As we go, keep /// we're analyzing is fully available in the specified block. As we go, keep

View File

@ -180,10 +180,11 @@ void RegSortData::print(raw_ostream &OS) const {
OS << "[NumUses=" << UsedByIndices.count() << ']'; OS << "[NumUses=" << UsedByIndices.count() << ']';
} }
LLVM_DUMP_METHOD #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
void RegSortData::dump() const { LLVM_DUMP_METHOD void RegSortData::dump() const {
print(errs()); errs() << '\n'; print(errs()); errs() << '\n';
} }
#endif
namespace { namespace {
@ -533,10 +534,11 @@ void Formula::print(raw_ostream &OS) const {
} }
} }
LLVM_DUMP_METHOD #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
void Formula::dump() const { LLVM_DUMP_METHOD void Formula::dump() const {
print(errs()); errs() << '\n'; print(errs()); errs() << '\n';
} }
#endif
/// Return true if the given addrec can be sign-extended without changing its /// Return true if the given addrec can be sign-extended without changing its
/// value. /// value.
@ -1238,10 +1240,11 @@ void Cost::print(raw_ostream &OS) const {
OS << ", plus " << SetupCost << " setup cost"; OS << ", plus " << SetupCost << " setup cost";
} }
LLVM_DUMP_METHOD #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
void Cost::dump() const { LLVM_DUMP_METHOD void Cost::dump() const {
print(errs()); errs() << '\n'; print(errs()); errs() << '\n';
} }
#endif
LSRFixup::LSRFixup() LSRFixup::LSRFixup()
: UserInst(nullptr), OperandValToReplace(nullptr), : UserInst(nullptr), OperandValToReplace(nullptr),
@ -1284,10 +1287,11 @@ void LSRFixup::print(raw_ostream &OS) const {
OS << ", Offset=" << Offset; OS << ", Offset=" << Offset;
} }
LLVM_DUMP_METHOD #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
void LSRFixup::dump() const { LLVM_DUMP_METHOD void LSRFixup::dump() const {
print(errs()); errs() << '\n'; print(errs()); errs() << '\n';
} }
#endif
/// Test whether this use as a formula which has the same registers as the given /// Test whether this use as a formula which has the same registers as the given
/// formula. /// formula.
@ -1390,10 +1394,11 @@ void LSRUse::print(raw_ostream &OS) const {
OS << ", widest fixup type: " << *WidestFixupType; OS << ", widest fixup type: " << *WidestFixupType;
} }
LLVM_DUMP_METHOD #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
void LSRUse::dump() const { LLVM_DUMP_METHOD void LSRUse::dump() const {
print(errs()); errs() << '\n'; print(errs()); errs() << '\n';
} }
#endif
static bool isAMCompletelyFolded(const TargetTransformInfo &TTI, static bool isAMCompletelyFolded(const TargetTransformInfo &TTI,
LSRUse::KindType Kind, MemAccessTy AccessTy, LSRUse::KindType Kind, MemAccessTy AccessTy,
@ -3696,10 +3701,11 @@ void WorkItem::print(raw_ostream &OS) const {
<< " , add offset " << Imm; << " , add offset " << Imm;
} }
LLVM_DUMP_METHOD #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
void WorkItem::dump() const { LLVM_DUMP_METHOD void WorkItem::dump() const {
print(errs()); errs() << '\n'; print(errs()); errs() << '\n';
} }
#endif
/// Look for registers which are a constant distance apart and try to form reuse /// Look for registers which are a constant distance apart and try to form reuse
/// opportunities between them. /// opportunities between them.
@ -4974,10 +4980,11 @@ void LSRInstance::print(raw_ostream &OS) const {
print_uses(OS); print_uses(OS);
} }
LLVM_DUMP_METHOD #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
void LSRInstance::dump() const { LLVM_DUMP_METHOD void LSRInstance::dump() const {
print(errs()); errs() << '\n'; print(errs()); errs() << '\n';
} }
#endif
namespace { namespace {

View File

@ -1888,10 +1888,11 @@ void MemorySSA::print(raw_ostream &OS) const {
F.print(OS, &Writer); F.print(OS, &Writer);
} }
void MemorySSA::dump() const { #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
MemorySSAAnnotatedWriter Writer(this); LLVM_DUMP_METHOD void MemorySSA::dump() const {
F.print(dbgs(), &Writer); print(dbgs());
} }
#endif
void MemorySSA::verifyMemorySSA() const { void MemorySSA::verifyMemorySSA() const {
verifyDefUses(F); verifyDefUses(F);
@ -2161,8 +2162,11 @@ void MemoryUse::print(raw_ostream &OS) const {
} }
void MemoryAccess::dump() const { void MemoryAccess::dump() const {
// Cannot completely remove virtual function even in release mode.
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
print(dbgs()); print(dbgs());
dbgs() << "\n"; dbgs() << "\n";
#endif
} }
char MemorySSAPrinterLegacyPass::ID = 0; char MemorySSAPrinterLegacyPass::ID = 0;

View File

@ -130,7 +130,8 @@ void llvm::appendToCompilerUsed(Module &M, ArrayRef<GlobalValue *> Values) {
Function *llvm::checkSanitizerInterfaceFunction(Constant *FuncOrBitcast) { Function *llvm::checkSanitizerInterfaceFunction(Constant *FuncOrBitcast) {
if (isa<Function>(FuncOrBitcast)) if (isa<Function>(FuncOrBitcast))
return cast<Function>(FuncOrBitcast); return cast<Function>(FuncOrBitcast);
FuncOrBitcast->dump(); FuncOrBitcast->print(errs());
errs() << '\n';
std::string Err; std::string Err;
raw_string_ostream Stream(Err); raw_string_ostream Stream(Err);
Stream << "Sanitizer interface function redefined: " << *FuncOrBitcast; Stream << "Sanitizer interface function redefined: " << *FuncOrBitcast;

View File

@ -74,7 +74,7 @@ static void reportCoverage(StringRef SourceFile, StringRef ObjectDir,
} }
if (DumpGCOV) if (DumpGCOV)
GF.dump(); GF.print(errs());
FileInfo FI(Options); FileInfo FI(Options);
GF.collectLineCounts(FI); GF.collectLineCounts(FI);

View File

@ -15,6 +15,7 @@
#include "llvm/IR/Instructions.h" #include "llvm/IR/Instructions.h"
#include "llvm/IR/Module.h" #include "llvm/IR/Module.h"
#include "llvm/Support/ErrorHandling.h" #include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/Debug.h"
using namespace llvm; using namespace llvm;
@ -195,17 +196,17 @@ void DiffConsumer::logd(const DiffLogBuilder &Log) {
switch (Log.getLineKind(I)) { switch (Log.getLineKind(I)) {
case DC_match: case DC_match:
out << " "; out << " ";
Log.getLeft(I)->dump(); Log.getLeft(I)->print(dbgs()); dbgs() << '\n';
//printValue(Log.getLeft(I), true); //printValue(Log.getLeft(I), true);
break; break;
case DC_left: case DC_left:
out << "< "; out << "< ";
Log.getLeft(I)->dump(); Log.getLeft(I)->print(dbgs()); dbgs() << '\n';
//printValue(Log.getLeft(I), true); //printValue(Log.getLeft(I), true);
break; break;
case DC_right: case DC_right:
out << "> "; out << "> ";
Log.getRight(I)->dump(); Log.getRight(I)->print(dbgs()); dbgs() << '\n';
//printValue(Log.getRight(I), false); //printValue(Log.getRight(I), false);
break; break;
} }

View File

@ -35,7 +35,7 @@ namespace {
} }
bool runOnFunction(Function &F) override { bool runOnFunction(Function &F) override {
getAnalysis<DominatorTreeWrapperPass>().dump(); getAnalysis<DominatorTreeWrapperPass>().print(dbgs());
return false; return false;
} }
}; };

View File

@ -96,7 +96,7 @@ void CallingConvEmitter::EmitAction(Record *Action,
} else if (Action->isSubClassOf("CCIf")) { } else if (Action->isSubClassOf("CCIf")) {
O << Action->getValueAsString("Predicate"); O << Action->getValueAsString("Predicate");
} else { } else {
Action->dump(); errs() << *Action;
PrintFatalError("Unknown CCPredicateAction!"); PrintFatalError("Unknown CCPredicateAction!");
} }
@ -268,7 +268,7 @@ void CallingConvEmitter::EmitAction(Record *Action,
<< "LocVT, LocInfo, ArgFlags, State))\n"; << "LocVT, LocInfo, ArgFlags, State))\n";
O << IndentStr << IndentStr << "return false;\n"; O << IndentStr << IndentStr << "return false;\n";
} else { } else {
Action->dump(); errs() << *Action;
PrintFatalError("Unknown CCAction!"); PrintFatalError("Unknown CCAction!");
} }
} }

View File

@ -1248,7 +1248,7 @@ static unsigned GetNumNodeResults(Record *Operator, CodeGenDAGPatterns &CDP) {
if (Operator->isSubClassOf("ComplexPattern")) if (Operator->isSubClassOf("ComplexPattern"))
return 1; return 1;
Operator->dump(); errs() << *Operator;
PrintFatalError("Unhandled node in GetNumNodeResults"); PrintFatalError("Unhandled node in GetNumNodeResults");
} }
@ -2114,7 +2114,7 @@ TreePatternNode *TreePattern::ParseTreePattern(Init *TheInit, StringRef OpName){
DagInit *Dag = dyn_cast<DagInit>(TheInit); DagInit *Dag = dyn_cast<DagInit>(TheInit);
if (!Dag) { if (!Dag) {
TheInit->dump(); TheInit->print(errs());
error("Pattern has unexpected init kind!"); error("Pattern has unexpected init kind!");
} }
DefInit *OpDef = dyn_cast<DefInit>(Dag->getOperator()); DefInit *OpDef = dyn_cast<DefInit>(Dag->getOperator());