LLVM: LiveDebugValues::MLocTracker Class Reference (original) (raw)

Tracker for what values are in machine locations. More...

#include "[CodeGen/LiveDebugValues/InstrRefBasedImpl.h](InstrRefBasedImpl%5F8h%5Fsource.html)"

Public Member Functions
LLVM_ABI_FOR_TEST MLocTracker (MachineFunction &MF, const TargetInstrInfo &TII, const TargetRegisterInfo &TRI, const TargetLowering &TLI)
unsigned getLocID (Register Reg)
Produce location ID number for a Register.
unsigned getLocID (SpillLocationNo Spill, unsigned SpillSubReg)
Produce location ID number for a spill position.
unsigned getLocID (SpillLocationNo Spill, StackSlotPos Idx)
Produce location ID number for a spill position.
unsigned getSpillIDWithIdx (SpillLocationNo Spill, unsigned Idx)
Given a spill number, and a slot within the spill, calculate the ID number for that location.
SpillLocationNo locIDToSpill (unsigned ID) const
Return the spill number that a location ID corresponds to.
StackSlotPos locIDToSpillIdx (unsigned ID) const
Returns the spill-slot size/offs that a location ID corresponds to.
unsigned getNumLocs () const
void setMPhis (unsigned NewCurBB)
Reset all locations to contain a PHI value at the designated block.
void loadFromArray (ValueTable &Locs, unsigned NewCurBB)
Load values for each location from array of ValueIDNums.
void reset ()
Wipe any un-necessary location records after traversing a block.
void clear ()
Clear all data.
void setMLoc (LocIdx L, ValueIDNum Num)
Set a locaiton to a certain value.
ValueIDNum readMLoc (LocIdx L)
Read the value of a particular location.
LLVM_ABI_FOR_TEST LocIdx trackRegister (unsigned ID)
Create a [LocIdx](classLiveDebugValues%5F1%5F1LocIdx.html "Handle-class for a particular "location".") for an untracked register ID.
LocIdx lookupOrTrackRegister (unsigned ID)
bool isRegisterTracked (Register R)
Is register R currently tracked by MLocTracker?
void defReg (Register R, unsigned BB, unsigned Inst)
Record a definition of the specified register at the given block / inst.
void setReg (Register R, ValueIDNum ValueID)
Set a register to a value number.
ValueIDNum readReg (Register R)
void wipeRegister (Register R)
Reset a register value to zero / empty.
LocIdx getRegMLoc (Register R)
Determine the [LocIdx](classLiveDebugValues%5F1%5F1LocIdx.html "Handle-class for a particular "location".") of an existing register.
void writeRegMask (const MachineOperand *MO, unsigned CurBB, unsigned InstID)
Record a RegMask operand being executed.
LLVM_ABI_FOR_TEST std::optional< SpillLocationNo > getOrTrackSpillLoc (SpillLoc L)
Find [LocIdx](classLiveDebugValues%5F1%5F1LocIdx.html "Handle-class for a particular "location".") for SpillLoc L, creating a new one if it's not tracked.
LocIdx getSpillMLoc (unsigned SpillID)
bool isSpill (LocIdx Idx) const
Return true if Idx is a spill machine location.
unsigned getLocSizeInBits (LocIdx L) const
How large is this location (aka, how wide is a value defined there?).
MLocIterator begin ()
MLocIterator end ()
iterator_range< MLocIterator > locations ()
Return a range over all locations currently tracked.
std::string LocIdxToName (LocIdx Idx) const
std::string IDAsString (const ValueIDNum &Num) const
LLVM_DUMP_METHOD void dump ()
LLVM_DUMP_METHOD void dump_mloc_map ()
MachineInstrBuilder emitLoc (const SmallVectorImpl< ResolvedDbgOp > &DbgOps, const DebugVariable &Var, const DILocation *DILoc, const DbgValueProperties &Properties)
Create a DBG_VALUE based on debug operands DbgOps.
Public Attributes
MachineFunction & MF
const TargetInstrInfo & TII
const TargetRegisterInfo & TRI
const TargetLowering & TLI
LocToValueType LocIdxToIDNum
Map of LocIdxes to the ValueIDNums that they store.
std::vector< LocIdx > LocIDToLocIdx
"Map" of machine location IDs (i.e., raw register or spill number) to the [LocIdx](classLiveDebugValues%5F1%5F1LocIdx.html "Handle-class for a particular "location".") key / number for that location.
IndexedMap< unsigned, LocIdxToIndexFunctor > LocIdxToLocID
Inverse map of LocIDToLocIdx.
SmallSet< Register, 8 > SPAliases
When clobbering register masks, we chose to not believe the machine model and don't clobber SP.
UniqueVector< SpillLoc > SpillLocs
Unique-ification of spill.
unsigned CurBB = -1
unsigned NumRegs
Cached local copy of the number of registers the target has.
unsigned NumSlotIdxes
Number of slot indexes the target has – distinct segments of a stack slot that can take on the value of a subregister, when a super-register is written to the stack.
SmallVector< std::pair< const MachineOperand *, unsigned >, 32 > Masks
Collection of register mask operands that have been observed.
DenseMap< StackSlotPos, unsigned > StackSlotIdxes
Map from a size/offset pair describing a position in a stack slot, to a numeric identifier for that position.
DenseMap< unsigned, StackSlotPos > StackIdxesToPos
Inverse of StackSlotIdxes.

Tracker for what values are in machine locations.

Listens to the Things being Done by various instructions, and maintains a table of what machine locations have what values (as defined by a ValueIDNum).

There are potentially a much larger number of machine locations on the target machine than the actual working-set size of the function. On x86 for example, we're extremely unlikely to want to track values through control or debug registers. To avoid doing so, MLocTracker has several layers of indirection going on, described below, to avoid unnecessarily tracking any location.

Here's a sort of diagram of the indexes, read from the bottom up:

  Size on stack   Offset on stack
        \              /
 Stack Idx (Where in slot is this?)
                /
               /

Slot Num (stack.0) / FrameIdx => SpillNum / \ / SpillID (int) Register number (int) \ / LocationID => [LocIdx](classLiveDebugValues%5F1%5F1LocIdx.html "Handle-class for a particular "location".") | [LocIdx](classLiveDebugValues%5F1%5F1LocIdx.html "Handle-class for a particular "location".") => ValueIDNum

The aim here is that the [LocIdx](classLiveDebugValues%5F1%5F1LocIdx.html "Handle-class for a particular "location".") => ValueIDNum vector is just an array of values in numbered locations, so that later analyses can ignore whether the location is a register or otherwise. To map a register / spill location to a [LocIdx](classLiveDebugValues%5F1%5F1LocIdx.html "Handle-class for a particular "location"."), you have to use the (sparse) LocationID => [LocIdx](classLiveDebugValues%5F1%5F1LocIdx.html "Handle-class for a particular "location".") map. And to build a LocationID for a stack slot, you need to combine identifiers for which stack slot it is and where within that slot is being described.

Register mask operands cause trouble by technically defining every register; various hacks are used to avoid tracking registers that are never read and only written by regmasks.

Definition at line 693 of file InstrRefBasedImpl.h.

LocToValueType

StackSlotPos

Pair for describing a position within a stack slot – first the size in bits, then the offset.

Definition at line 749 of file InstrRefBasedImpl.h.

Definition at line 1035 of file InstrRefBasedImpl.cpp.

References assert(), getLocID(), I, llvm::MCRegAliasIterator::isValid(), LocIDToLocIdx, LocIdxToIDNum, LocIdxToLocID, lookupOrTrackRegister(), LiveDebugValues::LocIdx::MakeIllegalLoc(), MF, NUM_LOC_BITS, NumRegs, NumSlotIdxes, reset(), Size, SPAliases, StackIdxesToPos, StackSlotIdxes, TII, TLI, and TRI.

begin()

clear()

void LiveDebugValues::MLocTracker::clear ( ) inline

defReg()

dump()

dump_mloc_map()

emitLoc()

Create a DBG_VALUE based on debug operands DbgOps.

Qualify it with the information in \pProperties, for variable Var. Don't insert it anywhere, just return the builder for it.

Definition at line 1204 of file InstrRefBasedImpl.cpp.

References llvm::all_of(), llvm::DIExpression::appendOpsToArg(), assert(), llvm::SmallVectorImpl< T >::assign(), llvm::sampleprof::Base, llvm::BuildMI(), llvm::SmallVectorImpl< T >::clear(), llvm::MachineOperand::CreateReg(), llvm::dwarf_linker::DebugLoc, LiveDebugValues::DbgValueProperties::DIExpr, DL, llvm::SmallVectorTemplateCommon< T, typename >::empty(), llvm::DebugVariable::getFragment(), LiveDebugValues::DbgValueProperties::getLocationOpCount(), getLocSizeInBits(), llvm::DIVariable::getSizeInBits(), llvm::DebugVariable::getVariable(), LiveDebugValues::SpillLocationNo::id(), LiveDebugValues::DbgValueProperties::Indirect, llvm::DIExpression::isComplex(), llvm::DIExpression::isImplicit(), llvm::DIExpression::isSingleLocationExpression(), LiveDebugValues::DbgValueProperties::IsVariadic, locIDToSpill(), locIDToSpillIdx(), LocIdxToLocID, MF, NumRegs, llvm::Offset, llvm::SmallVectorTemplateBase< T, bool >::push_back(), Size, llvm::SmallVectorTemplateCommon< T, typename >::size(), SpillLocs, TII, and TRI.

end()

getLocID() [1/3]

getLocID() [2/3]

getLocID() [3/3]

Produce location ID number for a spill position.

Parameters

Spill The number of the spill we're fetching the location for.
SpillSubReg Subregister within the spill we're addressing.

Definition at line 804 of file InstrRefBasedImpl.h.

References getLocID(), Size, and TRI.

getLocSizeInBits()

unsigned LiveDebugValues::MLocTracker::getLocSizeInBits ( LocIdx L) const inline

getNumLocs()

unsigned LiveDebugValues::MLocTracker::getNumLocs ( ) const inline

getOrTrackSpillLoc()

Find [LocIdx](classLiveDebugValues%5F1%5F1LocIdx.html "Handle-class for a particular "location".") for SpillLoc L, creating a new one if it's not tracked.

Returns std::nullopt when in scenarios where a spill slot could be tracked, but we would likely run into resource limitations.

Definition at line 1139 of file InstrRefBasedImpl.cpp.

References CurBB, getSpillIDWithIdx(), LiveDebugValues::SpillLocationNo::id(), LocIDToLocIdx, LocIdxToIDNum, LocIdxToLocID, NumSlotIdxes, SpillLocs, and StackWorkingSetLimit.

getRegMLoc()

getSpillIDWithIdx()

getSpillMLoc()

LocIdx LiveDebugValues::MLocTracker::getSpillMLoc ( unsigned SpillID) inline

IDAsString()

isRegisterTracked()

bool LiveDebugValues::MLocTracker::isRegisterTracked ( Register R) inline

isSpill()

bool LiveDebugValues::MLocTracker::isSpill ( LocIdx Idx) const inline

loadFromArray()

Load values for each location from array of ValueIDNums.

Take current bbnum just in case we read a value from a hitherto untouched register.

Definition at line 862 of file InstrRefBasedImpl.h.

References CurBB, and locations().

locations()

locIDToSpill()

locIDToSpillIdx()

StackSlotPos LiveDebugValues::MLocTracker::locIDToSpillIdx ( unsigned ID) const inline

LocIdxToName()

std::string MLocTracker::LocIdxToName ( LocIdx Idx ) const

Definition at line 1166 of file InstrRefBasedImpl.cpp.

References llvm::concat(), llvm::Twine::concat(), locIDToSpillIdx(), LocIdxToLocID, NumRegs, NumSlotIdxes, llvm::Twine::str(), and TRI.

Referenced by dump(), LiveDebugValues::ResolvedDbgOp::dump(), dump_mloc_map(), and IDAsString().

lookupOrTrackRegister()

LocIdx LiveDebugValues::MLocTracker::lookupOrTrackRegister ( unsigned ID) inline

readMLoc()

readReg()

reset()

void LiveDebugValues::MLocTracker::reset ( ) inline

setMLoc()

setMPhis()

void LiveDebugValues::MLocTracker::setMPhis ( unsigned NewCurBB) inline

Reset all locations to contain a PHI value at the designated block.

Used sometimes for actual PHI values, othertimes to indicate the block entry value (before any more information is known).

Definition at line 854 of file InstrRefBasedImpl.h.

References CurBB, and locations().

setReg()

trackRegister()

wipeRegister()

void LiveDebugValues::MLocTracker::wipeRegister ( Register R) inline

writeRegMask()

CurBB

unsigned LiveDebugValues::MLocTracker::CurBB = -1

LocIDToLocIdx

std::vector<LocIdx> LiveDebugValues::MLocTracker::LocIDToLocIdx

"Map" of machine location IDs (i.e., raw register or spill number) to the [LocIdx](classLiveDebugValues%5F1%5F1LocIdx.html "Handle-class for a particular "location".") key / number for that location.

There are always at least as many as the number of registers on the target – if the value in the register is not being tracked, then the [LocIdx](classLiveDebugValues%5F1%5F1LocIdx.html "Handle-class for a particular "location".") value will be zero. New entries are appended if a new spill slot begins being tracked. This, and the corresponding reverse map persist for the analysis of the whole function, and is necessarying for decoding various vectors of values.

Definition at line 715 of file InstrRefBasedImpl.h.

Referenced by clear(), getOrTrackSpillLoc(), getRegMLoc(), getSpillMLoc(), isRegisterTracked(), lookupOrTrackRegister(), MLocTracker(), and wipeRegister().

LocIdxToIDNum

LocToValueType LiveDebugValues::MLocTracker::LocIdxToIDNum

Map of LocIdxes to the ValueIDNums that they store.

This is tightly packed, entries only exist for locations that are being tracked.

Definition at line 705 of file InstrRefBasedImpl.h.

Referenced by begin(), clear(), defReg(), end(), getNumLocs(), getOrTrackSpillLoc(), MLocTracker(), readMLoc(), readReg(), setMLoc(), setReg(), trackRegister(), and wipeRegister().

LocIdxToLocID

Masks

Collection of register mask operands that have been observed.

Second part of pair indicates the instruction that they happened in. Used to reconstruct where defs happened if we start tracking a location later on.

Definition at line 745 of file InstrRefBasedImpl.h.

Referenced by reset(), trackRegister(), and writeRegMask().

MF

NumRegs

unsigned LiveDebugValues::MLocTracker::NumRegs

NumSlotIdxes

unsigned LiveDebugValues::MLocTracker::NumSlotIdxes

SPAliases

When clobbering register masks, we chose to not believe the machine model and don't clobber SP.

Do the same for SP aliases, and for efficiency, keep a set of them here.

Definition at line 723 of file InstrRefBasedImpl.h.

Referenced by MLocTracker(), and writeRegMask().

SpillLocs

StackIdxesToPos

StackSlotIdxes

Map from a size/offset pair describing a position in a stack slot, to a numeric identifier for that position.

Allows easier identification of individual positions.

Definition at line 754 of file InstrRefBasedImpl.h.

Referenced by clear(), getLocID(), and MLocTracker().

TII

TLI

TRI


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