LLVM  15.0.0git
Classes | Public Member Functions | Public Attributes | List of all members
TransferTracker Class Reference

Tracker for converting machine value locations and variable values into variable locations (the output of LiveDebugValues), recorded as DBG_VALUEs specifying block live-in locations and transfers within blocks. More...

Collaboration diagram for TransferTracker:
Collaboration graph
[legend]

Classes

struct  LocAndProperties
 
struct  Transfer
 Record of all changes in variable locations at a block position. More...
 
struct  UseBeforeDef
 Record of a use-before-def: created when a value that's live-in to the current block isn't available in any machine location, but it will be defined in this block. More...
 

Public Member Functions

 TransferTracker (const TargetInstrInfo *TII, MLocTracker *MTracker, MachineFunction &MF, const TargetRegisterInfo &TRI, const BitVector &CalleeSavedRegs, const TargetPassConfig &TPC)
 
void loadInlocs (MachineBasicBlock &MBB, ValueTable &MLocs, const SmallVectorImpl< std::pair< DebugVariable, DbgValue >> &VLocs, unsigned NumLocs)
 Load object with live-in variable values. More...
 
void addUseBeforeDef (const DebugVariable &Var, const DbgValueProperties &Properties, ValueIDNum ID)
 Record that Var has value ID, a value that becomes available later in the function. More...
 
void checkInstForNewValues (unsigned Inst, MachineBasicBlock::iterator pos)
 After the instruction at index Inst and position pos has been processed, check whether it defines a variable value in a use-before-def. More...
 
void flushDbgValues (MachineBasicBlock::iterator Pos, MachineBasicBlock *MBB)
 Helper to move created DBG_VALUEs into Transfers collection. More...
 
bool isEntryValueVariable (const DebugVariable &Var, const DIExpression *Expr) const
 
bool isEntryValueValue (const ValueIDNum &Val) const
 
bool recoverAsEntryValue (const DebugVariable &Var, const DbgValueProperties &Prop, const ValueIDNum &Num)
 
void redefVar (const MachineInstr &MI)
 Change a variable value after encountering a DBG_VALUE inside a block. More...
 
void redefVar (const MachineInstr &MI, const DbgValueProperties &Properties, Optional< LocIdx > OptNewLoc)
 Handle a change in variable location within a block. More...
 
void clobberMloc (LocIdx MLoc, MachineBasicBlock::iterator Pos, bool MakeUndef=true)
 Account for a location mloc being clobbered. More...
 
void transferMlocs (LocIdx Src, LocIdx Dst, MachineBasicBlock::iterator Pos)
 Transfer variables based on Src to be based on Dst. More...
 
MachineInstrBuilder emitMOLoc (const MachineOperand &MO, const DebugVariable &Var, const DbgValueProperties &Properties)
 

Public Attributes

const TargetInstrInfoTII
 
const TargetLoweringTLI
 
MLocTrackerMTracker
 This machine location tracker is assumed to always contain the up-to-date value mapping for all machine locations. More...
 
MachineFunctionMF
 
bool ShouldEmitDebugEntryValues
 
SmallVector< Transfer, 32 > Transfers
 Collection of transfers (DBG_VALUEs) to be inserted. More...
 
SmallVector< ValueIDNum, 32 > VarLocs
 Local cache of what-value-is-in-what-LocIdx. More...
 
DenseMap< LocIdx, SmallSet< DebugVariable, 4 > > ActiveMLocs
 Map from LocIdxes to which DebugVariables are based that location. More...
 
DenseMap< DebugVariable, LocAndPropertiesActiveVLocs
 Map from DebugVariable to it's current location and qualifying meta information. More...
 
SmallVector< MachineInstr *, 4 > PendingDbgValues
 Temporary cache of DBG_VALUEs to be entered into the Transfers collection. More...
 
DenseMap< unsigned, SmallVector< UseBeforeDef, 1 > > UseBeforeDefs
 Map from instruction index (within the block) to the set of UseBeforeDefs that become defined at that instruction. More...
 
DenseSet< DebugVariableUseBeforeDefVariables
 The set of variables that are in UseBeforeDefs and can become a location once the relevant value is defined. More...
 
const TargetRegisterInfoTRI
 
const BitVectorCalleeSavedRegs
 

Detailed Description

Tracker for converting machine value locations and variable values into variable locations (the output of LiveDebugValues), recorded as DBG_VALUEs specifying block live-in locations and transfers within blocks.

Operating on a per-block basis, this class takes a (pre-loaded) MLocTracker and must be initialized with the set of variable values that are live-in to the block. The caller then repeatedly calls process(). TransferTracker picks out variable locations for the live-in variable values (if there is a location) and creates the corresponding DBG_VALUEs. Then, as the block is stepped through, transfers of values between machine locations are identified and if profitable, a DBG_VALUE created.

This is where debug use-before-defs would be resolved: a variable with an unavailable value could materialize in the middle of a block, when the value becomes available. Or, we could detect clobbers and re-specify the variable in a backup location. (XXX these are unimplemented).

Definition at line 174 of file InstrRefBasedImpl.cpp.

Constructor & Destructor Documentation

◆ TransferTracker()

TransferTracker::TransferTracker ( const TargetInstrInfo TII,
MLocTracker MTracker,
MachineFunction MF,
const TargetRegisterInfo TRI,
const BitVector CalleeSavedRegs,
const TargetPassConfig TPC 
)
inline

Member Function Documentation

◆ addUseBeforeDef()

void TransferTracker::addUseBeforeDef ( const DebugVariable Var,
const DbgValueProperties Properties,
ValueIDNum  ID 
)
inline

Record that Var has value ID, a value that becomes available later in the function.

Definition at line 354 of file InstrRefBasedImpl.cpp.

References llvm::detail::DenseSetImpl< ValueT, MapTy, ValueInfoT >::insert().

◆ checkInstForNewValues()

void TransferTracker::checkInstForNewValues ( unsigned  Inst,
MachineBasicBlock::iterator  pos 
)
inline

◆ clobberMloc()

void TransferTracker::clobberMloc ( LocIdx  MLoc,
MachineBasicBlock::iterator  Pos,
bool  MakeUndef = true 
)
inline

◆ emitMOLoc()

MachineInstrBuilder TransferTracker::emitMOLoc ( const MachineOperand MO,
const DebugVariable Var,
const DbgValueProperties Properties 
)
inline

◆ flushDbgValues()

void TransferTracker::flushDbgValues ( MachineBasicBlock::iterator  Pos,
MachineBasicBlock MBB 
)
inline

Helper to move created DBG_VALUEs into Transfers collection.

Definition at line 391 of file InstrRefBasedImpl.cpp.

References llvm::MachineBasicBlock::begin(), llvm::SmallVectorImpl< T >::clear(), llvm::getBundleStart(), llvm::MachineBasicBlock::instr_begin(), and MBB.

◆ isEntryValueValue()

bool TransferTracker::isEntryValueValue ( const ValueIDNum Val) const
inline

◆ isEntryValueVariable()

bool TransferTracker::isEntryValueVariable ( const DebugVariable Var,
const DIExpression Expr 
) const
inline

◆ loadInlocs()

void TransferTracker::loadInlocs ( MachineBasicBlock MBB,
ValueTable &  MLocs,
const SmallVectorImpl< std::pair< DebugVariable, DbgValue >> &  VLocs,
unsigned  NumLocs 
)
inline

Load object with live-in variable values.

mlocs contains the live-in values in each machine location, while vlocs the live-in variable values. This method picks variable locations for the live-in variables, creates DBG_VALUEs and puts them in Transfers, then prepares the other object fields to track variable locations as we step through the block. FIXME: could just examine mloctracker instead of passing in mlocs?

Definition at line 262 of file InstrRefBasedImpl.cpp.

References LiveDebugValues::LocIdx::asU64(), llvm::MachineBasicBlock::begin(), llvm::detail::DenseSetImpl< ValueT, MapTy, ValueInfoT >::clear(), llvm::DenseMapBase< DenseMap< KeyT, ValueT, DenseMapInfo< KeyT >, llvm::detail::DenseMapPair< KeyT, ValueT > >, KeyT, ValueT, DenseMapInfo< KeyT >, llvm::detail::DenseMapPair< KeyT, ValueT > >::clear(), llvm::SmallVectorImpl< T >::clear(), LiveDebugValues::DbgValue::Const, LiveDebugValues::DbgValue::Def, LiveDebugValues::MLocTracker::emitLoc(), llvm::DenseMapBase< DenseMap< KeyT, ValueT, DenseMapInfo< KeyT >, llvm::detail::DenseMapPair< KeyT, ValueT > >, KeyT, ValueT, DenseMapInfo< KeyT >, llvm::detail::DenseMapPair< KeyT, ValueT > >::end(), llvm::DenseMapBase< DenseMap< KeyT, ValueT, DenseMapInfo< KeyT >, llvm::detail::DenseMapPair< KeyT, ValueT > >, KeyT, ValueT, DenseMapInfo< KeyT >, llvm::detail::DenseMapPair< KeyT, ValueT > >::find(), LiveDebugValues::ValueIDNum::getBlock(), llvm::MachineBasicBlock::getNumber(), llvm::DenseMapBase< DenseMap< KeyT, ValueT, DenseMapInfo< KeyT >, llvm::detail::DenseMapPair< KeyT, ValueT > >, KeyT, ValueT, DenseMapInfo< KeyT >, llvm::detail::DenseMapPair< KeyT, ValueT > >::insert(), LiveDebugValues::LocIdx::isIllegal(), LiveDebugValues::ValueIDNum::isPHI(), LiveDebugValues::MLocTracker::isSpill(), llvm::MCRegAliasIterator::isValid(), LiveDebugValues::MLocTracker::locations(), LiveDebugValues::MLocTracker::LocIdxToLocID, M, LiveDebugValues::LocIdx::MakeIllegalLoc(), MBB, LiveDebugValues::MLocTracker::NumRegs, llvm::DenseMapBase< DenseMap< KeyT, ValueT, DenseMapInfo< KeyT >, llvm::detail::DenseMapPair< KeyT, ValueT > >, KeyT, ValueT, DenseMapInfo< KeyT >, llvm::detail::DenseMapPair< KeyT, ValueT > >::reserve(), llvm::SmallVectorImpl< T >::reserve(), llvm::BitVector::test(), and TRI.

◆ recoverAsEntryValue()

bool TransferTracker::recoverAsEntryValue ( const DebugVariable Var,
const DbgValueProperties Prop,
const ValueIDNum Num 
)
inline

◆ redefVar() [1/2]

void TransferTracker::redefVar ( const MachineInstr MI)
inline

◆ redefVar() [2/2]

void TransferTracker::redefVar ( const MachineInstr MI,
const DbgValueProperties Properties,
Optional< LocIdx OptNewLoc 
)
inline

◆ transferMlocs()

void TransferTracker::transferMlocs ( LocIdx  Src,
LocIdx  Dst,
MachineBasicBlock::iterator  Pos 
)
inline

Member Data Documentation

◆ ActiveMLocs

DenseMap<LocIdx, SmallSet<DebugVariable, 4> > TransferTracker::ActiveMLocs

Map from LocIdxes to which DebugVariables are based that location.

Mantained while stepping through the block. Not accurate if VarLocs[Idx] != MTracker->LocIdxToIDNum[Idx].

Definition at line 211 of file InstrRefBasedImpl.cpp.

◆ ActiveVLocs

DenseMap<DebugVariable, LocAndProperties> TransferTracker::ActiveVLocs

Map from DebugVariable to it's current location and qualifying meta information.

To be used in conjunction with ActiveMLocs to construct enough information for the DBG_VALUEs for a particular LocIdx.

Definition at line 216 of file InstrRefBasedImpl.cpp.

◆ CalleeSavedRegs

const BitVector& TransferTracker::CalleeSavedRegs

Definition at line 243 of file InstrRefBasedImpl.cpp.

◆ MF

MachineFunction& TransferTracker::MF

Definition at line 182 of file InstrRefBasedImpl.cpp.

◆ MTracker

MLocTracker* TransferTracker::MTracker

This machine location tracker is assumed to always contain the up-to-date value mapping for all machine locations.

TransferTracker only reads information from it. (XXX make it const?)

Definition at line 181 of file InstrRefBasedImpl.cpp.

◆ PendingDbgValues

SmallVector<MachineInstr *, 4> TransferTracker::PendingDbgValues

Temporary cache of DBG_VALUEs to be entered into the Transfers collection.

Definition at line 219 of file InstrRefBasedImpl.cpp.

◆ ShouldEmitDebugEntryValues

bool TransferTracker::ShouldEmitDebugEntryValues

Definition at line 183 of file InstrRefBasedImpl.cpp.

◆ TII

const TargetInstrInfo* TransferTracker::TII

Definition at line 176 of file InstrRefBasedImpl.cpp.

◆ TLI

const TargetLowering* TransferTracker::TLI

Definition at line 177 of file InstrRefBasedImpl.cpp.

◆ Transfers

SmallVector<Transfer, 32> TransferTracker::Transfers

Collection of transfers (DBG_VALUEs) to be inserted.

Definition at line 200 of file InstrRefBasedImpl.cpp.

◆ TRI

const TargetRegisterInfo& TransferTracker::TRI

Definition at line 242 of file InstrRefBasedImpl.cpp.

◆ UseBeforeDefs

DenseMap<unsigned, SmallVector<UseBeforeDef, 1> > TransferTracker::UseBeforeDefs

Map from instruction index (within the block) to the set of UseBeforeDefs that become defined at that instruction.

Definition at line 235 of file InstrRefBasedImpl.cpp.

◆ UseBeforeDefVariables

DenseSet<DebugVariable> TransferTracker::UseBeforeDefVariables

The set of variables that are in UseBeforeDefs and can become a location once the relevant value is defined.

An element being erased from this collection prevents the use-before-def materializing.

Definition at line 240 of file InstrRefBasedImpl.cpp.

◆ VarLocs

SmallVector<ValueIDNum, 32> TransferTracker::VarLocs

Local cache of what-value-is-in-what-LocIdx.

Used to identify differences between TransferTrackers view of variable locations and MLocTrackers. For example, MLocTracker observes all clobbers, but TransferTracker lazily does not.

Definition at line 206 of file InstrRefBasedImpl.cpp.


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