Fix some refactos for iostream changes (in -Asserts mode).
authorDaniel Dunbar <daniel@zuster.org>
Sun, 23 Aug 2009 08:50:52 +0000 (08:50 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Sun, 23 Aug 2009 08:50:52 +0000 (08:50 +0000)
 - The world needs better C++ refactoring tools, can I get an Amen!?

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@79843 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Support/Debug.h
lib/CodeGen/MachineFunction.cpp
lib/CodeGen/ScheduleDAGPrinter.cpp
lib/CodeGen/SelectionDAG/SelectionDAGPrinter.cpp
lib/Support/Debug.cpp
lib/Target/MSP430/MSP430ISelDAGToDAG.cpp
lib/Target/Mips/MipsISelDAGToDAG.cpp
lib/Target/SystemZ/SystemZISelDAGToDAG.cpp

index fce2500489f1ab0a53ec20b564dff5ba12690c79..6f82ea716f24026437406e9cfa3b55bdc8600470 100644 (file)
@@ -32,7 +32,9 @@ namespace llvm {
 // is specified.  This should probably not be referenced directly, instead, use
 // the DEBUG macro below.
 //
+#ifndef NDEBUG
 extern bool DebugFlag;
+#endif
 
 // isCurrentDebugType - Return true if the specified string is the debug type
 // specified on the command line, or if none was specified on the command line
index 5bf86e3630fabcbddd0294e503d43946afc99b43..25dfa6e1ba514c2db0959cb062789266728959da 100644 (file)
@@ -305,8 +305,8 @@ void MachineFunction::viewCFG() const
 #ifndef NDEBUG
   ViewGraph(this, "mf" + getFunction()->getNameStr());
 #else
-  cerr << "SelectionDAG::viewGraph is only available in debug builds on "
-       << "systems with Graphviz or gv!\n";
+  errs() << "SelectionDAG::viewGraph is only available in debug builds on "
+         << "systems with Graphviz or gv!\n";
 #endif // NDEBUG
 }
 
@@ -315,8 +315,8 @@ void MachineFunction::viewCFGOnly() const
 #ifndef NDEBUG
   ViewGraph(this, "mf" + getFunction()->getNameStr(), true);
 #else
-  cerr << "SelectionDAG::viewGraph is only available in debug builds on "
-       << "systems with Graphviz or gv!\n";
+  errs() << "SelectionDAG::viewGraph is only available in debug builds on "
+         << "systems with Graphviz or gv!\n";
 #endif // NDEBUG
 }
 
index ae358ec4fb5beef56000f9a11ef5dd698edae004..95ad05e7d784a4740c5858bc996ea3894b1e6685 100644 (file)
@@ -93,7 +93,7 @@ void ScheduleDAG::viewGraph() {
     ViewGraph(this, "dag." + MF.getFunction()->getNameStr(), false,
               "Scheduling-Units Graph for " + MF.getFunction()->getNameStr());
 #else
-  cerr << "ScheduleDAG::viewGraph is only available in debug builds on "
-       << "systems with Graphviz or gv!\n";
+  errs() << "ScheduleDAG::viewGraph is only available in debug builds on "
+         << "systems with Graphviz or gv!\n";
 #endif  // NDEBUG
 }
index 50f2d07f8b2af7c67ac5f215104d8c75557eef0c..ccc5e3c75c99b77cb23727fc6a84b7a4d2ad4f51 100644 (file)
@@ -141,8 +141,8 @@ void SelectionDAG::viewGraph(const std::string &Title) {
   ViewGraph(this, "dag." + getMachineFunction().getFunction()->getNameStr(), 
             false, Title);
 #else
-  cerr << "SelectionDAG::viewGraph is only available in debug builds on "
-       << "systems with Graphviz or gv!\n";
+  errs() << "SelectionDAG::viewGraph is only available in debug builds on "
+         << "systems with Graphviz or gv!\n";
 #endif  // NDEBUG
 }
 
@@ -158,8 +158,8 @@ void SelectionDAG::clearGraphAttrs() {
 #ifndef NDEBUG
   NodeGraphAttrs.clear();
 #else
-  cerr << "SelectionDAG::clearGraphAttrs is only available in debug builds"
-       << " on systems with Graphviz or gv!\n";
+  errs() << "SelectionDAG::clearGraphAttrs is only available in debug builds"
+         << " on systems with Graphviz or gv!\n";
 #endif
 }
 
@@ -170,8 +170,8 @@ void SelectionDAG::setGraphAttrs(const SDNode *N, const char *Attrs) {
 #ifndef NDEBUG
   NodeGraphAttrs[N] = Attrs;
 #else
-  cerr << "SelectionDAG::setGraphAttrs is only available in debug builds"
-       << " on systems with Graphviz or gv!\n";
+  errs() << "SelectionDAG::setGraphAttrs is only available in debug builds"
+         << " on systems with Graphviz or gv!\n";
 #endif
 }
 
@@ -188,8 +188,8 @@ const std::string SelectionDAG::getGraphAttrs(const SDNode *N) const {
   else
     return "";
 #else
-  cerr << "SelectionDAG::getGraphAttrs is only available in debug builds"
-       << " on systems with Graphviz or gv!\n";
+  errs() << "SelectionDAG::getGraphAttrs is only available in debug builds"
+         << " on systems with Graphviz or gv!\n";
   return std::string("");
 #endif
 }
@@ -200,8 +200,8 @@ void SelectionDAG::setGraphColor(const SDNode *N, const char *Color) {
 #ifndef NDEBUG
   NodeGraphAttrs[N] = std::string("color=") + Color;
 #else
-  cerr << "SelectionDAG::setGraphColor is only available in debug builds"
-       << " on systems with Graphviz or gv!\n";
+  errs() << "SelectionDAG::setGraphColor is only available in debug builds"
+         << " on systems with Graphviz or gv!\n";
 #endif
 }
 
@@ -232,8 +232,8 @@ bool SelectionDAG::setSubgraphColorHelper(SDNode *N, const char *Color, DenseSet
     }
   }
 #else
-  cerr << "SelectionDAG::setSubgraphColor is only available in debug builds"
-       << " on systems with Graphviz or gv!\n";
+  errs() << "SelectionDAG::setSubgraphColor is only available in debug builds"
+         << " on systems with Graphviz or gv!\n";
 #endif
   return hit_limit;
 }
@@ -255,8 +255,8 @@ void SelectionDAG::setSubgraphColor(SDNode *N, const char *Color) {
   }
 
 #else
-  cerr << "SelectionDAG::setSubgraphColor is only available in debug builds"
-       << " on systems with Graphviz or gv!\n";
+  errs() << "SelectionDAG::setSubgraphColor is only available in debug builds"
+         << " on systems with Graphviz or gv!\n";
 #endif
 }
 
index 806a6559df955d0d2dd332788b64d74415605037..71ff411def2b018907ac8e7ae9455f2145e7828f 100644 (file)
 #include "llvm/Support/Debug.h"
 using namespace llvm;
 
+// All Debug.h functionality is a no-op in NDEBUG mode.
+#ifndef NDEBUG
 bool llvm::DebugFlag;  // DebugFlag - Exported boolean set by the -debug option
 
-#ifndef NDEBUG
 // -debug - Command line option to enable the DEBUG statements in the passes.
 // This flag may only be enabled in debug builds.
 static cl::opt<bool, true>
@@ -48,16 +49,15 @@ static cl::opt<DebugOnlyOpt, true, cl::parser<std::string> >
 DebugOnly("debug-only", cl::desc("Enable a specific type of debug output"),
           cl::Hidden, cl::value_desc("debug string"),
           cl::location(DebugOnlyOptLoc), cl::ValueRequired);
-#endif
 
 // isCurrentDebugType - Return true if the specified string is the debug type
 // specified on the command line, or if none was specified on the command line
 // with the -debug-only=X option.
 //
 bool llvm::isCurrentDebugType(const char *DebugType) {
-#ifndef NDEBUG
   return CurrentDebugType.empty() || DebugType == CurrentDebugType;
+}
 #else
-  return false;
+// Avoid "has no symbols" warning.
+int Debug_dummy = 0;
 #endif
-}
index 71d76845adb31e396fe3f3571b6abf6d27db9509..7a34c6fcb0055eddfc16b2651937d059e4a3504f 100644 (file)
@@ -130,7 +130,7 @@ void MSP430DAGToDAGISel::InstructionSelect() {
 
   // Codegen the basic block.
   DEBUG(errs() << "===== Instruction selection begins:\n");
-  Indent = 0;
+  DEBUG(Indent = 0);
   SelectRoot(*CurDAG);
   DEBUG(errs() << "===== Instruction selection ends:\n");
 
@@ -145,14 +145,14 @@ SDNode *MSP430DAGToDAGISel::Select(SDValue Op) {
   DEBUG(errs().indent(Indent) << "Selecting: ");
   DEBUG(Node->dump(CurDAG));
   DEBUG(errs() << "\n");
-  Indent += 2;
+  DEBUG(Indent += 2);
 
   // If we have a custom node, we already have selected!
   if (Node->isMachineOpcode()) {
     DEBUG(errs().indent(Indent-2) << "== ";
           Node->dump(CurDAG);
           errs() << "\n");
-    Indent -= 2;
+    DEBUG(Indent -= 2);
     return NULL;
   }
 
@@ -180,7 +180,7 @@ SDNode *MSP430DAGToDAGISel::Select(SDValue Op) {
   else
     DEBUG(ResNode->dump(CurDAG));
   DEBUG(errs() << "\n");
-  Indent -= 2;
+  DEBUG(Indent -= 2);
 
   return ResNode;
 }
index d0641a19d718a852a36f8b8ddbc02c56ebb7276c..ca72ff03dc7c37546e1dbc9a88102a2a1294cdd9 100644 (file)
@@ -112,7 +112,7 @@ void MipsDAGToDAGISel::InstructionSelect() {
   DEBUG(BB->dump());
   // Codegen the basic block.
   DEBUG(errs() << "===== Instruction selection begins:\n");
-  Indent = 0;
+  DEBUG(Indent = 0);
 
   // Select target instructions for the DAG.
   SelectRoot(*CurDAG);
@@ -190,14 +190,14 @@ SDNode* MipsDAGToDAGISel::Select(SDValue N) {
   DEBUG(errs().indent(Indent) << "Selecting: ";
         Node->dump(CurDAG);
         errs() << "\n");
-  Indent += 2;
+  DEBUG(Indent += 2);
 
   // If we have a custom node, we already have selected!
   if (Node->isMachineOpcode()) {
     DEBUG(errs().indent(Indent-2) << "== ";
           Node->dump(CurDAG);
           errs() << "\n");
-    Indent -= 2;
+    DEBUG(Indent -= 2);
     return NULL;
   }
 
@@ -367,7 +367,7 @@ SDNode* MipsDAGToDAGISel::Select(SDValue N) {
   else
     DEBUG(ResNode->dump(CurDAG));
   DEBUG(errs() << "\n");
-  Indent -= 2;
+  DEBUG(Indent -= 2);
 
   return ResNode;
 }
index c31e7ddf05896607d3cab45cb7450ff9bd326ad4..6af2f610897f3cbb8ded659dce370404fb4f7b6c 100644 (file)
@@ -607,7 +607,7 @@ void SystemZDAGToDAGISel::InstructionSelect() {
 
   // Codegen the basic block.
   DEBUG(errs() << "===== Instruction selection begins:\n");
-  Indent = 0;
+  DEBUG(Indent = 0);
   SelectRoot(*CurDAG);
   DEBUG(errs() << "===== Instruction selection ends:\n");
 
@@ -624,14 +624,14 @@ SDNode *SystemZDAGToDAGISel::Select(SDValue Op) {
   DEBUG(errs().indent(Indent) << "Selecting: ";
         Node->dump(CurDAG);
         errs() << "\n");
-  Indent += 2;
+  DEBUG(Indent += 2);
 
   // If we have a custom node, we already have selected!
   if (Node->isMachineOpcode()) {
     DEBUG(errs().indent(Indent-2) << "== ";
           Node->dump(CurDAG);
           errs() << "\n");
-    Indent -= 2;
+    DEBUG(Indent -= 2);
     return NULL; // Already selected.
   }
 
@@ -822,7 +822,7 @@ SDNode *SystemZDAGToDAGISel::Select(SDValue Op) {
           ResNode->dump(CurDAG);
         errs() << "\n";
         );
-  Indent -= 2;
+  DEBUG(Indent -= 2);
 
   return ResNode;
 }