class TransferTracker

Declaration

class TransferTracker { /* full declaration omitted */ };

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).

Declared at: llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp:174

Member Variables

public const llvm::TargetInstrInfo* TII
public const llvm::TargetLowering* TLI
public LiveDebugValues::MLocTracker* 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?)
public llvm::MachineFunction& MF
public bool ShouldEmitDebugEntryValues
public SmallVector<TransferTracker::Transfer, 32> Transfers
Collection of transfers (DBG_VALUEs) to be inserted.
public SmallVector<LiveDebugValues::ValueIDNum, 32> 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.
public DenseMap<LiveDebugValues::LocIdx, SmallSet<llvm::DebugVariable, 4>> 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].
public DenseMap<llvm::DebugVariable, TransferTracker::LocAndProperties> 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.
public SmallVector<llvm::MachineInstr*, 4> PendingDbgValues
Temporary cache of DBG_VALUEs to be entered into the Transfers collection.
public DenseMap< unsigned int, SmallVector<TransferTracker::UseBeforeDef, 1>> UseBeforeDefs
Map from instruction index (within the block) to the set of UseBeforeDefs that become defined at that instruction.
public DenseSet<llvm::DebugVariable> 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.
public const llvm::TargetRegisterInfo& TRI
public const llvm::BitVector& CalleeSavedRegs

Method Overview

  • public TransferTracker(const llvm::TargetInstrInfo * TII, LiveDebugValues::MLocTracker * MTracker, llvm::MachineFunction & MF, const llvm::TargetRegisterInfo & TRI, const llvm::BitVector & CalleeSavedRegs, const llvm::TargetPassConfig & TPC)
  • public void addUseBeforeDef(const llvm::DebugVariable & Var, const LiveDebugValues::DbgValueProperties & Properties, LiveDebugValues::ValueIDNum ID)
  • public void checkInstForNewValues(unsigned int Inst, MachineBasicBlock::iterator pos)
  • public void clobberMloc(LiveDebugValues::LocIdx MLoc, MachineBasicBlock::iterator Pos, bool MakeUndef = true)
  • public void clobberMloc(LiveDebugValues::LocIdx MLoc, LiveDebugValues::ValueIDNum OldValue, MachineBasicBlock::iterator Pos, bool MakeUndef = true)
  • public llvm::MachineInstrBuilder emitMOLoc(const llvm::MachineOperand & MO, const llvm::DebugVariable & Var, const LiveDebugValues::DbgValueProperties & Properties)
  • public void flushDbgValues(MachineBasicBlock::iterator Pos, llvm::MachineBasicBlock * MBB)
  • public bool isEntryValueValue(const LiveDebugValues::ValueIDNum & Val) const
  • public bool isEntryValueVariable(const llvm::DebugVariable & Var, const llvm::DIExpression * Expr) const
  • public void loadInlocs(llvm::MachineBasicBlock & MBB, LiveDebugValues::ValueTable & MLocs, const SmallVectorImpl<std::pair<DebugVariable, DbgValue>> & VLocs, unsigned int NumLocs)
  • public bool recoverAsEntryValue(const llvm::DebugVariable & Var, const LiveDebugValues::DbgValueProperties & Prop, const LiveDebugValues::ValueIDNum & Num)
  • public void redefVar(const llvm::MachineInstr & MI)
  • public void redefVar(const llvm::MachineInstr & MI, const LiveDebugValues::DbgValueProperties & Properties, Optional<LiveDebugValues::LocIdx> OptNewLoc)
  • public void transferMlocs(LiveDebugValues::LocIdx Src, LiveDebugValues::LocIdx Dst, MachineBasicBlock::iterator Pos)

Methods

TransferTracker(
    const llvm::TargetInstrInfo* TII,
    LiveDebugValues::MLocTracker* MTracker,
    llvm::MachineFunction& MF,
    const llvm::TargetRegisterInfo& TRI,
    const llvm::BitVector& CalleeSavedRegs,
    const llvm::TargetPassConfig& TPC)

Declared at: llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp:245

Parameters

const llvm::TargetInstrInfo* TII
LiveDebugValues::MLocTracker* MTracker
llvm::MachineFunction& MF
const llvm::TargetRegisterInfo& TRI
const llvm::BitVector& CalleeSavedRegs
const llvm::TargetPassConfig& TPC

void addUseBeforeDef(
    const llvm::DebugVariable& Var,
    const LiveDebugValues::DbgValueProperties&
        Properties,
    LiveDebugValues::ValueIDNum ID)

Description

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

Declared at: llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp:354

Parameters

const llvm::DebugVariable& Var
const LiveDebugValues::DbgValueProperties& Properties
LiveDebugValues::ValueIDNum ID

void checkInstForNewValues(
    unsigned int Inst,
    MachineBasicBlock::iterator pos)

Description

After the instruction at index \p Inst and position \p 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.

Declared at: llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp:365

Parameters

unsigned int Inst
MachineBasicBlock::iterator pos

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

Description

Account for a location \p mloc being clobbered. Examine the variable locations that will be terminated: and try to recover them by using another location. Optionally, given \p MakeUndef, emit a DBG_VALUE to explicitly terminate a location if it can't be recovered.

Declared at: llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp:531

Parameters

LiveDebugValues::LocIdx MLoc
MachineBasicBlock::iterator Pos
bool MakeUndef = true

void clobberMloc(
    LiveDebugValues::LocIdx MLoc,
    LiveDebugValues::ValueIDNum OldValue,
    MachineBasicBlock::iterator Pos,
    bool MakeUndef = true)

Description

Overload that takes an explicit value \p OldValue for when the value in\p MLoc has changed and the TransferTracker's locations have not been updated yet.

Declared at: llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp:544

Parameters

LiveDebugValues::LocIdx MLoc
LiveDebugValues::ValueIDNum OldValue
MachineBasicBlock::iterator Pos
bool MakeUndef = true

llvm::MachineInstrBuilder emitMOLoc(
    const llvm::MachineOperand& MO,
    const llvm::DebugVariable& Var,
    const LiveDebugValues::DbgValueProperties&
        Properties)

Declared at: llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp:644

Parameters

const llvm::MachineOperand& MO
const llvm::DebugVariable& Var
const LiveDebugValues::DbgValueProperties& Properties

void flushDbgValues(
    MachineBasicBlock::iterator Pos,
    llvm::MachineBasicBlock* MBB)

Description

Helper to move created DBG_VALUEs into Transfers collection.

Declared at: llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp:391

Parameters

MachineBasicBlock::iterator Pos
llvm::MachineBasicBlock* MBB

bool isEntryValueValue(
    const LiveDebugValues::ValueIDNum& Val) const

Declared at: llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp:420

Parameters

const LiveDebugValues::ValueIDNum& Val

bool isEntryValueVariable(
    const llvm::DebugVariable& Var,
    const llvm::DIExpression* Expr) const

Declared at: llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp:406

Parameters

const llvm::DebugVariable& Var
const llvm::DIExpression* Expr

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

Description

Load object with live-in variable values. \p mlocs contains the live-in values in each machine location, while \p 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 \p mlocs?

Declared at: llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp:262

Parameters

llvm::MachineBasicBlock& MBB
LiveDebugValues::ValueTable& MLocs
const SmallVectorImpl< std::pair<DebugVariable, DbgValue>>& VLocs
unsigned int NumLocs

bool recoverAsEntryValue(
    const llvm::DebugVariable& Var,
    const LiveDebugValues::DbgValueProperties&
        Prop,
    const LiveDebugValues::ValueIDNum& Num)

Declared at: llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp:435

Parameters

const llvm::DebugVariable& Var
const LiveDebugValues::DbgValueProperties& Prop
const LiveDebugValues::ValueIDNum& Num

void redefVar(const llvm::MachineInstr& MI)

Description

Change a variable value after encountering a DBG_VALUE inside a block.

Declared at: llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp:462

Parameters

const llvm::MachineInstr& MI

void redefVar(
    const llvm::MachineInstr& MI,
    const LiveDebugValues::DbgValueProperties&
        Properties,
    Optional<LiveDebugValues::LocIdx> OptNewLoc)

Description

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.

Declared at: llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp:489

Parameters

const llvm::MachineInstr& MI
const LiveDebugValues::DbgValueProperties& Properties
Optional<LiveDebugValues::LocIdx> OptNewLoc

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

Description

Transfer variables based on \p Src to be based on \p Dst. This handles both register copies as well as spills and restores. Creates DBG_VALUEs describing the movement.

Declared at: llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp:611

Parameters

LiveDebugValues::LocIdx Src
LiveDebugValues::LocIdx Dst
MachineBasicBlock::iterator Pos