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 34 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 36 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 45 of file InstrumentorUtils.h.

References 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 85 of file InstrumentorUtils.h.

References ErasableInstructions, and I.

◆ 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 54 of file InstrumentorUtils.h.

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

Referenced by llvm::instrumentor::IRTCallDescription::createLLVMCall().

◆ returnAllocas()

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

Return the temporary allocas.

Definition at line 77 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 106 of file InstrumentorUtils.h.

Referenced by getAlloca().

◆ 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 123 of file InstrumentorUtils.h.

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

◆ ErasableInstructions

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

Instructions that should be erased later.

Definition at line 113 of file InstrumentorUtils.h.

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

◆ Int32Ty

◆ Int64Ty

◆ Int8Ty

IntegerType* llvm::instrumentor::InstrumentorIRBuilderTy::Int8Ty = Type::getInt8Ty(Ctx)

◆ IRB

◆ M

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

Commonly used values for IR inspection and creation.

{

Definition at line 89 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 127 of file InstrumentorUtils.h.

Referenced by InstrumentorIRBuilderTy(), and llvm::instrumentor::InstrumentationOpportunity::replaceValue().

◆ 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 110 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: