MLIR 24.0.0git
mlir::remark Namespace Reference

Namespaces

namespace  detail

Classes

class  LLVMToMLIRDiagnosticHandler
 Diagnostic handler forwarding LLVM diagnostics to MLIR. More...
struct  RemarkCategories
 Define an the set of categories to accept. More...
class  RemarkEmittingPolicyAll
 Policy that emits all remarks. More...
class  RemarkEmittingPolicyFinal
 Policy that emits only the last remark reported for each identity, see DenseMapInfo<Remark>. More...
class  RemarkId
 A unique identifier for a remark, used to link related remarks together. More...
struct  RemarkOpts
 Options to create a Remark. More...

Enumerations

enum class  RemarkKind {
  RemarkUnknown = 0 , RemarkPassed , RemarkMissed , RemarkFailure ,
  RemarkAnalysis
}
 Categories describe the outcome of an transformation, not the mechanics of emitting/serializing remarks. More...

Functions

llvm::raw_ostream & operator<< (llvm::raw_ostream &os, RemarkId id)
template<class... Ts>
detail::LazyTextBuild reason (const char *fmt, Ts &&...ts)
 Create a Reason with llvm::formatv formatting.
template<class... Ts>
detail::LazyTextBuild suggest (const char *fmt, Ts &&...ts)
 Create a Suggestion with llvm::formatv formatting.
template<class... Ts>
detail::LazyTextBuild add (const char *fmt, Ts &&...ts)
 Create a Remark with llvm::formatv formatting.
template<class V>
detail::LazyTextBuild metric (StringRef key, V &&v)
detail::InFlightRemark passed (Location loc, RemarkOpts opts)
 Report an optimization remark that was passed.
detail::InFlightRemark missed (Location loc, RemarkOpts opts)
 Report an optimization remark that was missed.
detail::InFlightRemark failed (Location loc, RemarkOpts opts)
 Report an optimization remark that failed.
detail::InFlightRemark analysis (Location loc, RemarkOpts opts)
 Report an optimization analysis remark.
LogicalResult enableOptimizationRemarks (MLIRContext &ctx, std::unique_ptr< remark::detail::MLIRRemarkStreamerBase > streamer, std::unique_ptr< remark::detail::RemarkEmittingPolicyBase > remarkEmittingPolicy, const remark::RemarkCategories &cats, bool printAsEmitRemarks=false)
 Setup remarks for the context.
LogicalResult importLLVMRemarks (Operation *anchor, StringRef buffer, llvm::remarks::Format format)
 Parses buffer, a serialized LLVM remark file, and reports its remarks into the remark engine of the context of anchor, the operation the remarks refer to.
LogicalResult enableOptimizationRemarksWithLLVMStreamer (MLIRContext &ctx, StringRef filePath, llvm::remarks::Format fmt, std::unique_ptr< detail::RemarkEmittingPolicyBase > remarkEmittingPolicy, const RemarkCategories &cat, bool printAsEmitRemarks=false)
 Enable optimization remarks to a file with the given path and format.

Variables

constexpr llvm::StringLiteral llvmRemarkCategoryPrefix = "llvm-"
 Prefix of the category of remarks imported from LLVM.

Enumeration Type Documentation

◆ RemarkKind

enum class mlir::remark::RemarkKind
strong

Categories describe the outcome of an transformation, not the mechanics of emitting/serializing remarks.

Enumerator
RemarkUnknown 
RemarkPassed 

An optimization was applied.

RemarkMissed 

A profitable optimization opportunity was found but not applied.

RemarkFailure 

The compiler attempted the optimization but failed (e.g., legality checks, or better opportunites).

RemarkAnalysis 

Informational context (e.g., analysis numbers) without a pass/fail outcome.

Definition at line 70 of file Remarks.h.

Function Documentation

◆ add()

template<class... Ts>
detail::LazyTextBuild mlir::remark::add ( const char * fmt,
Ts &&... ts )
inline

Create a Remark with llvm::formatv formatting.

Definition at line 704 of file Remarks.h.

◆ analysis()

detail::InFlightRemark mlir::remark::analysis ( Location loc,
RemarkOpts opts )
inline

Report an optimization analysis remark.

Definition at line 739 of file Remarks.h.

References mlir::remark::detail::RemarkEngine::emitOptimizationRemarkAnalysis().

◆ enableOptimizationRemarks()

LogicalResult mlir::remark::enableOptimizationRemarks ( MLIRContext & ctx,
std::unique_ptr< remark::detail::MLIRRemarkStreamerBase > streamer,
std::unique_ptr< remark::detail::RemarkEmittingPolicyBase > remarkEmittingPolicy,
const remark::RemarkCategories & cats,
bool printAsEmitRemarks = false )

Setup remarks for the context.

This function will enable the remark engine and set the streamer to be used for optimization remarks. The remark categories are used to filter the remarks that will be emitted by the remark engine. If a category is not specified, it will not be emitted. If printAsEmitRemarks is true, the remarks will be printed as mlir::emitRemarks. 'streamer' must inherit from MLIRRemarkStreamerBase and will be used to stream the remarks.

Referenced by enableOptimizationRemarksWithLLVMStreamer(), and performActions().

◆ enableOptimizationRemarksWithLLVMStreamer()

LogicalResult mlir::remark::enableOptimizationRemarksWithLLVMStreamer ( MLIRContext & ctx,
StringRef filePath,
llvm::remarks::Format fmt,
std::unique_ptr< detail::RemarkEmittingPolicyBase > remarkEmittingPolicy,
const RemarkCategories & cat,
bool printAsEmitRemarks = false )

Enable optimization remarks to a file with the given path and format.

The remark categories are used to filter the remarks that are emitted. If the printAsEmitRemarks flag is set, remarks will also be printed using mlir::emitRemarks.

Definition at line 61 of file RemarkStreamer.cpp.

References mlir::remark::detail::LLVMRemarkStreamer::createToFile(), enableOptimizationRemarks(), and failed().

Referenced by performActions().

◆ failed()

detail::InFlightRemark mlir::remark::failed ( Location loc,
RemarkOpts opts )
inline

Report an optimization remark that failed.

Definition at line 733 of file Remarks.h.

References mlir::remark::detail::RemarkEngine::emitOptimizationRemarkFailure().

Referenced by enableOptimizationRemarksWithLLVMStreamer().

◆ importLLVMRemarks()

LogicalResult mlir::remark::importLLVMRemarks ( Operation * anchor,
StringRef buffer,
llvm::remarks::Format format )

Parses buffer, a serialized LLVM remark file, and reports its remarks into the remark engine of the context of anchor, the operation the remarks refer to.

The category is the prefixed LLVM pass name, the LLVM remark name becomes the remark name and the message is stored under the "Remark" argument. A remark is attached to its debug location if it has one, otherwise to the symbol named after its LLVM function inside anchor, otherwise to anchor. Fails if the buffer cannot be parsed.

Definition at line 205 of file LLVMRemarkImport.cpp.

References mlir::Operation::getContext(), mlir::MLIRContext::getRemarkEngine(), importLLVMRemark(), resolveLocation(), and success().

◆ metric()

template<class V>
detail::LazyTextBuild mlir::remark::metric ( StringRef key,
V && v )
inline

Definition at line 709 of file Remarks.h.

References mlir::remark::detail::Remark::Arg::val.

◆ missed()

detail::InFlightRemark mlir::remark::missed ( Location loc,
RemarkOpts opts )
inline

Report an optimization remark that was missed.

Definition at line 727 of file Remarks.h.

References mlir::remark::detail::RemarkEngine::emitOptimizationRemarkMiss().

◆ operator<<()

llvm::raw_ostream & mlir::remark::operator<< ( llvm::raw_ostream & os,
RemarkId id )
inline

Definition at line 57 of file Remarks.h.

◆ passed()

detail::InFlightRemark mlir::remark::passed ( Location loc,
RemarkOpts opts )
inline

Report an optimization remark that was passed.

Definition at line 722 of file Remarks.h.

References mlir::remark::detail::RemarkEngine::emitOptimizationRemark().

◆ reason()

template<class... Ts>
detail::LazyTextBuild mlir::remark::reason ( const char * fmt,
Ts &&... ts )
inline

Create a Reason with llvm::formatv formatting.

Definition at line 692 of file Remarks.h.

◆ suggest()

template<class... Ts>
detail::LazyTextBuild mlir::remark::suggest ( const char * fmt,
Ts &&... ts )
inline

Create a Suggestion with llvm::formatv formatting.

Definition at line 698 of file Remarks.h.

Variable Documentation

◆ llvmRemarkCategoryPrefix

llvm::StringLiteral mlir::remark::llvmRemarkCategoryPrefix = "llvm-"
constexpr

Prefix of the category of remarks imported from LLVM.

The category is the prefix followed by the LLVM pass name, e.g. llvm-inline, so that remark filters can select LLVM remarks (llvm-.*) or a single LLVM pass.

Definition at line 31 of file LLVMRemarkImport.h.

Referenced by getCategory().