LLVM 19.0.0git
Classes | Public Member Functions | Static Public Member Functions | Protected Attributes | List of all members
llvm::DiagnosticInfoOptimizationBase Class Referenceabstract

Common features for diagnostics dealing with optimization remarks that are used by both IR and MIR passes. More...

#include "llvm/IR/DiagnosticInfo.h"

Inheritance diagram for llvm::DiagnosticInfoOptimizationBase:
Inheritance graph
[legend]

Classes

struct  Argument
 Used in the streaming interface as the general argument type. More...
 
struct  setExtraArgs
 When an instance of this is inserted into the stream, the arguments following will not appear in the remark printed in the compiler output (-Rpass) but only in the optimization record file (-fsave-optimization-record). More...
 
struct  setIsVerbose
 Used to set IsVerbose via the stream interface. More...
 

Public Member Functions

 DiagnosticInfoOptimizationBase (enum DiagnosticKind Kind, enum DiagnosticSeverity Severity, const char *PassName, StringRef RemarkName, const Function &Fn, const DiagnosticLocation &Loc)
 PassName is the name of the pass emitting this diagnostic.
 
void insert (StringRef S)
 
void insert (Argument A)
 
void insert (setIsVerbose V)
 
void insert (setExtraArgs EA)
 
void print (DiagnosticPrinter &DP) const override
 
virtual bool isEnabled () const =0
 Return true if this optimization remark is enabled by one of of the LLVM command line flags (-pass-remarks, -pass-remarks-missed, or -pass-remarks-analysis).
 
StringRef getPassName () const
 
StringRef getRemarkName () const
 
std::string getMsg () const
 
std::optional< uint64_tgetHotness () const
 
void setHotness (std::optional< uint64_t > H)
 
bool isVerbose () const
 
ArrayRef< ArgumentgetArgs () const
 
bool isPassed () const
 
bool isMissed () const
 
bool isAnalysis () const
 
- Public Member Functions inherited from llvm::DiagnosticInfoWithLocationBase
 DiagnosticInfoWithLocationBase (enum DiagnosticKind Kind, enum DiagnosticSeverity Severity, const Function &Fn, const DiagnosticLocation &Loc)
 Fn is the function where the diagnostic is being emitted.
 
bool isLocationAvailable () const
 Return true if location information is available for this diagnostic.
 
std::string getLocationStr () const
 Return a string with the location information for this diagnostic in the format "file:line:col".
 
void getLocation (StringRef &RelativePath, unsigned &Line, unsigned &Column) const
 Return location information for this diagnostic in three parts: the relative source file path, line number and column.
 
std::string getAbsolutePath () const
 Return the absolute path tot the file.
 
const FunctiongetFunction () const
 
DiagnosticLocation getLocation () const
 
- Public Member Functions inherited from llvm::DiagnosticInfo
 DiagnosticInfo (int Kind, DiagnosticSeverity Severity)
 
virtual ~DiagnosticInfo ()=default
 
int getKind () const
 
DiagnosticSeverity getSeverity () const
 
virtual void print (DiagnosticPrinter &DP) const =0
 Print using the given DP a user-friendly message.
 

Static Public Member Functions

static bool classof (const DiagnosticInfo *DI)
 

Protected Attributes

const charPassName
 Name of the pass that triggers this report.
 
StringRef RemarkName
 Textual identifier for the remark (single-word, camel-case).
 
std::optional< uint64_tHotness
 If profile information is available, this is the number of times the corresponding code was executed in a profile instrumentation run.
 
SmallVector< Argument, 4 > Args
 Arguments collected via the streaming interface.
 
bool IsVerbose = false
 The remark is expected to be noisy.
 
int FirstExtraArgIndex = -1
 If positive, the index of the first argument that only appear in the optimization records and not in the remark printed in the compiler output.
 

Detailed Description

Common features for diagnostics dealing with optimization remarks that are used by both IR and MIR passes.

Definition at line 413 of file DiagnosticInfo.h.

Constructor & Destructor Documentation

◆ DiagnosticInfoOptimizationBase()

llvm::DiagnosticInfoOptimizationBase::DiagnosticInfoOptimizationBase ( enum DiagnosticKind  Kind,
enum DiagnosticSeverity  Severity,
const char PassName,
StringRef  RemarkName,
const Function Fn,
const DiagnosticLocation Loc 
)
inline

PassName is the name of the pass emitting this diagnostic.

RemarkName is a textual identifier for the remark (single-word, camel-case). Fn is the function where the diagnostic is being emitted. Loc is the location information to use in the diagnostic. If line table information is available, the diagnostic will include the source code location.

Definition at line 456 of file DiagnosticInfo.h.

Member Function Documentation

◆ classof()

static bool llvm::DiagnosticInfoOptimizationBase::classof ( const DiagnosticInfo DI)
inlinestatic

◆ getArgs()

ArrayRef< Argument > llvm::DiagnosticInfoOptimizationBase::getArgs ( ) const
inline

Definition at line 487 of file DiagnosticInfo.h.

References Args.

◆ getHotness()

std::optional< uint64_t > llvm::DiagnosticInfoOptimizationBase::getHotness ( ) const
inline

Definition at line 482 of file DiagnosticInfo.h.

References Hotness.

Referenced by llvm::OptimizationRemarkEmitter::emit().

◆ getMsg()

std::string DiagnosticInfoOptimizationBase::getMsg ( ) const

Definition at line 394 of file DiagnosticInfo.cpp.

References Args, FirstExtraArgIndex, llvm::make_range(), and OS.

Referenced by EmitAndPrintRemark(), and print().

◆ getPassName()

StringRef llvm::DiagnosticInfoOptimizationBase::getPassName ( ) const
inline

◆ getRemarkName()

StringRef llvm::DiagnosticInfoOptimizationBase::getRemarkName ( ) const
inline

Definition at line 480 of file DiagnosticInfo.h.

References RemarkName.

◆ insert() [1/4]

void DiagnosticInfoOptimizationBase::insert ( Argument  A)

Definition at line 382 of file DiagnosticInfo.cpp.

References A, and Args.

◆ insert() [2/4]

void DiagnosticInfoOptimizationBase::insert ( setExtraArgs  EA)

Definition at line 390 of file DiagnosticInfo.cpp.

References Args, and FirstExtraArgIndex.

◆ insert() [3/4]

void DiagnosticInfoOptimizationBase::insert ( setIsVerbose  V)

Definition at line 386 of file DiagnosticInfo.cpp.

References IsVerbose.

◆ insert() [4/4]

void DiagnosticInfoOptimizationBase::insert ( StringRef  S)

Definition at line 378 of file DiagnosticInfo.cpp.

References Args.

◆ isAnalysis()

bool llvm::DiagnosticInfoOptimizationBase::isAnalysis ( ) const
inline

◆ isEnabled()

virtual bool llvm::DiagnosticInfoOptimizationBase::isEnabled ( ) const
pure virtual

Return true if this optimization remark is enabled by one of of the LLVM command line flags (-pass-remarks, -pass-remarks-missed, or -pass-remarks-analysis).

Note that this only handles the LLVM flags. We cannot access Clang flags from here (they are handled in BackendConsumer::OptimizationRemarkHandler).

Implemented in llvm::MachineOptimizationRemark, llvm::MachineOptimizationRemarkMissed, llvm::MachineOptimizationRemarkAnalysis, llvm::OptimizationRemark, llvm::OptimizationRemarkMissed, llvm::OptimizationRemarkAnalysis, and llvm::DiagnosticInfoOptimizationFailure.

◆ isMissed()

bool llvm::DiagnosticInfoOptimizationBase::isMissed ( ) const
inline

◆ isPassed()

bool llvm::DiagnosticInfoOptimizationBase::isPassed ( ) const
inline

◆ isVerbose()

bool llvm::DiagnosticInfoOptimizationBase::isVerbose ( ) const
inline

Definition at line 485 of file DiagnosticInfo.h.

References IsVerbose.

◆ print()

void DiagnosticInfoOptimizationBase::print ( DiagnosticPrinter DP) const
overridevirtual

◆ setHotness()

void llvm::DiagnosticInfoOptimizationBase::setHotness ( std::optional< uint64_t H)
inline

Definition at line 483 of file DiagnosticInfo.h.

References H, and Hotness.

Member Data Documentation

◆ Args

SmallVector<Argument, 4> llvm::DiagnosticInfoOptimizationBase::Args
protected

Arguments collected via the streaming interface.

Definition at line 527 of file DiagnosticInfo.h.

Referenced by llvm::DiagnosticInfoIROptimization::DiagnosticInfoIROptimization(), getArgs(), getMsg(), and insert().

◆ FirstExtraArgIndex

int llvm::DiagnosticInfoOptimizationBase::FirstExtraArgIndex = -1
protected

If positive, the index of the first argument that only appear in the optimization records and not in the remark printed in the compiler output.

Definition at line 535 of file DiagnosticInfo.h.

Referenced by getMsg(), and insert().

◆ Hotness

std::optional<uint64_t> llvm::DiagnosticInfoOptimizationBase::Hotness
protected

If profile information is available, this is the number of times the corresponding code was executed in a profile instrumentation run.

Definition at line 524 of file DiagnosticInfo.h.

Referenced by getHotness(), print(), and setHotness().

◆ IsVerbose

bool llvm::DiagnosticInfoOptimizationBase::IsVerbose = false
protected

The remark is expected to be noisy.

Definition at line 530 of file DiagnosticInfo.h.

Referenced by insert(), and isVerbose().

◆ PassName

const char* llvm::DiagnosticInfoOptimizationBase::PassName
protected

Name of the pass that triggers this report.

If this matches the regular expression given in -Rpass=regexp, then the remark will be emitted.

Definition at line 515 of file DiagnosticInfo.h.

Referenced by getPassName().

◆ RemarkName

StringRef llvm::DiagnosticInfoOptimizationBase::RemarkName
protected

Textual identifier for the remark (single-word, camel-case).

Can be used by external tools reading the output file for optimization remarks to identify the remark.

Definition at line 520 of file DiagnosticInfo.h.

Referenced by getRemarkName().


The documentation for this class was generated from the following files: