Remove operator<< from HGraph.

It needs access to a code generator.

Test: observe a bogus graph at the point of register allocator, and see
that the Dump method crashes.

Change-Id: I09a847246428fd3bd0938f9f457773c465da253d
diff --git a/compiler/optimizing/nodes.cc b/compiler/optimizing/nodes.cc
index 2478693..00bfc92 100644
--- a/compiler/optimizing/nodes.cc
+++ b/compiler/optimizing/nodes.cc
@@ -2014,8 +2014,9 @@
 }
 
 std::ostream& HGraph::Dump(std::ostream& os,
+                           CodeGenerator* codegen,
                            std::optional<std::reference_wrapper<const BlockNamer>> namer) {
-  HGraphVisualizer vis(&os, this, nullptr, namer);
+  HGraphVisualizer vis(&os, this, codegen, namer);
   vis.DumpGraphDebug();
   return os;
 }
diff --git a/compiler/optimizing/nodes.h b/compiler/optimizing/nodes.h
index c00ac4e..fd3a275 100644
--- a/compiler/optimizing/nodes.h
+++ b/compiler/optimizing/nodes.h
@@ -54,6 +54,7 @@
 namespace art {
 
 class ArenaStack;
+class CodeGenerator;
 class GraphChecker;
 class HBasicBlock;
 class HConstructorFence;
@@ -427,6 +428,7 @@
   }
 
   std::ostream& Dump(std::ostream& os,
+                     CodeGenerator* codegen,
                      std::optional<std::reference_wrapper<const BlockNamer>> namer = std::nullopt);
 
   ArenaAllocator* GetAllocator() const { return allocator_; }
@@ -893,10 +895,6 @@
   DISALLOW_COPY_AND_ASSIGN(HGraph);
 };
 
-inline std::ostream& operator<<(std::ostream& os, HGraph& graph) {
-  return graph.Dump(os);
-}
-
 class HLoopInformation : public ArenaObject<kArenaAllocLoopInfo> {
  public:
   HLoopInformation(HBasicBlock* header, HGraph* graph)
diff --git a/compiler/optimizing/optimizing_compiler.cc b/compiler/optimizing/optimizing_compiler.cc
index 18e0512..cb40a51 100644
--- a/compiler/optimizing/optimizing_compiler.cc
+++ b/compiler/optimizing/optimizing_compiler.cc
@@ -191,8 +191,10 @@
         GraphChecker checker(graph_, codegen_);
         last_seen_graph_size_ = checker.Run(pass_change, last_seen_graph_size_);
         if (!checker.IsValid()) {
+          std::ostringstream stream;
+          graph_->Dump(stream, codegen_);
           LOG(FATAL_WITHOUT_ABORT) << "Error after " << pass_name << "(" << graph_->PrettyMethod()
-                                   << "): " << *graph_;
+                                   << "): " << stream.str();
           LOG(FATAL) << "(" << pass_name <<  "): " << Dumpable<GraphChecker>(checker);
         }
       }
diff --git a/compiler/optimizing/optimizing_unit_test.h b/compiler/optimizing/optimizing_unit_test.h
index 6600ff3..e836880 100644
--- a/compiler/optimizing/optimizing_unit_test.h
+++ b/compiler/optimizing/optimizing_unit_test.h
@@ -203,7 +203,7 @@
       const AdjacencyListGraph& alg_;
     };
     Namer namer(*this);
-    return graph_->Dump(os, namer);
+    return graph_->Dump(os, /* codegen_= */ nullptr, namer);
   }
 
  private: