LLVM 19.0.0git
Public Types | Public Member Functions | List of all members
llvm::ModuleSlotTracker Class Reference

Manage lifetime of a slot tracker for printing IR. More...

#include "llvm/IR/ModuleSlotTracker.h"

Inheritance diagram for llvm::ModuleSlotTracker:
Inheritance graph
[legend]

Public Types

using MachineMDNodeListType = std::vector< std::pair< unsigned, const MDNode * > >
 

Public Member Functions

 ModuleSlotTracker (SlotTracker &Machine, const Module *M, const Function *F=nullptr)
 Wrap a preinitialized SlotTracker.
 
 ModuleSlotTracker (const Module *M, bool ShouldInitializeAllMetadata=true)
 Construct a slot tracker from a module.
 
virtual ~ModuleSlotTracker ()
 Destructor to clean up storage.
 
SlotTrackergetMachine ()
 Lazily creates a slot tracker.
 
const ModulegetModule () const
 
const FunctiongetCurrentFunction () const
 
void incorporateFunction (const Function &F)
 Incorporate the given function.
 
int getLocalSlot (const Value *V)
 Return the slot number of the specified local value.
 
void setProcessHook (std::function< void(AbstractSlotTrackerStorage *, const Module *, bool)>)
 
void setProcessHook (std::function< void(AbstractSlotTrackerStorage *, const Function *, bool)>)
 
void collectMDNodes (MachineMDNodeListType &L, unsigned LB, unsigned UB) const
 

Detailed Description

Manage lifetime of a slot tracker for printing IR.

Wrapper around the SlotTracker used internally by AsmWriter. This class allows callers to share the cost of incorporating the metadata in a module or a function.

If the IR changes from underneath ModuleSlotTracker, strings like "<badref>" will be printed, or, worse, the wrong slots entirely.

Definition at line 44 of file ModuleSlotTracker.h.

Member Typedef Documentation

◆ MachineMDNodeListType

Definition at line 101 of file ModuleSlotTracker.h.

Constructor & Destructor Documentation

◆ ModuleSlotTracker() [1/2]

ModuleSlotTracker::ModuleSlotTracker ( SlotTracker Machine,
const Module M,
const Function F = nullptr 
)

Wrap a preinitialized SlotTracker.

Definition at line 870 of file AsmWriter.cpp.

◆ ModuleSlotTracker() [2/2]

ModuleSlotTracker::ModuleSlotTracker ( const Module M,
bool  ShouldInitializeAllMetadata = true 
)
explicit

Construct a slot tracker from a module.

If M is nullptr, uses a null slot tracker. Otherwise, initializes a slot tracker, and initializes all metadata slots. ShouldInitializeAllMetadata defaults to true because this is expected to be shared between multiple callers, and otherwise MDNode references will not match up.

Definition at line 874 of file AsmWriter.cpp.

◆ ~ModuleSlotTracker()

ModuleSlotTracker::~ModuleSlotTracker ( )
virtualdefault

Destructor to clean up storage.

Member Function Documentation

◆ collectMDNodes()

void ModuleSlotTracker::collectMDNodes ( MachineMDNodeListType L,
unsigned  LB,
unsigned  UB 
) const

Definition at line 5189 of file AsmWriter.cpp.

References I, and llvm::make_range().

Referenced by llvm::MachineModuleSlotTracker::collectMachineMDNodes().

◆ getCurrentFunction()

const Function * llvm::ModuleSlotTracker::getCurrentFunction ( ) const
inline

Definition at line 81 of file ModuleSlotTracker.h.

References F.

Referenced by printIRBlockReference(), and llvm::MIRFormatter::printIRValue().

◆ getLocalSlot()

int ModuleSlotTracker::getLocalSlot ( const Value V)

Return the slot number of the specified local value.

A function that defines this value should be incorporated prior to calling this method. Return -1 if the value is not in the function's SlotTracker.

Definition at line 910 of file AsmWriter.cpp.

References assert(), and llvm::SlotTracker::getLocalSlot().

Referenced by initSlots2BasicBlocks(), mapValueToSlot(), printIRBlockReference(), llvm::MIRFormatter::printIRValue(), and llvm::MachineBasicBlock::printName().

◆ getMachine()

SlotTracker * ModuleSlotTracker::getMachine ( )

◆ getModule()

const Module * llvm::ModuleSlotTracker::getModule ( ) const
inline

Definition at line 80 of file ModuleSlotTracker.h.

Referenced by llvm::Value::printAsOperand(), and printAsOperandImpl().

◆ incorporateFunction()

void ModuleSlotTracker::incorporateFunction ( const Function F)

◆ setProcessHook() [1/2]

void ModuleSlotTracker::setProcessHook ( std::function< void(AbstractSlotTrackerStorage *, const Function *, bool)>  Fn)

Definition at line 921 of file AsmWriter.cpp.

◆ setProcessHook() [2/2]

void ModuleSlotTracker::setProcessHook ( std::function< void(AbstractSlotTrackerStorage *, const Module *, bool)>  Fn)

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