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.
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 409 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 471 of file Instrumentor.h.

Constructor & Destructor Documentation

◆ ~InstrumentationOpportunity()

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

Definition at line 410 of file Instrumentor.h.

◆ InstrumentationOpportunity()

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

Construct an opportunity with location IP.

Definition at line 413 of file Instrumentor.h.

References IP.

Referenced by llvm::instrumentor::InstructionIO< Opcode >::InstructionIO().

Member Function Documentation

◆ addCommonArgs()

void llvm::instrumentor::InstrumentationOpportunity::addCommonArgs ( InstrumentationConfig & IConf,
LLVMContext & Ctx,
bool PassId )
inline

}

Add arguments available in all instrumentation opportunities.

Definition at line 476 of file Instrumentor.h.

References CB, getIdPost(), getIdPre(), llvm::Type::getInt32Ty(), IP, IRTArgs, and llvm::instrumentor::IRTArg::NONE.

Referenced by llvm::instrumentor::LoadIO::init(), and llvm::instrumentor::StoreIO::init().

◆ 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 340 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 500 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 328 of file Instrumentor.cpp.

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

Referenced by addCommonArgs().

◆ getLocationKind()

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

Get the location kind of the instrumentation opportunity.

Definition at line 464 of file Instrumentor.h.

References IP.

Referenced by llvm::instrumentor::InstrumentationConfig::addChoice(), llvm::instrumentor::LoadIO::init(), and llvm::instrumentor::StoreIO::init().

◆ getName()

virtual StringRef llvm::instrumentor::InstrumentationOpportunity::getName ( ) const
pure virtual

◆ 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 461 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 454 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 430 of file Instrumentor.h.

References forceCast().

◆ 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 441 of file Instrumentor.h.

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

◆ replaceValue()

Member Data Documentation

◆ CB

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

Definition at line 472 of file Instrumentor.h.

Referenced by addCommonArgs(), and instrument().

◆ Enabled

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

Whether the opportunity is enabled.

Definition at line 424 of file Instrumentor.h.

◆ IP

InstrumentationLocation llvm::instrumentor::InstrumentationOpportunity::IP

The instrumentation location of the opportunity.

Definition at line 416 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 421 of file Instrumentor.h.

Referenced by addCommonArgs(), llvm::instrumentor::LoadIO::init(), and llvm::instrumentor::StoreIO::init().


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