LLVM 23.0.0git
llvm::instrumentor::InstrumentorIRBuilderTy Struct Reference

An IR builder augmented with extra information for the instrumentor pass. More...

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

Public Types

using AllocaListTy = SmallVector<AllocaInst *>
 }

Public Member Functions

 InstrumentorIRBuilderTy (Module &M)
 Construct an IR builder for the module M.
 ~InstrumentorIRBuilderTy ()
 Destroy the IR builder and remove all erasable instructions cached during the process of instrumenting.
AllocaInstgetAlloca (Function *Fn, Type *Ty, bool MatchType=false)
 Get a temporary alloca to communicate (large) values with the runtime.
void returnAllocas ()
 Return the temporary allocas.
void eraseLater (Instruction *I)
 Save instruction I to be erased later.

Public Attributes

ModuleM
 Commonly used values for IR inspection and creation.
LLVMContextCtx
const DataLayoutDL = M.getDataLayout()
TypeVoidTy = Type::getVoidTy(Ctx)
PointerTypePtrTy = PointerType::get(Ctx, 0)
IntegerTypeInt8Ty = Type::getInt8Ty(Ctx)
IntegerTypeInt32Ty = Type::getInt32Ty(Ctx)
IntegerTypeInt64Ty = Type::getInt64Ty(Ctx)
DenseMap< std::pair< Function *, unsigned >, AllocaListTy * > AllocaMap
 Map that holds a list of currently available allocas for a function and alloca size.
DenseMap< AllocaInst *, AllocaListTy * > UsedAllocas
 Map that holds the currently used allocas and the list where they belong.
SmallPtrSet< Instruction *, 32 > ErasableInstructions
 Instructions that should be erased later.
IRBuilder< ConstantFolder, IRBuilderCallbackInserterIRB
 The underlying IR builder with insertion callback.
unsigned Epoch = 0
 The current epoch number.
DenseMap< Instruction *, unsignedNewInsts
 A mapping from instrumentation instructions to the epoch they have been created.

Detailed Description

An IR builder augmented with extra information for the instrumentor pass.

The underlying IR builder features an insertion callback to keep track of the new instructions.

Definition at line 37 of file InstrumentorUtils.h.

Member Typedef Documentation

◆ AllocaListTy

Constructor & Destructor Documentation

◆ InstrumentorIRBuilderTy()

llvm::instrumentor::InstrumentorIRBuilderTy::InstrumentorIRBuilderTy ( Module & M)
inline

Construct an IR builder for the module M.

Definition at line 39 of file InstrumentorUtils.h.

References Ctx, Epoch, I, IRB, M, and NewInsts.

◆ ~InstrumentorIRBuilderTy()

llvm::instrumentor::InstrumentorIRBuilderTy::~InstrumentorIRBuilderTy ( )
inline

Destroy the IR builder and remove all erasable instructions cached during the process of instrumenting.

Definition at line 48 of file InstrumentorUtils.h.

References AllocaMap, ErasableInstructions, llvm::PoisonValue::get(), and I.

Member Function Documentation

◆ eraseLater()

void llvm::instrumentor::InstrumentorIRBuilderTy::eraseLater ( Instruction * I)
inline

Save instruction I to be erased later.

The instructions are erased when the IR builder is destroyed.

Definition at line 94 of file InstrumentorUtils.h.

References ErasableInstructions, and I.

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

◆ getAlloca()

AllocaInst * llvm::instrumentor::InstrumentorIRBuilderTy::getAlloca ( Function * Fn,
Type * Ty,
bool MatchType = false )
inline

Get a temporary alloca to communicate (large) values with the runtime.

Definition at line 63 of file InstrumentorUtils.h.

References AllocaMap, llvm::BasicBlock::begin(), DL, llvm::Function::getDataLayout(), llvm::Function::getEntryBlock(), and UsedAllocas.

Referenced by llvm::instrumentor::IRTCallDescription::createLLVMCall(), and createValuePack().

◆ returnAllocas()

void llvm::instrumentor::InstrumentorIRBuilderTy::returnAllocas ( )
inline

Return the temporary allocas.

Definition at line 86 of file InstrumentorUtils.h.

References llvm::List, and UsedAllocas.

Member Data Documentation

◆ AllocaMap

DenseMap<std::pair<Function *, unsigned>, AllocaListTy *> llvm::instrumentor::InstrumentorIRBuilderTy::AllocaMap

Map that holds a list of currently available allocas for a function and alloca size.

Definition at line 115 of file InstrumentorUtils.h.

Referenced by getAlloca(), and ~InstrumentorIRBuilderTy().

◆ Ctx

◆ DL

const DataLayout& llvm::instrumentor::InstrumentorIRBuilderTy::DL = M.getDataLayout()

◆ Epoch

unsigned llvm::instrumentor::InstrumentorIRBuilderTy::Epoch = 0

The current epoch number.

Each instrumentation, e.g., of an instruction, is happening in a dedicated epoch. The epoch allows to determine if instrumentation instructions were already around, due to prior instrumentations, or have been introduced to support the current instrumentation, e.g., compute information about the current instruction.

Definition at line 132 of file InstrumentorUtils.h.

Referenced by llvm::instrumentor::IRTCallDescription::createLLVMCall(), llvm::instrumentor::InstrumentationOpportunity::getIdPost(), llvm::instrumentor::InstrumentationOpportunity::getIdPre(), InstrumentorIRBuilderTy(), llvm::instrumentor::InstrumentationOpportunity::replaceValue(), llvm::instrumentor::GlobalVarIO::setAddress(), and llvm::instrumentor::FunctionIO::setArguments().

◆ ErasableInstructions

SmallPtrSet<Instruction *, 32> llvm::instrumentor::InstrumentorIRBuilderTy::ErasableInstructions

Instructions that should be erased later.

Definition at line 122 of file InstrumentorUtils.h.

Referenced by eraseLater(), and ~InstrumentorIRBuilderTy().

◆ Int32Ty

◆ Int64Ty

◆ Int8Ty

◆ IRB

◆ M

Module& llvm::instrumentor::InstrumentorIRBuilderTy::M

Commonly used values for IR inspection and creation.

{

Definition at line 98 of file InstrumentorUtils.h.

Referenced by InstrumentorIRBuilderTy().

◆ NewInsts

DenseMap<Instruction *, unsigned> llvm::instrumentor::InstrumentorIRBuilderTy::NewInsts

A mapping from instrumentation instructions to the epoch they have been created.

Definition at line 136 of file InstrumentorUtils.h.

Referenced by InstrumentorIRBuilderTy(), llvm::instrumentor::InstrumentationOpportunity::replaceValue(), llvm::instrumentor::GlobalVarIO::setAddress(), and llvm::instrumentor::FunctionIO::setArguments().

◆ PtrTy

◆ UsedAllocas

DenseMap<AllocaInst *, AllocaListTy *> llvm::instrumentor::InstrumentorIRBuilderTy::UsedAllocas

Map that holds the currently used allocas and the list where they belong.

Once an alloca has to be returned, it is returned directly to its list.

Definition at line 119 of file InstrumentorUtils.h.

Referenced by getAlloca(), and returnAllocas().

◆ VoidTy

Type* llvm::instrumentor::InstrumentorIRBuilderTy::VoidTy = Type::getVoidTy(Ctx)

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