LLVM
15.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 | |
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 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. More... | |
MachineFunction & | MF |
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, LocAndProperties > | ActiveVLocs |
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< DebugVariable > | UseBeforeDefVariables |
The set of variables that are in UseBeforeDefs and can become a location once the relevant value is defined. More... | |
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 174 of file InstrRefBasedImpl.cpp.
|
inline |
Definition at line 245 of file InstrRefBasedImpl.cpp.
References llvm::MachineFunction::getSubtarget(), llvm::TargetSubtargetInfo::getTargetLowering(), llvm::TargetPassConfig::getTM(), and TM.
|
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().
|
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 365 of file InstrRefBasedImpl.cpp.
References llvm::detail::DenseSetImpl< ValueT, MapTy, ValueInfoT >::count(), 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(), and LiveDebugValues::MLocTracker::readMLoc().
|
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 531 of file InstrRefBasedImpl.cpp.
References LiveDebugValues::LocIdx::asU64(), LiveDebugValues::MLocTracker::emitLoc(), llvm::detail::DenseSetImpl< ValueT, MapTy, ValueInfoT >::empty(), LiveDebugValues::ValueIDNum::EmptyValue, 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 > >::erase(), llvm::DenseMapBase< DenseMap< KeyT, ValueT, DenseMapInfo< KeyT >, llvm::detail::DenseMapPair< KeyT, ValueT > >, KeyT, ValueT, DenseMapInfo< KeyT >, llvm::detail::DenseMapPair< KeyT, ValueT > >::find(), llvm::detail::DenseSetImpl< ValueT, MapTy, ValueInfoT >::insert(), llvm::DenseMapBase< DenseMap< KeyT, ValueT, DenseMapInfo< KeyT >, llvm::detail::DenseMapPair< KeyT, ValueT > >, KeyT, ValueT, DenseMapInfo< KeyT >, llvm::detail::DenseMapPair< KeyT, ValueT > >::insert(), LiveDebugValues::MLocTracker::locations(), and llvm::None.
|
inline |
Definition at line 633 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, and TII.
|
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.
|
inline |
Definition at line 420 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, and TRI.
|
inline |
Definition at line 406 of file InstrRefBasedImpl.cpp.
References llvm::DebugVariable::getInlinedAt(), llvm::DIExpression::getNumElements(), llvm::DebugVariable::getVariable(), and llvm::DILocalVariable::isParameter().
|
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.
|
inline |
Definition at line 435 of file InstrRefBasedImpl.cpp.
References llvm::MachineOperand::CreateReg(), LiveDebugValues::DbgValueProperties::DIExpr, llvm::DIExpression::EntryValue, LiveDebugValues::ValueIDNum::getLoc(), LiveDebugValues::DbgValueProperties::Indirect, LiveDebugValues::MLocTracker::LocIdxToLocID, and llvm::DIExpression::prepend().
|
inline |
Change a variable value after encountering a DBG_VALUE inside a block.
Definition at line 462 of file InstrRefBasedImpl.cpp.
References llvm::DenseMapBase< DenseMap< KeyT, ValueT, DenseMapInfo< KeyT >, llvm::detail::DenseMapPair< KeyT, ValueT > >, KeyT, ValueT, DenseMapInfo< KeyT >, llvm::detail::DenseMapPair< KeyT, ValueT > >::end(), llvm::detail::DenseSetImpl< ValueT, MapTy, ValueInfoT >::erase(), llvm::DenseMapBase< DenseMap< KeyT, ValueT, DenseMapInfo< KeyT >, llvm::detail::DenseMapPair< KeyT, ValueT > >, KeyT, ValueT, DenseMapInfo< KeyT >, llvm::detail::DenseMapPair< KeyT, ValueT > >::erase(), llvm::DenseMapBase< DenseMap< KeyT, ValueT, DenseMapInfo< KeyT >, llvm::detail::DenseMapPair< KeyT, ValueT > >, KeyT, ValueT, DenseMapInfo< KeyT >, llvm::detail::DenseMapPair< KeyT, ValueT > >::find(), llvm::MachineOperand::getReg(), LiveDebugValues::MLocTracker::getRegMLoc(), llvm::MachineOperand::isReg(), and MI.
|
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 489 of file InstrRefBasedImpl.cpp.
References LiveDebugValues::LocIdx::asU64(), llvm::DenseMapBase< DenseMap< KeyT, ValueT, DenseMapInfo< KeyT >, llvm::detail::DenseMapPair< KeyT, ValueT > >, KeyT, ValueT, DenseMapInfo< KeyT >, llvm::detail::DenseMapPair< KeyT, ValueT > >::clear(), llvm::DenseMapBase< DenseMap< KeyT, ValueT, DenseMapInfo< KeyT >, llvm::detail::DenseMapPair< KeyT, ValueT > >, KeyT, ValueT, DenseMapInfo< KeyT >, llvm::detail::DenseMapPair< KeyT, ValueT > >::end(), llvm::detail::DenseSetImpl< ValueT, MapTy, ValueInfoT >::erase(), llvm::DenseMapBase< DenseMap< KeyT, ValueT, DenseMapInfo< KeyT >, llvm::detail::DenseMapPair< KeyT, ValueT > >, KeyT, ValueT, DenseMapInfo< KeyT >, llvm::detail::DenseMapPair< KeyT, ValueT > >::erase(), llvm::DenseMapBase< DenseMap< KeyT, ValueT, DenseMapInfo< KeyT >, llvm::detail::DenseMapPair< KeyT, ValueT > >, KeyT, ValueT, DenseMapInfo< KeyT >, llvm::detail::DenseMapPair< KeyT, ValueT > >::find(), llvm::DenseMapBase< DenseMap< KeyT, ValueT, DenseMapInfo< KeyT >, llvm::detail::DenseMapPair< KeyT, ValueT > >, KeyT, ValueT, DenseMapInfo< KeyT >, llvm::detail::DenseMapPair< KeyT, ValueT > >::insert(), MI, P, and LiveDebugValues::MLocTracker::readMLoc().
|
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 600 of file InstrRefBasedImpl.cpp.
References assert(), llvm::DenseMapBase< DenseMap< KeyT, ValueT, DenseMapInfo< KeyT >, llvm::detail::DenseMapPair< KeyT, ValueT > >, KeyT, ValueT, DenseMapInfo< KeyT >, llvm::detail::DenseMapPair< KeyT, ValueT > >::clear(), LiveDebugValues::MLocTracker::emitLoc(), LiveDebugValues::ValueIDNum::EmptyValue, EmulateOldLDV, 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(), MI, and LiveDebugValues::MLocTracker::readMLoc().
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.
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.
Definition at line 243 of file InstrRefBasedImpl.cpp.
MachineFunction& TransferTracker::MF |
Definition at line 182 of file InstrRefBasedImpl.cpp.
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.
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.
bool TransferTracker::ShouldEmitDebugEntryValues |
Definition at line 183 of file InstrRefBasedImpl.cpp.
const TargetInstrInfo* TransferTracker::TII |
Definition at line 176 of file InstrRefBasedImpl.cpp.
const TargetLowering* TransferTracker::TLI |
Definition at line 177 of file InstrRefBasedImpl.cpp.
SmallVector<Transfer, 32> TransferTracker::Transfers |
Collection of transfers (DBG_VALUEs) to be inserted.
Definition at line 200 of file InstrRefBasedImpl.cpp.
const TargetRegisterInfo& TransferTracker::TRI |
Definition at line 242 of file InstrRefBasedImpl.cpp.
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.
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.
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.