diff options
Diffstat (limited to 'include/llvm/IR/RemarkStreamer.h')
-rw-r--r-- | include/llvm/IR/RemarkStreamer.h | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/include/llvm/IR/RemarkStreamer.h b/include/llvm/IR/RemarkStreamer.h index f34cc660b2fb..2abf6f99cb08 100644 --- a/include/llvm/IR/RemarkStreamer.h +++ b/include/llvm/IR/RemarkStreamer.h @@ -25,12 +25,12 @@ namespace llvm { /// Streamer for remarks. class RemarkStreamer { - /// The filename that the remark diagnostics are emitted to. - const std::string Filename; /// The regex used to filter remarks based on the passes that emit them. Optional<Regex> PassFilter; /// The object used to serialize the remarks to a specific format. - std::unique_ptr<remarks::Serializer> Serializer; + std::unique_ptr<remarks::RemarkSerializer> RemarkSerializer; + /// The filename that the remark diagnostics are emitted to. + const Optional<std::string> Filename; /// Convert diagnostics into remark objects. /// The lifetime of the members of the result is bound to the lifetime of @@ -38,14 +38,16 @@ class RemarkStreamer { remarks::Remark toRemark(const DiagnosticInfoOptimizationBase &Diag); public: - RemarkStreamer(StringRef Filename, - std::unique_ptr<remarks::Serializer> Serializer); + RemarkStreamer(std::unique_ptr<remarks::RemarkSerializer> RemarkSerializer, + Optional<StringRef> Filename = None); /// Return the filename that the remark diagnostics are emitted to. - StringRef getFilename() const { return Filename; } + Optional<StringRef> getFilename() const { + return Filename ? Optional<StringRef>(*Filename) : None; + } /// Return stream that the remark diagnostics are emitted to. - raw_ostream &getStream() { return Serializer->OS; } + raw_ostream &getStream() { return RemarkSerializer->OS; } /// Return the serializer used for this stream. - remarks::Serializer &getSerializer() { return *Serializer; } + remarks::RemarkSerializer &getSerializer() { return *RemarkSerializer; } /// Set a pass filter based on a regex \p Filter. /// Returns an error if the regex is invalid. Error setFilter(StringRef Filter); @@ -84,13 +86,21 @@ struct RemarkSetupFormatError : RemarkSetupErrorInfo<RemarkSetupFormatError> { using RemarkSetupErrorInfo<RemarkSetupFormatError>::RemarkSetupErrorInfo; }; -/// Setup optimization remarks. +/// Setup optimization remarks that output to a file. Expected<std::unique_ptr<ToolOutputFile>> setupOptimizationRemarks(LLVMContext &Context, StringRef RemarksFilename, StringRef RemarksPasses, StringRef RemarksFormat, bool RemarksWithHotness, unsigned RemarksHotnessThreshold = 0); +/// Setup optimization remarks that output directly to a raw_ostream. +/// \p OS is managed by the caller and should be open for writing as long as \p +/// Context is streaming remarks to it. +Error setupOptimizationRemarks(LLVMContext &Context, raw_ostream &OS, + StringRef RemarksPasses, StringRef RemarksFormat, + bool RemarksWithHotness, + unsigned RemarksHotnessThreshold = 0); + } // end namespace llvm #endif // LLVM_IR_REMARKSTREAMER_H |