|
LLVM 24.0.0git
|
Base class for instrumentation opportunities. More...
#include "llvm/Transforms/IPO/Instrumentor.h"
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 Value * | instrument (Value *&V, bool &Changed, InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB, InstrumentationCaches &ICaches) |
| } | |
| virtual Type * | getRetTy (LLVMContext &Ctx) const |
| Get the return type for the instrumentation runtime function. | |
| virtual StringRef | getName () const =0 |
| Get the name of the instrumentation opportunity. | |
| virtual ArrayRef< unsigned > | getAllOpcodes () const |
| Get all opcodes for this 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 LLVM_ABI Value * | forceCast (Value &V, Type &Ty, InstrumentorIRBuilderTy &IIRB) |
| Helpers to cast values, pass them to the runtime, and replace them. | |
| static Value * | getValue (Value &V, Type &Ty, InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB) |
| static LLVM_ABI Value * | replaceValue (Value &V, Value &NewV, InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB) |
| static LLVM_ABI Value * | getIdPre (Value &V, Type &Ty, InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB) |
| Get the opportunity identifier for the pre and post positions. | |
| static LLVM_ABI Value * | getIdPost (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< IRTArg > | IRTArgs |
| The list of possible arguments for the instrumentation runtime function. | |
| StringMap< int32_t > | FlagNames |
| Flag names and their integer bitmask values. | |
| bool | Enabled = true |
| Whether the opportunity is enabled. | |
| StringRef | Filter |
| A filter expression to be matched against runtime property values. | |
| CallbackTy | CB = nullptr |
Base class for instrumentation opportunities.
All opportunities should inherit from this class and implement the virtual class members.
Definition at line 492 of file Instrumentor.h.
| using llvm::instrumentor::InstrumentationOpportunity::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.
{
Definition at line 579 of file Instrumentor.h.
|
inlinevirtual |
Definition at line 493 of file Instrumentor.h.
|
inline |
Construct an opportunity with location IP.
Definition at line 496 of file Instrumentor.h.
References IP.
Referenced by llvm::instrumentor::BaseInstructionIO::BaseInstructionIO(), llvm::instrumentor::BasePointerIO::BasePointerIO(), llvm::instrumentor::FunctionIO::FunctionIO(), llvm::instrumentor::GlobalVarIO::GlobalVarIO(), and llvm::instrumentor::ModuleIO::ModuleIO().
|
inline |
}
Add arguments available in all instrumentation opportunities.
Definition at line 584 of file Instrumentor.h.
References CB, getIdPost(), getIdPre(), llvm::Type::getInt32Ty(), IP, IRTArgs, and llvm::instrumentor::IRTArg::NONE.
Referenced by llvm::instrumentor::AllocaIO::init(), llvm::instrumentor::BasePointerIO::init(), llvm::instrumentor::CastIO::init(), llvm::instrumentor::CompareIO::init(), llvm::instrumentor::FunctionIO::init(), llvm::instrumentor::GlobalVarIO::init(), llvm::instrumentor::LoadIO::init(), llvm::instrumentor::ModuleIO::init(), llvm::instrumentor::NumericIO::init(), llvm::instrumentor::StoreIO::init(), and llvm::instrumentor::UnreachableIO::init().
|
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 745 of file Instrumentor.cpp.
References llvm::Constant::getNullValue(), and llvm::instrumentor::InstrumentorIRBuilderTy::IRB.
Referenced by getValue().
|
inlinevirtual |
Get all opcodes for this instrumentation opportunity.
For non-instruction opportunities, returns an empty array. For instruction opportunities, returns an array of all opcodes this IO handles.
Reimplemented in llvm::instrumentor::InstructionIO< Opcodes >, llvm::instrumentor::InstructionIO< Instruction::Add, Instruction::FAdd, Instruction::Sub, Instruction::FSub, Instruction::Mul, Instruction::FMul, Instruction::UDiv, Instruction::FDiv, Instruction::SDiv, Instruction::URem, Instruction::SRem, Instruction::FRem, Instruction::Shl, Instruction::LShr, Instruction::AShr, Instruction::And, Instruction::Or, Instruction::Xor, Instruction::FNeg >, llvm::instrumentor::InstructionIO< Instruction::Alloca >, llvm::instrumentor::InstructionIO< Instruction::ICmp, Instruction::FCmp >, llvm::instrumentor::InstructionIO< Instruction::Load >, llvm::instrumentor::InstructionIO< Instruction::PtrToInt, Instruction::IntToPtr, Instruction::Trunc, Instruction::ZExt, Instruction::SExt, Instruction::FPToUI, Instruction::FPToSI, Instruction::UIToFP, Instruction::SIToFP, Instruction::FPTrunc, Instruction::FPExt, Instruction::AddrSpaceCast, Instruction::BitCast >, llvm::instrumentor::InstructionIO< Instruction::Store >, and llvm::instrumentor::InstructionIO< Instruction::Unreachable >.
Definition at line 569 of file Instrumentor.h.
|
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 610 of file Instrumentor.h.
Referenced by getIdPost(), and getIdPre().
|
static |
Definition at line 739 of file Instrumentor.cpp.
References llvm::instrumentor::InstrumentorIRBuilderTy::Epoch, and getIdFromEpoch().
Referenced by addCommonArgs().
|
static |
Get the opportunity identifier for the pre and post positions.
{
Definition at line 733 of file Instrumentor.cpp.
References llvm::instrumentor::InstrumentorIRBuilderTy::Epoch, and getIdFromEpoch().
Referenced by addCommonArgs().
|
inline |
Get the location kind of the instrumentation opportunity.
Definition at line 572 of file Instrumentor.h.
References IP.
Referenced by llvm::instrumentor::InstrumentationConfig::addChoice(), llvm::instrumentor::AllocaIO::init(), llvm::instrumentor::CastIO::init(), llvm::instrumentor::CompareIO::init(), llvm::instrumentor::FunctionIO::init(), llvm::instrumentor::GlobalVarIO::init(), llvm::instrumentor::LoadIO::init(), llvm::instrumentor::NumericIO::init(), and llvm::instrumentor::StoreIO::init().
|
pure virtual |
Get the name of the instrumentation opportunity.
Implemented in llvm::instrumentor::BasePointerIO, llvm::instrumentor::CastIO, llvm::instrumentor::CompareIO, llvm::instrumentor::FunctionIO, llvm::instrumentor::GlobalVarIO, llvm::instrumentor::InstructionIO< Opcodes >, llvm::instrumentor::InstructionIO< Instruction::Add, Instruction::FAdd, Instruction::Sub, Instruction::FSub, Instruction::Mul, Instruction::FMul, Instruction::UDiv, Instruction::FDiv, Instruction::SDiv, Instruction::URem, Instruction::SRem, Instruction::FRem, Instruction::Shl, Instruction::LShr, Instruction::AShr, Instruction::And, Instruction::Or, Instruction::Xor, Instruction::FNeg >, llvm::instrumentor::InstructionIO< Instruction::Alloca >, llvm::instrumentor::InstructionIO< Instruction::ICmp, Instruction::FCmp >, llvm::instrumentor::InstructionIO< Instruction::Load >, llvm::instrumentor::InstructionIO< Instruction::PtrToInt, Instruction::IntToPtr, Instruction::Trunc, Instruction::ZExt, Instruction::SExt, Instruction::FPToUI, Instruction::FPToSI, Instruction::UIToFP, Instruction::SIToFP, Instruction::FPTrunc, Instruction::FPExt, Instruction::AddrSpaceCast, Instruction::BitCast >, llvm::instrumentor::InstructionIO< Instruction::Store >, llvm::instrumentor::InstructionIO< Instruction::Unreachable >, llvm::instrumentor::ModuleIO, and llvm::instrumentor::NumericIO.
Referenced by llvm::instrumentor::InstrumentationConfig::addChoice(), and llvm::instrumentor::evaluateFilter().
|
inlinevirtual |
Get the return type for the instrumentation runtime function.
Definition at line 561 of file Instrumentor.h.
Referenced by instrument().
|
inlinestatic |
Definition at line 531 of file Instrumentor.h.
References forceCast().
Referenced by llvm::instrumentor::AllocaIO::init(), llvm::instrumentor::BasePointerIO::init(), llvm::instrumentor::CastIO::init(), llvm::instrumentor::CompareIO::init(), and llvm::instrumentor::NumericIO::init().
|
inlinevirtual |
}
Instrument the value V using the configuration IConf, and potentially, the caches ICaches.
Definition at line 542 of file Instrumentor.h.
References CB, Changed, llvm::instrumentor::IRTCallDescription::createLLVMCall(), DL, llvm::instrumentor::evaluateFilter(), getRetTy(), and llvm::instrumentor::InstrumentorIRBuilderTy::IRB.
|
static |
Definition at line 752 of file Instrumentor.cpp.
References llvm::cast(), llvm::instrumentor::InstrumentorIRBuilderTy::DL, llvm::dyn_cast(), llvm::instrumentor::InstrumentorIRBuilderTy::Epoch, llvm::Value::getType(), I, llvm::instrumentor::InstrumentorIRBuilderTy::IRB, llvm::isa(), llvm::instrumentor::InstrumentorIRBuilderTy::NewInsts, and llvm::Value::replaceUsesWithIf().
Referenced by llvm::instrumentor::AllocaIO::init(), llvm::instrumentor::CastIO::init(), llvm::instrumentor::CompareIO::init(), llvm::instrumentor::LoadIO::init(), and llvm::instrumentor::NumericIO::init().
| CallbackTy llvm::instrumentor::InstrumentationOpportunity::CB = nullptr |
Definition at line 580 of file Instrumentor.h.
Referenced by addCommonArgs(), instrument(), and llvm::instrumentor::FunctionIO::setArguments().
| bool llvm::instrumentor::InstrumentationOpportunity::Enabled = true |
Whether the opportunity is enabled.
Definition at line 510 of file Instrumentor.h.
| 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:
Definition at line 524 of file Instrumentor.h.
Referenced by llvm::instrumentor::evaluateFilter().
| StringMap<int32_t> llvm::instrumentor::InstrumentationOpportunity::FlagNames |
Flag names and their integer bitmask values.
Definition at line 507 of file Instrumentor.h.
Referenced by llvm::instrumentor::CompareIO::addFlagNames(), llvm::instrumentor::NumericIO::addFlagNames(), and llvm::instrumentor::evaluateFilter().
| InstrumentationLocation llvm::instrumentor::InstrumentationOpportunity::IP |
The instrumentation location of the opportunity.
Definition at line 499 of file Instrumentor.h.
Referenced by addCommonArgs(), getLocationKind(), and InstrumentationOpportunity().
| 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 504 of file Instrumentor.h.
Referenced by addCommonArgs(), llvm::instrumentor::evaluateFilter(), llvm::instrumentor::AllocaIO::init(), llvm::instrumentor::BasePointerIO::init(), llvm::instrumentor::CastIO::init(), llvm::instrumentor::CompareIO::init(), llvm::instrumentor::FunctionIO::init(), llvm::instrumentor::GlobalVarIO::init(), llvm::instrumentor::LoadIO::init(), llvm::instrumentor::ModuleIO::init(), llvm::instrumentor::NumericIO::init(), and llvm::instrumentor::StoreIO::init().