Add opt remarks to Generic Specializer pass

Adds a combined API to output both debug message and optimization remarks.

The previously added test partial_specialization_debug.sil ensures that it's an
NFC for debug output.
This commit is contained in:
Adam Nemet
2017-11-10 11:35:03 -08:00
parent 7ba352c4d7
commit bd8764caaa
7 changed files with 231 additions and 19 deletions

View File

@@ -63,6 +63,20 @@ template <typename DerivedT> std::string Remark<DerivedT>::getMsg() const {
return OS.str();
}
template <typename DerivedT> std::string Remark<DerivedT>::getDebugMsg() const {
std::string Str;
llvm::raw_string_ostream OS(Str);
if (IndentDebugWidth)
OS << std::string(" ", IndentDebugWidth);
for (const Argument &Arg : Args)
OS << Arg.Val;
OS << "\n";
return OS.str();
}
Emitter::Emitter(StringRef PassName, SILModule &M)
: Module(M), PassName(PassName),
PassedEnabled(
@@ -94,6 +108,14 @@ void Emitter::emit(const RemarkMissed &R) {
emitRemark(Module, R, diag::opt_remark_missed, isEnabled<RemarkMissed>());
}
void Emitter::emitDebug(const RemarkPassed &R) {
llvm::dbgs() << R.getDebugMsg();
}
void Emitter::emitDebug(const RemarkMissed &R) {
llvm::dbgs() << R.getDebugMsg();
}
namespace llvm {
namespace yaml {