LLVM 20.0.0git
|
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...
Classes | |
class | LocationAndQuality |
struct | ResolvedDbgValue |
Stores the resolved operands (machine locations and constants) and qualifying meta-information needed to construct a concrete DBG_VALUE-like instruction. More... | |
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 Types | |
enum class | LocationQuality : unsigned char { Illegal = 0 , Register , CalleeSavedRegister , SpillSlot , Best = SpillSlot } |
using | ValueLocPair = std::pair< ValueIDNum, LocationAndQuality > |
Public Member Functions | |
TransferTracker (const TargetInstrInfo *TII, MLocTracker *MTracker, MachineFunction &MF, const DebugVariableMap &DVMap, const TargetRegisterInfo &TRI, const BitVector &CalleeSavedRegs, const TargetPassConfig &TPC) | |
bool | isCalleeSaved (LocIdx L) const |
std::optional< LocationQuality > | getLocQualityIfBetter (LocIdx L, LocationQuality Min) const |
void | loadVarInloc (MachineBasicBlock &MBB, DbgOpIDMap &DbgOpStore, const SmallVectorImpl< ValueLocPair > &ValueToLoc, DebugVariableID VarID, DbgValue Value) |
For a variable Var with the live-in value Value , attempts to resolve the DbgValue to a concrete DBG_VALUE, emitting that value and loading the tracking information to track Var throughout the block. | |
void | loadInlocs (MachineBasicBlock &MBB, ValueTable &MLocs, DbgOpIDMap &DbgOpStore, const SmallVectorImpl< std::pair< DebugVariableID, DbgValue > > &VLocs, unsigned NumLocs) |
Load object with live-in variable values. | |
void | addUseBeforeDef (DebugVariableID VarID, const DbgValueProperties &Properties, const SmallVectorImpl< DbgOp > &DbgOps, unsigned Inst) |
Record that Var has value ID , a value that becomes available later in the function. | |
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. | |
void | flushDbgValues (MachineBasicBlock::iterator Pos, MachineBasicBlock *MBB) |
Helper to move created DBG_VALUEs into Transfers collection. | |
bool | isEntryValueVariable (const DebugVariable &Var, const DIExpression *Expr) const |
bool | isEntryValueValue (const ValueIDNum &Val) const |
bool | recoverAsEntryValue (DebugVariableID VarID, const DbgValueProperties &Prop, const ValueIDNum &Num) |
void | redefVar (const MachineInstr &MI) |
Change a variable value after encountering a DBG_VALUE inside a block. | |
void | redefVar (const MachineInstr &MI, const DbgValueProperties &Properties, SmallVectorImpl< ResolvedDbgOp > &NewLocs) |
Handle a change in variable location within a block. | |
void | clobberMloc (LocIdx MLoc, MachineBasicBlock::iterator Pos, bool MakeUndef=true) |
Account for a location mloc being clobbered. | |
void | clobberMloc (LocIdx MLoc, ValueIDNum OldValue, MachineBasicBlock::iterator Pos, bool MakeUndef=true) |
Overload that takes an explicit value OldValue for when the value in MLoc has changed and the TransferTracker's locations have not been updated yet. | |
void | transferMlocs (LocIdx Src, LocIdx Dst, MachineBasicBlock::iterator Pos) |
Transfer variables based on Src to be based on Dst . | |
MachineInstrBuilder | emitMOLoc (const MachineOperand &MO, const DebugVariable &Var, const DbgValueProperties &Properties) |
Static Public Member Functions | |
static bool | ValueToLocSort (const ValueLocPair &A, const ValueLocPair &B) |
Public Attributes | |
const TargetInstrInfo * | TII |
const TargetLowering * | TLI |
MLocTracker * | MTracker |
This machine location tracker is assumed to always contain the up-to-date value mapping for all machine locations. | |
MachineFunction & | MF |
const DebugVariableMap & | DVMap |
bool | ShouldEmitDebugEntryValues |
SmallVector< Transfer, 32 > | Transfers |
Collection of transfers (DBG_VALUEs) to be inserted. | |
SmallVector< ValueIDNum, 32 > | VarLocs |
Local cache of what-value-is-in-what-LocIdx. | |
DenseMap< LocIdx, SmallSet< DebugVariableID, 4 > > | ActiveMLocs |
Map from LocIdxes to which DebugVariables are based that location. | |
DenseMap< DebugVariableID, ResolvedDbgValue > | ActiveVLocs |
Map from DebugVariable to it's current location and qualifying meta information. | |
SmallVector< std::pair< DebugVariableID, MachineInstr * >, 4 > | PendingDbgValues |
Temporary cache of DBG_VALUEs to be entered into the Transfers collection. | |
DenseMap< unsigned, SmallVector< UseBeforeDef, 1 > > | UseBeforeDefs |
Map from instruction index (within the block) to the set of UseBeforeDefs that become defined at that instruction. | |
DenseSet< DebugVariableID > | UseBeforeDefVariables |
The set of variables that are in UseBeforeDefs and can become a location once the relevant value is defined. | |
const TargetRegisterInfo & | TRI |
const BitVector & | CalleeSavedRegs |
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 177 of file InstrRefBasedImpl.cpp.
using TransferTracker::ValueLocPair = std::pair<ValueIDNum, LocationAndQuality> |
Definition at line 322 of file InstrRefBasedImpl.cpp.
|
strong |
Enumerator | |
---|---|
Illegal | |
Register | |
CalleeSavedRegister | |
SpillSlot | |
Best |
Definition at line 296 of file InstrRefBasedImpl.cpp.
|
inline |
Definition at line 270 of file InstrRefBasedImpl.cpp.
References llvm::MachineFunction::getSubtarget(), llvm::TargetSubtargetInfo::getTargetLowering(), llvm::TargetPassConfig::getTM(), MF, ShouldEmitDebugEntryValues, TLI, and TM.
|
inline |
Record that Var
has value ID
, a value that becomes available later in the function.
Definition at line 513 of file InstrRefBasedImpl.cpp.
References llvm::detail::DenseSetImpl< ValueT, MapTy, ValueInfoT >::insert(), UseBeforeDefs, and UseBeforeDefVariables.
Referenced by loadVarInloc().
|
inline |
After the instruction at index Inst
and position pos
has been processed, check whether it defines a variable value in a use-before-def.
If so, and the variable value hasn't changed since the start of the block, create a DBG_VALUE.
Definition at line 524 of file InstrRefBasedImpl.cpp.
References assert(), llvm::detail::DenseSetImpl< ValueT, MapTy, ValueInfoT >::count(), DVMap, LiveDebugValues::MLocTracker::emitLoc(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::empty(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::end(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::find(), flushDbgValues(), getLocQualityIfBetter(), Idx, llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::insert(), LiveDebugValues::LocIdx::isIllegal(), LiveDebugValues::MLocTracker::locations(), LiveDebugValues::DebugVariableMap::lookupDVID(), MTracker, PendingDbgValues, llvm::SmallVectorTemplateBase< T, bool >::push_back(), llvm::SmallVectorBase< Size_T >::size(), UseBeforeDefs, and UseBeforeDefVariables.
|
inline |
Account for a location mloc
being clobbered.
Examine the variable locations that will be terminated: and try to recover them by using another location. Optionally, given MakeUndef
, emit a DBG_VALUE to explicitly terminate a location if it can't be recovered.
Definition at line 801 of file InstrRefBasedImpl.cpp.
References ActiveMLocs, LiveDebugValues::LocIdx::asU64(), clobberMloc(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::end(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::find(), and VarLocs.
Referenced by clobberMloc().
|
inline |
Overload that takes an explicit value OldValue
for when the value in MLoc
has changed and the TransferTracker's locations have not been updated yet.
Definition at line 814 of file InstrRefBasedImpl.cpp.
References ActiveMLocs, ActiveVLocs, assert(), LiveDebugValues::LocIdx::asU64(), llvm::SmallVectorTemplateCommon< T, typename >::begin(), DVMap, LiveDebugValues::MLocTracker::emitLoc(), llvm::SmallVectorImpl< T >::emplace_back(), llvm::detail::DenseSetImpl< ValueT, MapTy, ValueInfoT >::empty(), LiveDebugValues::ValueIDNum::EmptyValue, llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::end(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::find(), flushDbgValues(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::insert(), llvm::detail::DenseSetImpl< ValueT, MapTy, ValueInfoT >::insert(), llvm::SmallVectorImpl< T >::insert(), LiveDebugValues::MLocTracker::locations(), LiveDebugValues::DebugVariableMap::lookupDVID(), LiveDebugValues::LocIdx::MakeIllegalLoc(), MTracker, PendingDbgValues, llvm::SmallVectorTemplateBase< T, bool >::push_back(), recoverAsEntryValue(), llvm::replace_copy(), and VarLocs.
|
inline |
Definition at line 950 of file InstrRefBasedImpl.cpp.
References llvm::BuildMI(), LiveDebugValues::DbgValueProperties::DIExpr, DL, llvm::MCInstrInfo::get(), llvm::MDNode::getContext(), llvm::DebugVariable::getInlinedAt(), llvm::DILocalVariable::getScope(), llvm::DebugVariable::getVariable(), LiveDebugValues::DbgValueProperties::Indirect, MF, and TII.
Referenced by recoverAsEntryValue().
|
inline |
Helper to move created DBG_VALUEs into Transfers collection.
Definition at line 606 of file InstrRefBasedImpl.cpp.
References llvm::MachineBasicBlock::begin(), llvm::SmallVectorImpl< T >::clear(), llvm::getBundleStart(), llvm::MachineBasicBlock::instr_begin(), MBB, PendingDbgValues, llvm::SmallVectorBase< Size_T >::size(), and Transfers.
Referenced by checkInstForNewValues(), clobberMloc(), loadInlocs(), and transferMlocs().
|
inline |
Definition at line 332 of file InstrRefBasedImpl.cpp.
References CalleeSavedRegister, isCalleeSaved(), LiveDebugValues::MLocTracker::isSpill(), MTracker, Register, and SpillSlot.
Referenced by checkInstForNewValues(), and loadInlocs().
Definition at line 281 of file InstrRefBasedImpl.cpp.
References CalleeSavedRegs, llvm::MCRegAliasIterator::isValid(), LiveDebugValues::MLocTracker::LocIdxToLocID, MTracker, LiveDebugValues::MLocTracker::NumRegs, llvm::BitVector::test(), and TRI.
Referenced by getLocQualityIfBetter().
|
inline |
Definition at line 635 of file InstrRefBasedImpl.cpp.
References FP, LiveDebugValues::ValueIDNum::getBlock(), llvm::TargetRegisterInfo::getFrameRegister(), LiveDebugValues::ValueIDNum::getLoc(), llvm::TargetLoweringBase::getStackPointerRegisterToSaveRestore(), LiveDebugValues::ValueIDNum::isPHI(), LiveDebugValues::MLocTracker::isSpill(), LiveDebugValues::MLocTracker::LocIdxToLocID, MF, MTracker, TLI, and TRI.
Referenced by recoverAsEntryValue().
|
inline |
Definition at line 621 of file InstrRefBasedImpl.cpp.
References llvm::DebugVariable::getInlinedAt(), llvm::DIExpression::getNumElements(), llvm::DebugVariable::getVariable(), llvm::DIExpression::isDeref(), and llvm::DILocalVariable::isParameter().
Referenced by recoverAsEntryValue().
|
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 451 of file InstrRefBasedImpl.cpp.
References ActiveMLocs, ActiveVLocs, llvm::SmallVectorTemplateCommon< T, typename >::begin(), llvm::MachineBasicBlock::begin(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::clear(), llvm::detail::DenseSetImpl< ValueT, MapTy, ValueInfoT >::clear(), llvm::SmallVectorImpl< T >::clear(), LiveDebugValues::DbgValue::Def, LiveDebugValues::ValueIDNum::EmptyValue, llvm::SmallVectorTemplateCommon< T, typename >::end(), LiveDebugValues::DbgOpIDMap::find(), flushDbgValues(), getLocQualityIfBetter(), Idx, loadVarInloc(), LiveDebugValues::MLocTracker::locations(), MBB, MTracker, llvm::SmallVectorTemplateBase< T, bool >::push_back(), llvm::SmallVectorImpl< T >::reserve(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::reserve(), llvm::sort(), UseBeforeDefs, UseBeforeDefVariables, ValueToLocSort(), and VarLocs.
|
inline |
For a variable Var
with the live-in value Value
, attempts to resolve the DbgValue to a concrete DBG_VALUE, emitting that value and loading the tracking information to track Var throughout the block.
ValueToLoc
is a map containing the best known location for every ValueIDNum that Value may use. MBB
is the basic block that we are loading the live-in value for. DbgOpStore
is the map containing the DbgOpID->DbgOp mapping needed to determine the values used by Value.
Definition at line 356 of file InstrRefBasedImpl.cpp.
References ActiveMLocs, ActiveVLocs, addUseBeforeDef(), assert(), llvm::SmallVectorTemplateCommon< T, typename >::begin(), DVMap, LiveDebugValues::MLocTracker::emitLoc(), llvm::SmallVectorTemplateCommon< T, typename >::end(), LiveDebugValues::DbgOpIDMap::find(), LiveDebugValues::ValueIDNum::getBlock(), LiveDebugValues::ValueIDNum::getInst(), llvm::MachineBasicBlock::getNumber(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::insert(), LiveDebugValues::ValueIDNum::isPHI(), LiveDebugValues::DebugVariableMap::lookupDVID(), MBB, MTracker, PendingDbgValues, llvm::SmallVectorTemplateBase< T, bool >::push_back(), recoverAsEntryValue(), and ValueToLocSort().
Referenced by loadInlocs().
|
inline |
Definition at line 650 of file InstrRefBasedImpl.cpp.
References llvm::DIExpression::convertToNonVariadicExpression(), llvm::MachineOperand::CreateReg(), LiveDebugValues::DbgValueProperties::DIExpr, DVMap, emitMOLoc(), llvm::DIExpression::EntryValue, LiveDebugValues::ValueIDNum::getLoc(), LiveDebugValues::DbgValueProperties::Indirect, isEntryValueValue(), isEntryValueVariable(), LiveDebugValues::DbgValueProperties::IsVariadic, LiveDebugValues::MLocTracker::LocIdxToLocID, LiveDebugValues::DebugVariableMap::lookupDVID(), MTracker, PendingDbgValues, llvm::DIExpression::prepend(), llvm::SmallVectorTemplateBase< T, bool >::push_back(), and ShouldEmitDebugEntryValues.
Referenced by clobberMloc(), and loadVarInloc().
|
inline |
Change a variable value after encountering a DBG_VALUE inside a block.
Definition at line 692 of file InstrRefBasedImpl.cpp.
References ActiveMLocs, ActiveVLocs, llvm::all_of(), DVMap, llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::erase(), llvm::detail::DenseSetImpl< ValueT, MapTy, ValueInfoT >::erase(), LiveDebugValues::DebugVariableMap::getDVID(), llvm::MachineOperand::getReg(), LiveDebugValues::MLocTracker::getRegMLoc(), llvm::MachineOperand::isReg(), MI, MTracker, llvm::SmallVectorTemplateBase< T, bool >::push_back(), redefVar(), and UseBeforeDefVariables.
Referenced by redefVar().
|
inline |
Handle a change in variable location within a block.
Terminate the variables current location, and record the value it now refers to, so that we can detect location transfers later on.
Definition at line 731 of file InstrRefBasedImpl.cpp.
References ActiveMLocs, ActiveVLocs, LiveDebugValues::LocIdx::asU64(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::clear(), DVMap, llvm::SmallVectorImpl< T >::emplace_back(), llvm::SmallVectorBase< Size_T >::empty(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::erase(), llvm::detail::DenseSetImpl< ValueT, MapTy, ValueInfoT >::erase(), LiveDebugValues::DebugVariableMap::getDVID(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::insert(), MI, MTracker, P, LiveDebugValues::MLocTracker::readMLoc(), UseBeforeDefVariables, and VarLocs.
|
inline |
Transfer variables based on Src
to be based on Dst
.
This handles both register copies as well as spills and restores. Creates DBG_VALUEs describing the movement.
Definition at line 911 of file InstrRefBasedImpl.cpp.
References ActiveMLocs, ActiveVLocs, assert(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::clear(), DVMap, LiveDebugValues::MLocTracker::emitLoc(), LiveDebugValues::ValueIDNum::EmptyValue, EmulateOldLDV, flushDbgValues(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::insert(), LiveDebugValues::DebugVariableMap::lookupDVID(), MI, MTracker, PendingDbgValues, llvm::SmallVectorTemplateBase< T, bool >::push_back(), LiveDebugValues::MLocTracker::readMLoc(), and VarLocs.
|
inlinestatic |
Definition at line 324 of file InstrRefBasedImpl.cpp.
Referenced by loadInlocs(), and loadVarInloc().
DenseMap<LocIdx, SmallSet<DebugVariableID, 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 233 of file InstrRefBasedImpl.cpp.
Referenced by clobberMloc(), loadInlocs(), loadVarInloc(), redefVar(), and transferMlocs().
DenseMap<DebugVariableID, ResolvedDbgValue> 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 238 of file InstrRefBasedImpl.cpp.
Referenced by clobberMloc(), loadInlocs(), loadVarInloc(), redefVar(), and transferMlocs().
Definition at line 268 of file InstrRefBasedImpl.cpp.
Referenced by isCalleeSaved().
const DebugVariableMap& TransferTracker::DVMap |
Definition at line 186 of file InstrRefBasedImpl.cpp.
Referenced by checkInstForNewValues(), clobberMloc(), loadVarInloc(), recoverAsEntryValue(), redefVar(), and transferMlocs().
MachineFunction& TransferTracker::MF |
Definition at line 185 of file InstrRefBasedImpl.cpp.
Referenced by emitMOLoc(), isEntryValueValue(), and TransferTracker().
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 184 of file InstrRefBasedImpl.cpp.
Referenced by checkInstForNewValues(), clobberMloc(), getLocQualityIfBetter(), isCalleeSaved(), isEntryValueValue(), loadInlocs(), loadVarInloc(), recoverAsEntryValue(), redefVar(), and transferMlocs().
SmallVector<std::pair<DebugVariableID, MachineInstr *>, 4> TransferTracker::PendingDbgValues |
Temporary cache of DBG_VALUEs to be entered into the Transfers collection.
Definition at line 241 of file InstrRefBasedImpl.cpp.
Referenced by checkInstForNewValues(), clobberMloc(), flushDbgValues(), loadVarInloc(), recoverAsEntryValue(), and transferMlocs().
bool TransferTracker::ShouldEmitDebugEntryValues |
Definition at line 187 of file InstrRefBasedImpl.cpp.
Referenced by recoverAsEntryValue(), and TransferTracker().
const TargetInstrInfo* TransferTracker::TII |
Definition at line 179 of file InstrRefBasedImpl.cpp.
Referenced by emitMOLoc().
const TargetLowering* TransferTracker::TLI |
Definition at line 180 of file InstrRefBasedImpl.cpp.
Referenced by isEntryValueValue(), and TransferTracker().
SmallVector<Transfer, 32> TransferTracker::Transfers |
Collection of transfers (DBG_VALUEs) to be inserted.
Definition at line 222 of file InstrRefBasedImpl.cpp.
Referenced by flushDbgValues().
const TargetRegisterInfo& TransferTracker::TRI |
Definition at line 267 of file InstrRefBasedImpl.cpp.
Referenced by isCalleeSaved(), and isEntryValueValue().
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 260 of file InstrRefBasedImpl.cpp.
Referenced by addUseBeforeDef(), checkInstForNewValues(), and loadInlocs().
DenseSet<DebugVariableID> 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 265 of file InstrRefBasedImpl.cpp.
Referenced by addUseBeforeDef(), checkInstForNewValues(), loadInlocs(), and redefVar().
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 228 of file InstrRefBasedImpl.cpp.
Referenced by clobberMloc(), loadInlocs(), redefVar(), and transferMlocs().