LLVM 24.0.0git
llvm::ModuleSlotTracker Class Reference

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

#include "llvm/IR/ModuleSlotTracker.h"

Inheritance diagram for llvm::ModuleSlotTracker:
[legend]

Public Types

using MachineMDNodeListType

Public Member Functions

 ModuleSlotTracker (SlotTracker &Machine, const Module *M, const Function *F=nullptr)
 Wrap a preinitialized SlotTracker.
 ModuleSlotTracker (const Module *M)
 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 *)>)
void setProcessHook (std::function< void(AbstractSlotTrackerStorage *, const Function *)>)
void collectMDNodes (MachineMDNodeListType &L) const
virtual bool shouldPrintDebugLocationInline (const DILocation *) const
 Return whether a debug location should be printed inline instead of by ID.

Protected Member Functions

void renumberMetadataForAssembly (ArrayRef< const MDNode * > AdditionalMetadata, MachineMDNodeListType *AdditionalMetadataNodes=nullptr) const
 Renumber module metadata and then additional metadata for canonical assembly output.
void collectAdditionalMetadata (ArrayRef< const MDNode * > AdditionalMetadata, MachineMDNodeListType &AdditionalMetadataNodes) const
 Collect metadata reachable from AdditionalMetadata but not from the module.

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 45 of file ModuleSlotTracker.h.

Member Typedef Documentation

◆ MachineMDNodeListType

Initial value:
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.

Definition at line 47 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 946 of file AsmWriter.cpp.

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

◆ ModuleSlotTracker() [2/2]

ModuleSlotTracker::ModuleSlotTracker ( const Module * M)
explicit

Construct a slot tracker from a module.

If M is nullptr, uses a null slot tracker.

Definition at line 950 of file AsmWriter.cpp.

◆ ~ModuleSlotTracker()

ModuleSlotTracker::~ModuleSlotTracker ( )
virtualdefault

Destructor to clean up storage.

References getMachine().

Member Function Documentation

◆ collectAdditionalMetadata()

void ModuleSlotTracker::collectAdditionalMetadata ( ArrayRef< const MDNode * > AdditionalMetadata,
MachineMDNodeListType & AdditionalMetadataNodes ) const
protected

Collect metadata reachable from AdditionalMetadata but not from the module.

Definition at line 1330 of file AsmWriter.cpp.

References assert(), llvm::SmallVectorImpl< T >::emplace_back(), N, and llvm::sort().

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

◆ collectMDNodes()

void ModuleSlotTracker::collectMDNodes ( MachineMDNodeListType & L) const

Definition at line 5561 of file AsmWriter.cpp.

References I, and llvm::make_range().

◆ getCurrentFunction()

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

Definition at line 94 of file ModuleSlotTracker.h.

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 983 of file AsmWriter.cpp.

References assert().

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

◆ getMachine()

◆ getModule()

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

Definition at line 93 of file ModuleSlotTracker.h.

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

◆ incorporateFunction()

void ModuleSlotTracker::incorporateFunction ( const Function & F)

◆ renumberMetadataForAssembly()

void ModuleSlotTracker::renumberMetadataForAssembly ( ArrayRef< const MDNode * > AdditionalMetadata,
MachineMDNodeListType * AdditionalMetadataNodes = nullptr ) const
protected

Renumber module metadata and then additional metadata for canonical assembly output.

Definition at line 1323 of file AsmWriter.cpp.

References assert().

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

◆ setProcessHook() [1/2]

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

Definition at line 993 of file AsmWriter.cpp.

◆ setProcessHook() [2/2]

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

Definition at line 988 of file AsmWriter.cpp.

Referenced by collectAdditionalMetadata().

◆ shouldPrintDebugLocationInline()

virtual bool llvm::ModuleSlotTracker::shouldPrintDebugLocationInline ( const DILocation * ) const
inlinevirtual

Return whether a debug location should be printed inline instead of by ID.

Reimplemented in llvm::MachineModuleSlotTracker.

Definition at line 117 of file ModuleSlotTracker.h.

Referenced by writeAsOperandInternal().


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