LLVM 23.0.0git
llvm::instrumentor::InstrumentationOpportunity Struct Referenceabstract

Base class for instrumentation opportunities. More...

#include "llvm/Transforms/IPO/Instrumentor.h"

Inheritance diagram for llvm::instrumentor::InstrumentationOpportunity:
[legend]

Public Types

using CallbackTy = std::function<bool(Value &)>
 An optional callback that takes the value that is about to be instrumented and can return false if it should be skipped.

Public Member Functions

virtual ~InstrumentationOpportunity ()
 InstrumentationOpportunity (const InstrumentationLocation IP)
 Construct an opportunity with location IP.
virtual Valueinstrument (Value *&V, InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB, InstrumentationCaches &ICaches)
 }
virtual TypegetRetTy (LLVMContext &Ctx) const
 Get the return type for the instrumentation runtime function.
virtual StringRef getName () const =0
 Get the name of the instrumentation opportunity.
unsigned getOpcode () const
 Get the opcode of the instruction instrumentation opportunity.
InstrumentationLocation::KindTy getLocationKind () const
 Get the location kind of the instrumentation opportunity.
void addCommonArgs (InstrumentationConfig &IConf, LLVMContext &Ctx, bool PassId)
 }

Static Public Member Functions

static ValueforceCast (Value &V, Type &Ty, InstrumentorIRBuilderTy &IIRB)
 Helpers to cast values, pass them to the runtime, and replace them.
static ValuegetValue (Value &V, Type &Ty, InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB)
static ValuereplaceValue (Value &V, Value &NewV, InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB)
static ValuegetIdPre (Value &V, Type &Ty, InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB)
 Get the opportunity identifier for the pre and post positions.
static ValuegetIdPost (Value &V, Type &Ty, InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB)
static int32_t getIdFromEpoch (uint32_t CurrentEpoch)
 }

Public Attributes

InstrumentationLocation IP
 The instrumentation location of the opportunity.
SmallVector< IRTArgIRTArgs
 The list of possible arguments for the instrumentation runtime function.
bool Enabled = true
 Whether the opportunity is enabled.
StringRef Filter
 A filter expression to be matched against runtime property values.
CallbackTy CB = nullptr

Detailed Description

Base class for instrumentation opportunities.

All opportunities should inherit from this class and implement the virtual class members.

Definition at line 463 of file Instrumentor.h.

Member Typedef Documentation

◆ CallbackTy

An optional callback that takes the value that is about to be instrumented and can return false if it should be skipped.

{

Definition at line 543 of file Instrumentor.h.

Constructor & Destructor Documentation

◆ ~InstrumentationOpportunity()

virtual llvm::instrumentor::InstrumentationOpportunity::~InstrumentationOpportunity ( )
inlinevirtual

Definition at line 464 of file Instrumentor.h.

◆ InstrumentationOpportunity()

llvm::instrumentor::InstrumentationOpportunity::InstrumentationOpportunity ( const InstrumentationLocation IP)
inline

Member Function Documentation

◆ addCommonArgs()

◆ forceCast()

Value * InstrumentationOpportunity::forceCast ( Value & V,
Type & Ty,
InstrumentorIRBuilderTy & IIRB )
static

Helpers to cast values, pass them to the runtime, and replace them.

To be used as part of the getter/setter of a InstrumentationOpportunity. {

Definition at line 550 of file Instrumentor.cpp.

References llvm::Constant::getNullValue(), and llvm::instrumentor::InstrumentorIRBuilderTy::IRB.

Referenced by getValue().

◆ getIdFromEpoch()

int32_t llvm::instrumentor::InstrumentationOpportunity::getIdFromEpoch ( uint32_t CurrentEpoch)
inlinestatic

}

Compute the opportunity identifier for the current instrumentation epoch CurrentEpoch. The identifiers are assigned consecutively as the epoch advances. Epochs may have no identifier assigned (e.g., because no id was requested). This function always returns the same identifier when called multiple times with the same epoch.

Definition at line 572 of file Instrumentor.h.

Referenced by getIdPost(), and getIdPre().

◆ getIdPost()

Value * InstrumentationOpportunity::getIdPost ( Value & V,
Type & Ty,
InstrumentationConfig & IConf,
InstrumentorIRBuilderTy & IIRB )
static

◆ getIdPre()

Value * InstrumentationOpportunity::getIdPre ( Value & V,
Type & Ty,
InstrumentationConfig & IConf,
InstrumentorIRBuilderTy & IIRB )
static

Get the opportunity identifier for the pre and post positions.

{

Definition at line 538 of file Instrumentor.cpp.

References llvm::instrumentor::InstrumentorIRBuilderTy::Epoch, and getIdFromEpoch().

Referenced by addCommonArgs().

◆ getLocationKind()

InstrumentationLocation::KindTy llvm::instrumentor::InstrumentationOpportunity::getLocationKind ( ) const
inline

◆ getName()

◆ getOpcode()

unsigned llvm::instrumentor::InstrumentationOpportunity::getOpcode ( ) const
inline

Get the opcode of the instruction instrumentation opportunity.

Only valid if it is instruction instrumentation.

Definition at line 533 of file Instrumentor.h.

References IP.

◆ getRetTy()

virtual Type * llvm::instrumentor::InstrumentationOpportunity::getRetTy ( LLVMContext & Ctx) const
inlinevirtual

Get the return type for the instrumentation runtime function.

Definition at line 526 of file Instrumentor.h.

Referenced by instrument().

◆ getValue()

Value * llvm::instrumentor::InstrumentationOpportunity::getValue ( Value & V,
Type & Ty,
InstrumentationConfig & IConf,
InstrumentorIRBuilderTy & IIRB )
inlinestatic

Definition at line 498 of file Instrumentor.h.

References forceCast().

Referenced by llvm::instrumentor::AllocaIO::init().

◆ instrument()

virtual Value * llvm::instrumentor::InstrumentationOpportunity::instrument ( Value *& V,
InstrumentationConfig & IConf,
InstrumentorIRBuilderTy & IIRB,
InstrumentationCaches & ICaches )
inlinevirtual

}

Instrument the value V using the configuration IConf, and potentially, the caches ICaches.

Definition at line 509 of file Instrumentor.h.

References CB, llvm::instrumentor::IRTCallDescription::createLLVMCall(), DL, llvm::instrumentor::evaluateFilter(), getRetTy(), and llvm::instrumentor::InstrumentorIRBuilderTy::IRB.

◆ replaceValue()

Member Data Documentation

◆ CB

CallbackTy llvm::instrumentor::InstrumentationOpportunity::CB = nullptr

◆ Enabled

bool llvm::instrumentor::InstrumentationOpportunity::Enabled = true

Whether the opportunity is enabled.

Definition at line 478 of file Instrumentor.h.

◆ Filter

StringRef llvm::instrumentor::InstrumentationOpportunity::Filter

A filter expression to be matched against runtime property values.

If the filter is non-empty, only instrumentations matching the filter will be executed. The filter syntax supports:

  • Integer comparisons: ==, !=, <, >, <=, >=
  • String comparisons: ==, != (with quoted strings)
  • String prefix check: startswith("prefix")
  • Logical operators: &&, || Examples: "sync_scope_id==3 && atomicity_ordering>0" "name==\"foo\" || name.startswith(\"test_\")" If a property value is dynamic (not a constant), the filter is assumed to pass (true).

Definition at line 492 of file Instrumentor.h.

Referenced by llvm::instrumentor::evaluateFilter().

◆ IP

InstrumentationLocation llvm::instrumentor::InstrumentationOpportunity::IP

The instrumentation location of the opportunity.

Definition at line 470 of file Instrumentor.h.

Referenced by addCommonArgs(), getLocationKind(), getOpcode(), and InstrumentationOpportunity().

◆ IRTArgs

SmallVector<IRTArg> llvm::instrumentor::InstrumentationOpportunity::IRTArgs

The list of possible arguments for the instrumentation runtime function.

The order within the array determines the order of arguments. Arguments may be disabled and will not be passed to the function call.

Definition at line 475 of file Instrumentor.h.

Referenced by addCommonArgs(), llvm::instrumentor::evaluateFilter(), llvm::instrumentor::AllocaIO::init(), llvm::instrumentor::FunctionIO::init(), llvm::instrumentor::GlobalVarIO::init(), llvm::instrumentor::LoadIO::init(), llvm::instrumentor::ModuleIO::init(), and llvm::instrumentor::StoreIO::init().


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