Here's an example patch of how dbgs() will be used. Essentially I will
replace uses of errs() with dbgs(). I believe this is the correct thing
to do because:
- With #define NDEBUG, dbgs() == errs()
- With debugging and -debug-buffer-size=0 (the default), dbgs() just
passes output to errs().
- When -debug-buffer-size>0, you want to buffer ALL output so that you
don't get some strange reordering effect where some output goes out
early and the rest gets dumped at the end.
Please review and let me know if the general approach is ok. I will
start to convert files once I get the ok.
Thanks!
-Dave
Index: lib/CodeGen/SelectionDAG/SelectionDAG.cpp
==================================================================---
lib/CodeGen/SelectionDAG/SelectionDAG.cpp (revision 91557)
+++ lib/CodeGen/SelectionDAG/SelectionDAG.cpp (working copy)
@@ -34,6 +34,7 @@
#include "llvm/Target/TargetIntrinsicInfo.h"
#include "llvm/Target/TargetMachine.h"
#include "llvm/Support/CommandLine.h"
+#include "llvm/Support/Debug.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/ManagedStatic.h"
#include "llvm/Support/MathExtras.h"
@@ -5666,7 +5667,7 @@
void SDNode::dump() const { dump(0); }
void SDNode::dump(const SelectionDAG *G) const {
- print(errs(), G);
+ print(dbgs(), G);
}
void SDNode::print_types(raw_ostream &OS, const SelectionDAG *G) const {
@@ -5834,12 +5835,12 @@
if (N->getOperand(i).getNode()->hasOneUse())
DumpNodes(N->getOperand(i).getNode(), indent+2, G);
else
- errs() << "\n" << std::string(indent+2, '
')
- << (void*)N->getOperand(i).getNode() << ":
<multiple use>";
+ dbgs() << "\n" << std::string(indent+2, '
')
+ << (void*)N->getOperand(i).getNode() << ":
<multiple use>";
- errs() << "\n";
- errs().indent(indent);
+ dbgs() << "\n";
+ dbgs().indent(indent);
N->dump(G);
}
@@ -5997,7 +5998,7 @@
}
void SelectionDAG::dump() const {
- errs() << "SelectionDAG has " << AllNodes.size()
<< " nodes:";
+ dbgs() << "SelectionDAG has " << AllNodes.size()
<< " nodes:";
for (allnodes_const_iterator I = allnodes_begin(), E = allnodes_end();
I != E; ++I) {
@@ -6008,7 +6009,7 @@
if (getRoot().getNode()) DumpNodes(getRoot().getNode(), 2, this);
- errs() << "\n\n";
+ dbgs() << "\n\n";
}
void SDNode::printr(raw_ostream &OS, const SelectionDAG *G) const {
@@ -6049,12 +6050,12 @@
void SDNode::dumpr() const {
VisitedSDNodeSet once;
- DumpNodesr(errs(), this, 0, 0, once);
+ DumpNodesr(dbgs(), this, 0, 0, once);
}
void SDNode::dumpr(const SelectionDAG *G) const {
VisitedSDNodeSet once;
- DumpNodesr(errs(), this, 0, G, once);
+ DumpNodesr(dbgs(), this, 0, G, once);
}
Index: lib/Target/X86/X86ISelDAGToDAG.cpp
==================================================================---
lib/Target/X86/X86ISelDAGToDAG.cpp (revision 91557)
+++ lib/Target/X86/X86ISelDAGToDAG.cpp (working copy)
@@ -116,37 +116,37 @@
}
void dump() {
- errs() << "X86ISelAddressMode " << this <<
'\n';
- errs() << "Base.Reg ";
+ dbgs() << "X86ISelAddressMode " << this <<
'\n';
+ dbgs() << "Base.Reg ";
if (Base.Reg.getNode() != 0)
Base.Reg.getNode()->dump();
else
- errs() << "nul";
- errs() << " Base.FrameIndex " << Base.FrameIndex
<< '\n'
+ dbgs() << "nul";
+ dbgs() << " Base.FrameIndex " << Base.FrameIndex
<< '\n'
<< " Scale" << Scale << '\n'
<< "IndexReg ";
if (IndexReg.getNode() != 0)
IndexReg.getNode()->dump();
else
- errs() << "nul";
- errs() << " Disp " << Disp << '\n'
+ dbgs() << "nul";
+ dbgs() << " Disp " << Disp << '\n'
<< "GV ";
if (GV)
GV->dump();
else
- errs() << "nul";
- errs() << " CP ";
+ dbgs() << "nul";
+ dbgs() << " CP ";
if (CP)
CP->dump();
else
- errs() << "nul";
- errs() << '\n'
+ dbgs() << "nul";
+ dbgs() << '\n'
<< "ES ";
if (ES)
- errs() << ES;
+ dbgs() << ES;
else
- errs() << "nul";
- errs() << " JT" << JT << " Align"
<< Align << '\n';
+ dbgs() << "nul";
+ dbgs() << " JT" << JT << " Align"
<< Align << '\n';
}
};
}
@@ -678,12 +678,12 @@
// Codegen the basic block.
#ifndef NDEBUG
- DEBUG(errs() << "===== Instruction selection begins:\n");
+ DEBUG(dbgs() << "===== Instruction selection begins:\n");
Indent = 0;
#endif
SelectRoot(*CurDAG);
#ifndef NDEBUG
- DEBUG(errs() << "===== Instruction selection ends:\n");
+ DEBUG(dbgs() << "===== Instruction selection ends:\n");
#endif
CurDAG->RemoveDeadNodes();
@@ -853,7 +853,7 @@
bool is64Bit = Subtarget->is64Bit();
DebugLoc dl = N.getDebugLoc();
DEBUG({
- errs() << "MatchAddress: ";
+ dbgs() << "MatchAddress: ";
AM.dump();
});
// Limit recursion.
@@ -1711,9 +1711,9 @@
#ifndef NDEBUG
DEBUG({
- errs() << std::string(Indent, ' ') <<
"Selecting: ";
+ dbgs() << std::string(Indent, ' ') <<
"Selecting: ";
Node->dump(CurDAG);
- errs() << '\n';
+ dbgs() << '\n';
});
Indent += 2;
#endif
@@ -1721,9 +1721,9 @@
if (Node->isMachineOpcode()) {
#ifndef NDEBUG
DEBUG({
- errs() << std::string(Indent-2, ' ') << "==
";
+ dbgs() << std::string(Indent-2, ' ') << "==
";
Node->dump(CurDAG);
- errs() << '\n';
+ dbgs() << '\n';
});
Indent -= 2;
#endif
@@ -1824,9 +1824,9 @@
ReplaceUses(N.getValue(0), Result);
#ifndef NDEBUG
DEBUG({
- errs() << std::string(Indent-2, ' ') <<
"=> ";
+ dbgs() << std::string(Indent-2, ' ') <<
"=> ";
Result.getNode()->dump(CurDAG);
- errs() << '\n';
+ dbgs() << '\n';
});
#endif
}
@@ -1853,9 +1853,9 @@
ReplaceUses(N.getValue(1), Result);
#ifndef NDEBUG
DEBUG({
- errs() << std::string(Indent-2, ' ') <<
"=> ";
+ dbgs() << std::string(Indent-2, ' ') <<
"=> ";
Result.getNode()->dump(CurDAG);
- errs() << '\n';
+ dbgs() << '\n';
});
#endif
}
@@ -1996,9 +1996,9 @@
ReplaceUses(N.getValue(0), Result);
#ifndef NDEBUG
DEBUG({
- errs() << std::string(Indent-2, ' ') <<
"=> ";
+ dbgs() << std::string(Indent-2, ' ') <<
"=> ";
Result.getNode()->dump(CurDAG);
- errs() << '\n';
+ dbgs() << '\n';
});
#endif
}
@@ -2026,9 +2026,9 @@
ReplaceUses(N.getValue(1), Result);
#ifndef NDEBUG
DEBUG({
- errs() << std::string(Indent-2, ' ') <<
"=> ";
+ dbgs() << std::string(Indent-2, ' ') <<
"=> ";
Result.getNode()->dump(CurDAG);
- errs() << '\n';
+ dbgs() << '\n';
});
#endif
}
@@ -2151,12 +2151,12 @@
#ifndef NDEBUG
DEBUG({
- errs() << std::string(Indent-2, ' ') << "=>
";
+ dbgs() << std::string(Indent-2, ' ') << "=>
";
if (ResNode == NULL || ResNode == N.getNode())
N.getNode()->dump(CurDAG);
else
ResNode->dump(CurDAG);
- errs() << '\n';
+ dbgs() << '\n';
});
Indent -= 2;
#endif