LLVM 19.0.0git
Classes | Namespaces | Macros | Typedefs | Functions
Statistic.h File Reference

This file defines the 'Statistic' class, which is designed to be an easy way to expose various metrics from passes. More...

#include "llvm/Config/llvm-config.h"
#include "llvm/Support/Compiler.h"
#include <atomic>
#include <memory>
#include <vector>

Go to the source code of this file.

Classes

class  llvm::TrackingStatistic
 
class  llvm::NoopStatistic
 

Namespaces

namespace  llvm
 This is an optimization pass for GlobalISel generic memory operations.
 

Macros

#define LLVM_ENABLE_STATS   1
 
#define STATISTIC(VARNAME, DESC)    static llvm::Statistic VARNAME = {DEBUG_TYPE, #VARNAME, DESC}
 
#define ALWAYS_ENABLED_STATISTIC(VARNAME, DESC)    static llvm::TrackingStatistic VARNAME = {DEBUG_TYPE, #VARNAME, DESC}
 

Typedefs

using llvm::Statistic = NoopStatistic
 

Functions

void llvm::EnableStatistics (bool DoPrintOnExit=true)
 Enable the collection and printing of statistics.
 
bool llvm::AreStatisticsEnabled ()
 Check if statistics are enabled.
 
std::unique_ptr< raw_fd_ostreamllvm::CreateInfoOutputFile ()
 Return a file stream to print our output on.
 
void llvm::PrintStatistics ()
 Print statistics to the file returned by CreateInfoOutputFile().
 
void llvm::PrintStatistics (raw_ostream &OS)
 Print statistics to the given output stream.
 
void llvm::PrintStatisticsJSON (raw_ostream &OS)
 Print statistics in JSON format.
 
std::vector< std::pair< StringRef, uint64_t > > llvm::GetStatistics ()
 Get the statistics.
 
void llvm::ResetStatistics ()
 Reset the statistics.
 

Detailed Description

This file defines the 'Statistic' class, which is designed to be an easy way to expose various metrics from passes.

These statistics are printed at the end of a run (from llvm_shutdown), when the -stats command line option is passed on the command line.

This is useful for reporting information like the number of instructions simplified, optimized or removed by various transformations, like this:

static Statistic NumInstsKilled("gcse", "Number of instructions killed");

Later, in the code: ++NumInstsKilled;

NOTE: Statistics must be declared as global variables.

Definition in file Statistic.h.

Macro Definition Documentation

◆ ALWAYS_ENABLED_STATISTIC

#define ALWAYS_ENABLED_STATISTIC (   VARNAME,
  DESC 
)     static llvm::TrackingStatistic VARNAME = {DEBUG_TYPE, #VARNAME, DESC}

Definition at line 172 of file Statistic.h.

◆ LLVM_ENABLE_STATS

#define LLVM_ENABLE_STATS   1

Definition at line 39 of file Statistic.h.

◆ STATISTIC

#define STATISTIC (   VARNAME,
  DESC 
)     static llvm::Statistic VARNAME = {DEBUG_TYPE, #VARNAME, DESC}

Definition at line 167 of file Statistic.h.