LLVM  8.0.1
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"

Public Member Functions

 ModuleSlotTracker (SlotTracker &Machine, const Module *M, const Function *F=nullptr)
 Wrap a preinitialized SlotTracker. More...
 
 ModuleSlotTracker (const Module *M, bool ShouldInitializeAllMetadata=true)
 Construct a slot tracker from a module. More...
 
 ~ModuleSlotTracker ()
 Destructor to clean up storage. More...
 
SlotTrackergetMachine ()
 Lazily creates a slot tracker. More...
 
const ModulegetModule () const
 
const FunctiongetCurrentFunction () const
 
void incorporateFunction (const Function &F)
 Incorporate the given function. More...
 
int getLocalSlot (const Value *V)
 Return the slot number of the specified local value. More...
 

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 30 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 819 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 823 of file AsmWriter.cpp.

◆ ~ModuleSlotTracker()

ModuleSlotTracker::~ModuleSlotTracker ( )
default

Destructor to clean up storage.

Member Function Documentation

◆ getCurrentFunction()

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

Definition at line 62 of file ModuleSlotTracker.h.

References getLocalSlot(), and incorporateFunction().

Referenced by printIRBlockReference(), and printIRValueReference().

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

Referenced by getCurrentFunction(), mapValueToSlot(), llvm::MachineBasicBlock::print(), printIRBlockReference(), and printIRValueReference().

◆ getMachine()

SlotTracker * ModuleSlotTracker::getMachine ( )

Lazily creates a slot tracker.

Definition at line 830 of file AsmWriter.cpp.

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

◆ getModule()

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

Definition at line 61 of file ModuleSlotTracker.h.

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

◆ incorporateFunction()

void ModuleSlotTracker::incorporateFunction ( const Function F)

Incorporate the given function.

Purge the currently incorporated function and incorporate F. If F is currently incorporated, this is a no-op.

Definition at line 841 of file AsmWriter.cpp.

Referenced by getCurrentFunction(), initSlots2BasicBlocks(), initSlots2Values(), llvm::MIRPrinter::print(), llvm::Value::print(), llvm::MachineFunction::print(), llvm::MachineBasicBlock::print(), llvm::MachineInstr::print(), printIRBlockReference(), and printMemOperand().


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