LLVM 22.0.0git
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)
#define ALWAYS_ENABLED_STATISTIC(VARNAME, DESC)

Typedefs

using llvm::Statistic = NoopStatistic

Functions

LLVM_ABI void llvm::EnableStatistics (bool DoPrintOnExit=true)
 Enable the collection and printing of statistics.
LLVM_ABI bool llvm::AreStatisticsEnabled ()
 Check if statistics are enabled.
LLVM_ABI std::unique_ptr< raw_ostreamllvm::CreateInfoOutputFile ()
 Return a stream to print our output on.
LLVM_ABI void llvm::PrintStatistics ()
 Print statistics to the file returned by CreateInfoOutputFile().
LLVM_ABI void llvm::PrintStatistics (raw_ostream &OS)
 Print statistics to the given output stream.
LLVM_ABI void llvm::PrintStatisticsJSON (raw_ostream &OS)
 Print statistics in JSON format.
LLVM_ABI std::vector< std::pair< StringRef, uint64_t > > llvm::GetStatistics ()
 Get the statistics.
LLVM_ABI 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 )
Value:
static llvm::TrackingStatistic VARNAME = {DEBUG_TYPE, #VARNAME, DESC}
#define DEBUG_TYPE
#define DESC

Definition at line 177 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 )
Value:
static llvm::Statistic VARNAME [[maybe_unused]] = {DEBUG_TYPE, #VARNAME, DESC}
NoopStatistic Statistic
Definition Statistic.h:162

Definition at line 171 of file Statistic.h.