[ORC] Print CPU feature string in JITTargetMachineBuilder debugging output.

GitOrigin-RevId: 0469256d35e7dce12db1ff479bac9946c344d31f
diff --git a/include/llvm/ExecutionEngine/Orc/JITTargetMachineBuilder.h b/include/llvm/ExecutionEngine/Orc/JITTargetMachineBuilder.h
index c4109a8..e3cfbfe 100644
--- a/include/llvm/ExecutionEngine/Orc/JITTargetMachineBuilder.h
+++ b/include/llvm/ExecutionEngine/Orc/JITTargetMachineBuilder.h
@@ -32,6 +32,9 @@
 
 /// A utility class for building TargetMachines for JITs.
 class JITTargetMachineBuilder {
+#ifndef NDEBUG
+  friend class JITTargetMachineBuilderPrinter;
+#endif
 public:
   /// Create a JITTargetMachineBuilder based on the given triple.
   ///
@@ -139,12 +142,6 @@
   /// Access Triple.
   const Triple &getTargetTriple() const { return TT; }
 
-#ifndef NDEBUG
-  /// Debug-dump a JITTargetMachineBuilder.
-  friend raw_ostream &operator<<(raw_ostream &OS,
-                                 const JITTargetMachineBuilder &JTMB);
-#endif
-
 private:
   Triple TT;
   std::string CPU;
@@ -155,6 +152,26 @@
   CodeGenOpt::Level OptLevel = CodeGenOpt::Default;
 };
 
+#ifndef NDEBUG
+class JITTargetMachineBuilderPrinter {
+public:
+  JITTargetMachineBuilderPrinter(JITTargetMachineBuilder &JTMB,
+                                 StringRef Indent)
+      : JTMB(JTMB), Indent(Indent) {}
+  void print(raw_ostream &OS) const;
+
+  friend raw_ostream &operator<<(raw_ostream &OS,
+                                 const JITTargetMachineBuilderPrinter &JTMBP) {
+    JTMBP.print(OS);
+    return OS;
+  }
+
+private:
+  JITTargetMachineBuilder &JTMB;
+  StringRef Indent;
+};
+#endif // NDEBUG
+
 } // end namespace orc
 } // end namespace llvm
 
diff --git a/lib/ExecutionEngine/Orc/JITTargetMachineBuilder.cpp b/lib/ExecutionEngine/Orc/JITTargetMachineBuilder.cpp
index 8cf66c9..4257137 100644
--- a/lib/ExecutionEngine/Orc/JITTargetMachineBuilder.cpp
+++ b/lib/ExecutionEngine/Orc/JITTargetMachineBuilder.cpp
@@ -65,9 +65,13 @@
 }
 
 #ifndef NDEBUG
-raw_ostream &operator<<(raw_ostream &OS, const JITTargetMachineBuilder &JTMB) {
-  OS << "{ Triple = \"" << JTMB.TT.str() << "\", CPU = \"" << JTMB.CPU
-     << "\", Options = <not-printable>, Relocation Model = ";
+void JITTargetMachineBuilderPrinter::print(raw_ostream &OS) const {
+  OS << Indent << "{\n"
+     << Indent << "  Triple = \"" << JTMB.TT.str() << "\"\n"
+     << Indent << "  CPU = \"" << JTMB.CPU << "\"\n"
+     << Indent << "  Features = \"" << JTMB.Features.getString() << "\"\n"
+     << Indent << "  Options = <not-printable>\n"
+     << Indent << "  Relocation Model = ";
 
   if (JTMB.RM) {
     switch (*JTMB.RM) {
@@ -91,9 +95,10 @@
       break;
     }
   } else
-    OS << "unspecified";
+    OS << "unspecified (will use target default)";
 
-  OS << ", Code Model = ";
+  OS << "\n"
+     << Indent << "  Code Model = ";
 
   if (JTMB.CM) {
     switch (*JTMB.CM) {
@@ -114,9 +119,10 @@
       break;
     }
   } else
-    OS << "unspecified";
+    OS << "unspecified (will use target default)";
 
-  OS << ", Optimization Level = ";
+  OS << "\n"
+     << Indent << "  Optimization Level = ";
   switch (JTMB.OptLevel) {
   case CodeGenOpt::None:
     OS << "None";
@@ -132,8 +138,7 @@
     break;
   }
 
-  OS << " }";
-  return OS;
+  OS << "\n" << Indent << "}\n";
 }
 #endif // NDEBUG
 
diff --git a/lib/ExecutionEngine/Orc/LLJIT.cpp b/lib/ExecutionEngine/Orc/LLJIT.cpp
index c368c1e..fb6d87a 100644
--- a/lib/ExecutionEngine/Orc/LLJIT.cpp
+++ b/lib/ExecutionEngine/Orc/LLJIT.cpp
@@ -922,7 +922,8 @@
   }
 
   LLVM_DEBUG({
-    dbgs() << "  JITTargetMachineBuilder is " << JTMB << "\n"
+    dbgs() << "  JITTargetMachineBuilder is "
+           << JITTargetMachineBuilderPrinter(*JTMB, "  ")
            << "  Pre-constructed ExecutionSession: " << (ES ? "Yes" : "No")
            << "\n"
            << "  DataLayout: ";