diff --git a/llvm/include/llvm/ExecutionEngine/Orc/JITTargetMachineBuilder.h b/llvm/include/llvm/ExecutionEngine/Orc/JITTargetMachineBuilder.h index c4109a8de82e..e3cfbfe421fa 100644 --- a/llvm/include/llvm/ExecutionEngine/Orc/JITTargetMachineBuilder.h +++ b/llvm/include/llvm/ExecutionEngine/Orc/JITTargetMachineBuilder.h @@ -32,6 +32,9 @@ namespace orc { /// 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 @@ public: /// 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 @@ private: 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/llvm/lib/ExecutionEngine/Orc/JITTargetMachineBuilder.cpp b/llvm/lib/ExecutionEngine/Orc/JITTargetMachineBuilder.cpp index 8cf66c9e759a..4257137a2212 100644 --- a/llvm/lib/ExecutionEngine/Orc/JITTargetMachineBuilder.cpp +++ b/llvm/lib/ExecutionEngine/Orc/JITTargetMachineBuilder.cpp @@ -65,9 +65,13 @@ JITTargetMachineBuilder &JITTargetMachineBuilder::addFeatures( } #ifndef NDEBUG -raw_ostream &operator<<(raw_ostream &OS, const JITTargetMachineBuilder &JTMB) { - OS << "{ Triple = \"" << JTMB.TT.str() << "\", CPU = \"" << JTMB.CPU - << "\", Options = , 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 = \n" + << Indent << " Relocation Model = "; if (JTMB.RM) { switch (*JTMB.RM) { @@ -91,9 +95,10 @@ raw_ostream &operator<<(raw_ostream &OS, const JITTargetMachineBuilder &JTMB) { 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 @@ raw_ostream &operator<<(raw_ostream &OS, const JITTargetMachineBuilder &JTMB) { 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 @@ raw_ostream &operator<<(raw_ostream &OS, const JITTargetMachineBuilder &JTMB) { break; } - OS << " }"; - return OS; + OS << "\n" << Indent << "}\n"; } #endif // NDEBUG diff --git a/llvm/lib/ExecutionEngine/Orc/LLJIT.cpp b/llvm/lib/ExecutionEngine/Orc/LLJIT.cpp index c368c1e37134..fb6d87a51402 100644 --- a/llvm/lib/ExecutionEngine/Orc/LLJIT.cpp +++ b/llvm/lib/ExecutionEngine/Orc/LLJIT.cpp @@ -922,7 +922,8 @@ Error LLJITBuilderState::prepareForConstruction() { } LLVM_DEBUG({ - dbgs() << " JITTargetMachineBuilder is " << JTMB << "\n" + dbgs() << " JITTargetMachineBuilder is " + << JITTargetMachineBuilderPrinter(*JTMB, " ") << " Pre-constructed ExecutionSession: " << (ES ? "Yes" : "No") << "\n" << " DataLayout: ";