class MLocTracker
Declaration
class MLocTracker { /* full declaration omitted */ };
Description
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 | LocIdx => ValueIDNum The aim here is that the LocIdx => 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, you have to use the (sparse) LocationID => LocIdx 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.
Declared at: llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.h:346
Member Variables
- public llvm::MachineFunction& MF
- public const llvm::TargetInstrInfo& TII
- public const llvm::TargetRegisterInfo& TRI
- public const llvm::TargetLowering& TLI
- public LiveDebugValues::MLocTracker::LocToValueType LocIdxToIDNum
- Map of LocIdxes to the ValueIDNums that they store. This is tightly packed, entries only exist for locations that are being tracked.
- public std::vector<LocIdx> LocIDToLocIdx
- "Map" of machine location IDs (i.e., raw register or spill number) to the LocIdx 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 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.
- public IndexedMap<unsigned int, LiveDebugValues::LocIdxToIndexFunctor> LocIdxToLocID
- Inverse map of LocIDToLocIdx.
- public SmallSet<llvm::Register, 8> 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.
- public UniqueVector<LiveDebugValues::SpillLoc> SpillLocs
- Unique-ification of spill. Used to number them -- their LocID number is the index in SpillLocs minus one plus NumRegs.
- public unsigned int CurBB
- public unsigned int NumRegs
- Cached local copy of the number of registers the target has.
- public unsigned int 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.
- public SmallVector<std::pair<const MachineOperand*, unsigned int>, 32> 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.
- public DenseMap< LiveDebugValues::MLocTracker::StackSlotPos, unsigned int> 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.
- public DenseMap< unsigned int, LiveDebugValues::MLocTracker::StackSlotPos> StackIdxesToPos
- Inverse of StackSlotIdxes.
Method Overview
- public std::string IDAsString(const LiveDebugValues::ValueIDNum & Num) const
- public std::string LocIdxToName(LiveDebugValues::LocIdx Idx) const
- public MLocTracker(llvm::MachineFunction & MF, const llvm::TargetInstrInfo & TII, const llvm::TargetRegisterInfo & TRI, const llvm::TargetLowering & TLI)
- public LiveDebugValues::MLocTracker::MLocIterator begin()
- public void clear()
- public void defReg(llvm::Register R, unsigned int BB, unsigned int Inst)
- public void dump()
- public void dump_mloc_map()
- public llvm::MachineInstrBuilder emitLoc(Optional<LiveDebugValues::LocIdx> MLoc, const llvm::DebugVariable & Var, const LiveDebugValues::DbgValueProperties & Properties)
- public LiveDebugValues::MLocTracker::MLocIterator end()
- public unsigned int getLocID(llvm::Register Reg)
- public unsigned int getLocID(LiveDebugValues::SpillLocationNo Spill, unsigned int SpillSubReg)
- public unsigned int getLocID(LiveDebugValues::SpillLocationNo Spill, LiveDebugValues::MLocTracker::StackSlotPos Idx)
- public unsigned int getLocSizeInBits(LiveDebugValues::LocIdx L) const
- public unsigned int getNumLocs() const
- public Optional<LiveDebugValues::SpillLocationNo> getOrTrackSpillLoc(LiveDebugValues::SpillLoc L)
- public LiveDebugValues::LocIdx getRegMLoc(llvm::Register R)
- public unsigned int getSpillIDWithIdx(LiveDebugValues::SpillLocationNo Spill, unsigned int Idx)
- public LiveDebugValues::LocIdx getSpillMLoc(unsigned int SpillID)
- public bool isRegisterTracked(llvm::Register R)
- public bool isSpill(LiveDebugValues::LocIdx Idx) const
- public void loadFromArray(LiveDebugValues::ValueTable & Locs, unsigned int NewCurBB)
- public LiveDebugValues::SpillLocationNo locIDToSpill(unsigned int ID) const
- public LiveDebugValues::MLocTracker::StackSlotPos locIDToSpillIdx(unsigned int ID) const
- public iterator_range<LiveDebugValues::MLocTracker::MLocIterator> locations()
- public LiveDebugValues::LocIdx lookupOrTrackRegister(unsigned int ID)
- public LiveDebugValues::ValueIDNum readMLoc(LiveDebugValues::LocIdx L)
- public LiveDebugValues::ValueIDNum readReg(llvm::Register R)
- public void reset()
- public void setMLoc(LiveDebugValues::LocIdx L, LiveDebugValues::ValueIDNum Num)
- public void setMPhis(unsigned int NewCurBB)
- public void setReg(llvm::Register R, LiveDebugValues::ValueIDNum ValueID)
- public LiveDebugValues::LocIdx trackRegister(unsigned int ID)
- public void wipeRegister(llvm::Register R)
- public void writeRegMask(const llvm::MachineOperand * MO, unsigned int CurBB, unsigned int InstID)
Methods
¶std::string IDAsString(
const LiveDebugValues::ValueIDNum& Num) const
std::string IDAsString(
const LiveDebugValues::ValueIDNum& Num) const
Declared at: llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.h:662
Parameters
- const LiveDebugValues::ValueIDNum& Num
¶std::string LocIdxToName(
LiveDebugValues::LocIdx Idx) const
std::string LocIdxToName(
LiveDebugValues::LocIdx Idx) const
Declared at: llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.h:660
Parameters
¶MLocTracker(llvm::MachineFunction& MF,
const llvm::TargetInstrInfo& TII,
const llvm::TargetRegisterInfo& TRI,
const llvm::TargetLowering& TLI)
MLocTracker(llvm::MachineFunction& MF,
const llvm::TargetInstrInfo& TII,
const llvm::TargetRegisterInfo& TRI,
const llvm::TargetLowering& TLI)
Declared at: llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.h:445
Parameters
- llvm::MachineFunction& MF
- const llvm::TargetInstrInfo& TII
- const llvm::TargetRegisterInfo& TRI
- const llvm::TargetLowering& TLI
¶LiveDebugValues::MLocTracker::MLocIterator begin()
LiveDebugValues::MLocTracker::MLocIterator begin()
Declared at: llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.h:649
¶void clear()
void clear()
Description
Clear all data. Destroys the LocID < => LocIdx map, which makes most of the information in this pass uninterpretable.
Declared at: llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.h:532
¶void defReg(llvm::Register R,
unsigned int BB,
unsigned int Inst)
void defReg(llvm::Register R,
unsigned int BB,
unsigned int Inst)
Description
Record a definition of the specified register at the given block / inst. This doesn't take a ValueIDNum, because the definition and its location are synonymous.
Declared at: llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.h:578
Parameters
- llvm::Register R
- unsigned int BB
- unsigned int Inst
¶void dump()
void dump()
Declared at: llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.h:665
¶void dump_mloc_map()
void dump_mloc_map()
Declared at: llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.h:667
¶llvm::MachineInstrBuilder emitLoc(
Optional<LiveDebugValues::LocIdx> MLoc,
const llvm::DebugVariable& Var,
const LiveDebugValues::DbgValueProperties&
Properties)
llvm::MachineInstrBuilder emitLoc(
Optional<LiveDebugValues::LocIdx> MLoc,
const llvm::DebugVariable& Var,
const LiveDebugValues::DbgValueProperties&
Properties)
Description
Create a DBG_VALUE based on machine location \p MLoc. Qualify it with the information in \pProperties, for variable Var. Don't insert it anywhere, just return the builder for it.
Declared at: llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.h:673
Parameters
- Optional<LiveDebugValues::LocIdx> MLoc
- const llvm::DebugVariable& Var
- const LiveDebugValues::DbgValueProperties& Properties
¶LiveDebugValues::MLocTracker::MLocIterator end()
LiveDebugValues::MLocTracker::MLocIterator end()
Declared at: llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.h:651
¶unsigned int getLocID(llvm::Register Reg)
unsigned int getLocID(llvm::Register Reg)
Description
Produce location ID number for a Register. Provides some small amount of type safety.
Declared at: llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.h:451
Parameters
- llvm::Register Reg
- The register we're looking up.
¶unsigned int getLocID(
LiveDebugValues::SpillLocationNo Spill,
unsigned int SpillSubReg)
unsigned int getLocID(
LiveDebugValues::SpillLocationNo Spill,
unsigned int SpillSubReg)
Description
Produce location ID number for a spill position.
Declared at: llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.h:456
Parameters
- LiveDebugValues::SpillLocationNo Spill
- The number of the spill we're fetching the location for.
- unsigned int SpillSubReg
- Subregister within the spill we're addressing.
¶unsigned int getLocID(
LiveDebugValues::SpillLocationNo Spill,
LiveDebugValues::MLocTracker::StackSlotPos
Idx)
unsigned int getLocID(
LiveDebugValues::SpillLocationNo Spill,
LiveDebugValues::MLocTracker::StackSlotPos
Idx)
Description
Produce location ID number for a spill position.
Declared at: llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.h:465
Parameters
- LiveDebugValues::SpillLocationNo Spill
- The number of the spill we're fetching the location for.\apramSpillIdx size/offset within the spill slot to be addressed.
- LiveDebugValues::MLocTracker::StackSlotPos Idx
¶unsigned int getLocSizeInBits(
LiveDebugValues::LocIdx L) const
unsigned int getLocSizeInBits(
LiveDebugValues::LocIdx L) const
Description
How large is this location (aka, how wide is a value defined there?).
Declared at: llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.h:637
Parameters
¶unsigned int getNumLocs() const
unsigned int getNumLocs() const
Declared at: llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.h:501
¶Optional<LiveDebugValues::SpillLocationNo>
getOrTrackSpillLoc(LiveDebugValues::SpillLoc L)
Optional<LiveDebugValues::SpillLocationNo>
getOrTrackSpillLoc(LiveDebugValues::SpillLoc L)
Description
Find LocIdx for SpillLoc \p L, creating a new one if it's not tracked. Returns None when in scenarios where a spill slot could be tracked, but we would likely run into resource limitations.
Declared at: llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.h:625
Parameters
¶LiveDebugValues::LocIdx getRegMLoc(
llvm::Register R)
LiveDebugValues::LocIdx getRegMLoc(
llvm::Register R)
Description
Determine the LocIdx of an existing register.
Declared at: llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.h:610
Parameters
¶unsigned int getSpillIDWithIdx(
LiveDebugValues::SpillLocationNo Spill,
unsigned int Idx)
unsigned int getSpillIDWithIdx(
LiveDebugValues::SpillLocationNo Spill,
unsigned int Idx)
Description
Given a spill number, and a slot within the spill, calculate the ID number for that location.
Declared at: llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.h:476
Parameters
- LiveDebugValues::SpillLocationNo Spill
- unsigned int Idx
¶LiveDebugValues::LocIdx getSpillMLoc(
unsigned int SpillID)
LiveDebugValues::LocIdx getSpillMLoc(
unsigned int SpillID)
Declared at: llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.h:628
Parameters
- unsigned int SpillID
¶bool isRegisterTracked(llvm::Register R)
bool isRegisterTracked(llvm::Register R)
Description
Is register R currently tracked by MLocTracker?
Declared at: llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.h:570
Parameters
¶bool isSpill(LiveDebugValues::LocIdx Idx) const
bool isSpill(LiveDebugValues::LocIdx Idx) const
Description
Return true if Idx is a spill machine location.
Declared at: llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.h:634
Parameters
¶void loadFromArray(
LiveDebugValues::ValueTable& Locs,
unsigned int NewCurBB)
void loadFromArray(
LiveDebugValues::ValueTable& Locs,
unsigned int NewCurBB)
Description
Load values for each location from array of ValueIDNums. Take current bbnum just in case we read a value from a hitherto untouched register.
Declared at: llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.h:514
Parameters
- LiveDebugValues::ValueTable& Locs
- unsigned int NewCurBB
¶LiveDebugValues::SpillLocationNo locIDToSpill(
unsigned int ID) const
LiveDebugValues::SpillLocationNo locIDToSpill(
unsigned int ID) const
Description
Return the spill number that a location ID corresponds to.
Declared at: llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.h:485
Parameters
- unsigned int ID
¶LiveDebugValues::MLocTracker::StackSlotPos
locIDToSpillIdx(unsigned int ID) const
LiveDebugValues::MLocTracker::StackSlotPos
locIDToSpillIdx(unsigned int ID) const
Description
Returns the spill-slot size/offs that a location ID corresponds to.
Declared at: llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.h:494
Parameters
- unsigned int ID
¶iterator_range<
LiveDebugValues::MLocTracker::MLocIterator>
locations()
iterator_range<
LiveDebugValues::MLocTracker::MLocIterator>
locations()
Description
Return a range over all locations currently tracked.
Declared at: llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.h:656
¶LiveDebugValues::LocIdx lookupOrTrackRegister(
unsigned int ID)
LiveDebugValues::LocIdx lookupOrTrackRegister(
unsigned int ID)
Declared at: llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.h:562
Parameters
- unsigned int ID
¶LiveDebugValues::ValueIDNum readMLoc(
LiveDebugValues::LocIdx L)
LiveDebugValues::ValueIDNum readMLoc(
LiveDebugValues::LocIdx L)
Description
Read the value of a particular location
Declared at: llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.h:553
Parameters
¶LiveDebugValues::ValueIDNum readReg(
llvm::Register R)
LiveDebugValues::ValueIDNum readReg(
llvm::Register R)
Declared at: llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.h:593
Parameters
¶void reset()
void reset()
Description
Wipe any un-necessary location records after traversing a block.
Declared at: llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.h:523
¶void setMLoc(LiveDebugValues::LocIdx L,
LiveDebugValues::ValueIDNum Num)
void setMLoc(LiveDebugValues::LocIdx L,
LiveDebugValues::ValueIDNum Num)
Description
Set a locaiton to a certain value.
Declared at: llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.h:547
Parameters
¶void setMPhis(unsigned int NewCurBB)
void setMPhis(unsigned int NewCurBB)
Description
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).
Declared at: llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.h:506
Parameters
- unsigned int NewCurBB
¶void setReg(llvm::Register R,
LiveDebugValues::ValueIDNum ValueID)
void setReg(llvm::Register R,
LiveDebugValues::ValueIDNum ValueID)
Description
Set a register to a value number. To be used if the value number is known in advance.
Declared at: llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.h:587
Parameters
¶LiveDebugValues::LocIdx trackRegister(
unsigned int ID)
LiveDebugValues::LocIdx trackRegister(
unsigned int ID)
Description
Create a LocIdx for an untracked register ID. Initialize it to either an mphi value representing a live-in, or a recent register mask clobber.
Declared at: llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.h:560
Parameters
- unsigned int ID
¶void wipeRegister(llvm::Register R)
void wipeRegister(llvm::Register R)
Description
Reset a register value to zero / empty. Needed to replicate the VarLoc implementation where a copy to/from a register effectively clears the contents of the source register. (Values can only have one machine location in VarLocBasedImpl).
Declared at: llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.h:603
Parameters
¶void writeRegMask(const llvm::MachineOperand* MO,
unsigned int CurBB,
unsigned int InstID)
void writeRegMask(const llvm::MachineOperand* MO,
unsigned int CurBB,
unsigned int InstID)
Description
Record a RegMask operand being executed. Defs any register we currently track, stores a pointer to the mask in case we have to account for it later.
Declared at: llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.h:620
Parameters
- const llvm::MachineOperand* MO
- unsigned int CurBB
- unsigned int InstID