LLVM: TransferTracker Class Reference (original) (raw)
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 Member Functions | |
|---|---|
| TransferTracker (const TargetInstrInfo *TII, MLocTracker *MTracker, MachineFunction &MF, const DebugVariableMap &DVMap, const TargetRegisterInfo &TRI, const BitVector &CalleeSavedRegs, bool ShouldEmitDebugEntryValues) | |
| 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) |
| 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 176 of file InstrRefBasedImpl.cpp.
◆ ValueLocPair
◆ LocationQuality
◆ addUseBeforeDef()
◆ checkInstForNewValues()
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 531 of file InstrRefBasedImpl.cpp.
References assert(), DVMap, 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(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::insert(), LiveDebugValues::LocIdx::isIllegal(), MTracker, PendingDbgValues, llvm::SmallVectorTemplateBase< T, bool >::push_back(), llvm::SmallVectorTemplateCommon< T, typename >::size(), UseBeforeDefs, UseBeforeDefVariables, and LiveDebugValues::ValueIDNum::Value.
◆ clobberMloc() [1/2]
◆ clobberMloc() [2/2]
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 831 of file InstrRefBasedImpl.cpp.
References ActiveMLocs, ActiveVLocs, assert(), LiveDebugValues::LocIdx::asU64(), llvm::SmallVectorTemplateCommon< T, typename >::begin(), DVMap, llvm::SmallVectorImpl< T >::emplace_back(), llvm::detail::DenseSetImpl< ValueT, MapTy, ValueInfoT >::empty(), LiveDebugValues::ValueIDNum::EmptyValue, flushDbgValues(), llvm::detail::DenseSetImpl< ValueT, MapTy, ValueInfoT >::insert(), llvm::SmallVectorImpl< T >::insert(), LiveDebugValues::LocIdx::MakeIllegalLoc(), MTracker, PendingDbgValues, recoverAsEntryValue(), llvm::replace_copy(), and VarLocs.
◆ emitMOLoc()
Definition at line 965 of file InstrRefBasedImpl.cpp.
References llvm::BuildMI(), LiveDebugValues::DbgValueProperties::DIExpr, DL, llvm::MDNode::get(), llvm::MDNode::getContext(), llvm::DebugVariable::getInlinedAt(), llvm::DILocalVariable::getScope(), llvm::DebugVariable::getVariable(), LiveDebugValues::DbgValueProperties::Indirect, MF, and TII.
Referenced by recoverAsEntryValue().
◆ flushDbgValues()
◆ getLocQualityIfBetter()
| std::optional< LocationQuality > TransferTracker::getLocQualityIfBetter ( LocIdx L, LocationQuality Min ) const | inline |
|---|
◆ isCalleeSaved()
| bool TransferTracker::isCalleeSaved ( LocIdx L) const | inline |
|---|
◆ isEntryValueValue()
◆ isEntryValueVariable()
◆ loadInlocs()
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 459 of file InstrRefBasedImpl.cpp.
References ActiveMLocs, ActiveVLocs, LiveDebugValues::LocIdx::asU64(), LiveDebugValues::DbgValue::Def, LiveDebugValues::ValueIDNum::EmptyValue, llvm::SmallVectorTemplateCommon< T, typename >::end(), LiveDebugValues::DbgOpIDMap::find(), flushDbgValues(), getLocQualityIfBetter(), LiveDebugValues::DbgOp::ID, loadVarInloc(), llvm::lower_bound(), MBB, MTracker, llvm::SmallVectorTemplateBase< T, bool >::push_back(), llvm::sort(), UseBeforeDefs, UseBeforeDefVariables, ValueToLocSort(), and VarLocs.
◆ loadVarInloc()
For a variable Var with the live-in value [Value](classllvm%5F1%5F1Value.html "LLVM Value Representation."), 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 355 of file InstrRefBasedImpl.cpp.
References ActiveMLocs, ActiveVLocs, addUseBeforeDef(), assert(), DVMap, llvm::SmallVectorTemplateCommon< T, typename >::end(), LiveDebugValues::DbgOpIDMap::find(), LiveDebugValues::ValueIDNum::getBlock(), LiveDebugValues::ValueIDNum::getInst(), LiveDebugValues::ValueIDNum::isPHI(), llvm::lower_bound(), MBB, MTracker, PendingDbgValues, llvm::SmallVectorTemplateBase< T, bool >::push_back(), recoverAsEntryValue(), and ValueToLocSort().
Referenced by loadInlocs().
◆ recoverAsEntryValue()
Definition at line 657 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, llvm::DIExpression::isEntryValue(), isEntryValueValue(), isEntryValueVariable(), LiveDebugValues::DbgValueProperties::IsVariadic, MTracker, PendingDbgValues, llvm::DIExpression::prepend(), Register, and ShouldEmitDebugEntryValues.
Referenced by clobberMloc(), and loadVarInloc().
◆ redefVar() [1/2]
Change a variable value after encountering a DBG_VALUE inside a block.
Definition at line 709 of file InstrRefBasedImpl.cpp.
References ActiveMLocs, ActiveVLocs, llvm::all_of(), DVMap, llvm::MachineOperand::getReg(), llvm::MachineOperand::isReg(), MI, MTracker, llvm::SmallVectorTemplateBase< T, bool >::push_back(), redefVar(), Register, and UseBeforeDefVariables.
Referenced by redefVar().
◆ redefVar() [2/2]
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 748 of file InstrRefBasedImpl.cpp.
References ActiveMLocs, ActiveVLocs, LiveDebugValues::LocIdx::asU64(), DVMap, llvm::SmallVectorImpl< T >::emplace_back(), llvm::SmallVectorTemplateCommon< T, typename >::empty(), MI, MTracker, P, UseBeforeDefVariables, and VarLocs.
◆ transferMlocs()
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 927 of file InstrRefBasedImpl.cpp.
References ActiveMLocs, ActiveVLocs, assert(), DVMap, LiveDebugValues::ValueIDNum::EmptyValue, EmulateOldLDV, flushDbgValues(), MI, MTracker, PendingDbgValues, llvm::replace(), and VarLocs.
◆ ValueToLocSort()
◆ ActiveMLocs
◆ ActiveVLocs
◆ CalleeSavedRegs
◆ DVMap
◆ MF
◆ 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 183 of file InstrRefBasedImpl.cpp.
Referenced by checkInstForNewValues(), clobberMloc(), getLocQualityIfBetter(), isCalleeSaved(), isEntryValueValue(), loadInlocs(), loadVarInloc(), recoverAsEntryValue(), redefVar(), redefVar(), transferMlocs(), and TransferTracker().
◆ PendingDbgValues
◆ ShouldEmitDebugEntryValues
bool TransferTracker::ShouldEmitDebugEntryValues
◆ TII
◆ TLI
◆ Transfers
◆ TRI
◆ UseBeforeDefs
◆ UseBeforeDefVariables
◆ VarLocs
The documentation for this class was generated from the following file:
- lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp