LLVM 24.0.0git
llvm::SlotTracker Class Reference

This class provides computation of slot numbers for LLVM Assembly writing. More...

Inheritance diagram for llvm::SlotTracker:
[legend]

Public Types

using ValueMap = DenseMap<const Value *, unsigned>
 ValueMap - A mapping of Values to slot numbers.
using mdn_iterator = DenseMap<const MDNode*, unsigned>::iterator
 MDNode map iterators.
using as_iterator = DenseMap<AttributeSet, unsigned>::iterator
 AttributeSet map iterators.
using guid_iterator = DenseMap<GlobalValue::GUID, unsigned>::iterator
 GUID map iterators.

Public Member Functions

 SlotTracker (const Module *M, bool ShouldTrackMetadataDefinitions=false)
 Construct from a module.
 SlotTracker (const Function *F)
 Construct from a function, starting out in incorp state.
 SlotTracker (const ModuleSummaryIndex *Index)
 Construct from a module summary index.
 SlotTracker (const SlotTracker &)=delete
SlotTracker & operator= (const SlotTracker &)=delete
 ~SlotTracker () override=default
void setProcessHook (std::function< void(AbstractSlotTrackerStorage *, const Module *)>)
void setProcessHook (std::function< void(AbstractSlotTrackerStorage *, const Function *)>)
void createMetadataSlot (const MDNode *N) override
 getMetadataSlot - Get the slot number of a MDNode.
int getLocalSlot (const Value *V)
 Return the slot number of the specified value in it's type plane.
int getGlobalSlot (const GlobalValue *V)
 getGlobalSlot - Get the slot number of a global value.
int getMetadataSlot (const MDNode *N) override
 getMetadataSlot - Get the slot number of a MDNode.
int getAttributeGroupSlot (AttributeSet AS)
int getModulePathSlot (StringRef Path)
int getGUIDSlot (GlobalValue::GUID GUID)
int getTypeIdSlot (StringRef Id)
int getTypeIdCompatibleVtableSlot (StringRef Id)
void incorporateFunction (const Function *F)
 If you'd like to deal with a function instead of just a module, use this method to get its data into the SlotTracker.
const Function * getFunction () const
void purgeFunction ()
 After calling incorporateFunction, use this method to remove the most recently incorporated function from the SlotTracker.
mdn_iterator mdn_begin ()
mdn_iterator mdn_end ()
unsigned mdn_size () const
bool mdn_empty () const
as_iterator as_begin ()
as_iterator as_end ()
unsigned as_size () const
bool as_empty () const
void initializeIfNeeded ()
 These functions do the actual initialization.
int initializeIndexIfNeeded ()
Public Member Functions inherited from llvm::AbstractSlotTrackerStorage
virtual ~AbstractSlotTrackerStorage ()

Detailed Description

This class provides computation of slot numbers for LLVM Assembly writing.

Definition at line 790 of file AsmWriter.cpp.

Member Typedef Documentation

◆ as_iterator

◆ guid_iterator

GUID map iterators.

Definition at line 910 of file AsmWriter.cpp.

◆ mdn_iterator

MDNode map iterators.

Definition at line 894 of file AsmWriter.cpp.

◆ ValueMap

ValueMap - A mapping of Values to slot numbers.

Definition at line 793 of file AsmWriter.cpp.

Constructor & Destructor Documentation

◆ SlotTracker() [1/4]

SlotTracker::SlotTracker ( const Module * M,
bool ShouldTrackMetadataDefinitions = false )
explicit

Construct from a module.

Definition at line 1031 of file AsmWriter.cpp.

Referenced by operator=(), and SlotTracker().

◆ SlotTracker() [2/4]

SlotTracker::SlotTracker ( const Function * F)
explicit

Construct from a function, starting out in incorp state.

Definition at line 1037 of file AsmWriter.cpp.

References F, and getParent().

◆ SlotTracker() [3/4]

SlotTracker::SlotTracker ( const ModuleSummaryIndex * Index)
explicit

Construct from a module summary index.

Definition at line 1041 of file AsmWriter.cpp.

◆ SlotTracker() [4/4]

llvm::SlotTracker::SlotTracker ( const SlotTracker & )
delete

References SlotTracker().

◆ ~SlotTracker()

Member Function Documentation

◆ as_begin()

as_iterator llvm::SlotTracker::as_begin ( )
inline

Definition at line 904 of file AsmWriter.cpp.

◆ as_empty()

bool llvm::SlotTracker::as_empty ( ) const
inline

Definition at line 907 of file AsmWriter.cpp.

◆ as_end()

as_iterator llvm::SlotTracker::as_end ( )
inline

Definition at line 905 of file AsmWriter.cpp.

◆ as_size()

unsigned llvm::SlotTracker::as_size ( ) const
inline

Definition at line 906 of file AsmWriter.cpp.

◆ createMetadataSlot()

void SlotTracker::createMetadataSlot ( const MDNode * N)
overridevirtual

getMetadataSlot - Get the slot number of a MDNode.

Implements llvm::AbstractSlotTrackerStorage.

Definition at line 1378 of file AsmWriter.cpp.

References N.

Referenced by ~SlotTracker().

◆ getAttributeGroupSlot()

int SlotTracker::getAttributeGroupSlot ( AttributeSet AS)

Definition at line 1403 of file AsmWriter.cpp.

References initializeIfNeeded().

Referenced by ~SlotTracker().

◆ getFunction()

const Function * llvm::SlotTracker::getFunction ( ) const
inline

Definition at line 886 of file AsmWriter.cpp.

◆ getGlobalSlot()

int SlotTracker::getGlobalSlot ( const GlobalValue * V)

getGlobalSlot - Get the slot number of a global value.

Definition at line 1358 of file AsmWriter.cpp.

References initializeIfNeeded(), and MI.

Referenced by ~SlotTracker().

◆ getGUIDSlot()

int SlotTracker::getGUIDSlot ( GlobalValue::GUID GUID)

Definition at line 1421 of file AsmWriter.cpp.

References I, and initializeIndexIfNeeded().

Referenced by ~SlotTracker().

◆ getLocalSlot()

int SlotTracker::getLocalSlot ( const Value * V)

Return the slot number of the specified value in it's type plane.

getLocalSlot - Get the slot number for a value that is local to a function.

If something is not in the SlotTracker, return -1.

Definition at line 1393 of file AsmWriter.cpp.

References assert(), initializeIfNeeded(), and llvm::isa().

Referenced by ~SlotTracker().

◆ getMetadataSlot()

int SlotTracker::getMetadataSlot ( const MDNode * N)
overridevirtual

getMetadataSlot - Get the slot number of a MDNode.

Implements llvm::AbstractSlotTrackerStorage.

Definition at line 1381 of file AsmWriter.cpp.

References initializeIfNeeded(), llvm::isa(), and N.

Referenced by writeAsOperandInternal(), and ~SlotTracker().

◆ getModulePathSlot()

int SlotTracker::getModulePathSlot ( StringRef Path)

Definition at line 1412 of file AsmWriter.cpp.

References I, and initializeIndexIfNeeded().

Referenced by ~SlotTracker().

◆ getTypeIdCompatibleVtableSlot()

int SlotTracker::getTypeIdCompatibleVtableSlot ( StringRef Id)

Definition at line 1439 of file AsmWriter.cpp.

References I, and initializeIndexIfNeeded().

Referenced by ~SlotTracker().

◆ getTypeIdSlot()

int SlotTracker::getTypeIdSlot ( StringRef Id)

Definition at line 1430 of file AsmWriter.cpp.

References I, and initializeIndexIfNeeded().

Referenced by ~SlotTracker().

◆ incorporateFunction()

void llvm::SlotTracker::incorporateFunction ( const Function * F)
inline

If you'd like to deal with a function instead of just a module, use this method to get its data into the SlotTracker.

Definition at line 881 of file AsmWriter.cpp.

References F.

◆ initializeIfNeeded()

void SlotTracker::initializeIfNeeded ( )
inline

These functions do the actual initialization.

< Prevent re-processing next time we're called.

Definition at line 1045 of file AsmWriter.cpp.

Referenced by getAttributeGroupSlot(), getGlobalSlot(), getLocalSlot(), and getMetadataSlot().

◆ initializeIndexIfNeeded()

int SlotTracker::initializeIndexIfNeeded ( )

< Prevent re-processing next time we're called.

Definition at line 1055 of file AsmWriter.cpp.

Referenced by getGUIDSlot(), getModulePathSlot(), getTypeIdCompatibleVtableSlot(), and getTypeIdSlot().

◆ mdn_begin()

mdn_iterator llvm::SlotTracker::mdn_begin ( )
inline

Definition at line 896 of file AsmWriter.cpp.

◆ mdn_empty()

bool llvm::SlotTracker::mdn_empty ( ) const
inline

Definition at line 899 of file AsmWriter.cpp.

◆ mdn_end()

mdn_iterator llvm::SlotTracker::mdn_end ( )
inline

Definition at line 897 of file AsmWriter.cpp.

◆ mdn_size()

unsigned llvm::SlotTracker::mdn_size ( ) const
inline

Definition at line 898 of file AsmWriter.cpp.

◆ operator=()

SlotTracker & llvm::SlotTracker::operator= ( const SlotTracker & )
delete

References SlotTracker().

◆ purgeFunction()

void SlotTracker::purgeFunction ( )

After calling incorporateFunction, use this method to remove the most recently incorporated function from the SlotTracker.

Clean up after incorporating a function.

This will reset the state of the machine back to just the module contents.

This is the only way to get out of the function incorporation state that affects get*Slot/Create*Slot. Function incorporation state is indicated by TheFunction != 0.

Definition at line 1349 of file AsmWriter.cpp.

References ST_DEBUG.

◆ setProcessHook() [1/2]

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

Definition at line 1372 of file AsmWriter.cpp.

◆ setProcessHook() [2/2]

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

Definition at line 1367 of file AsmWriter.cpp.

Referenced by ~SlotTracker().


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