LLVM 19.0.0git
Classes | Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Friends | List of all members
llvm::DPValue Class Reference

Record of a variable value-assignment, aka a non instruction representation of the dbg.value intrinsic. More...

#include "llvm/IR/DebugProgramInstruction.h"

Inheritance diagram for llvm::DPValue:
Inheritance graph
[legend]

Classes

class  location_op_iterator
 Iterator for ValueAsMetadata that internally uses direct pointer iteration over either a ValueAsMetadata* or a ValueAsMetadata**, dereferencing to the ValueAsMetadata . More...
 

Public Types

enum class  LocationType : uint8_t {
  Declare , Value , Assign , End ,
  Any
}
 
- Public Types inherited from llvm::DbgRecord
enum  Kind : uint8_t { ValueKind , LabelKind }
 Subclass discriminator. More...
 
using self_iterator = simple_ilist< DbgRecord >::iterator
 
using const_self_iterator = simple_ilist< DbgRecord >::const_iterator
 

Public Member Functions

 DPValue (const DbgVariableIntrinsic *DVI)
 Create a new DPValue representing the intrinsic DVI, for example the assignment represented by a dbg.value.
 
 DPValue (const DPValue &DPV)
 
 DPValue (Metadata *Location, DILocalVariable *DV, DIExpression *Expr, const DILocation *DI, LocationType Type=LocationType::Value)
 Directly construct a new DPValue representing a dbg.value intrinsic assigning Location to the DV / Expr / DI variable.
 
 DPValue (Metadata *Value, DILocalVariable *Variable, DIExpression *Expression, DIAssignID *AssignID, Metadata *Address, DIExpression *AddressExpression, const DILocation *DI)
 
bool isDbgDeclare ()
 
bool isDbgValue ()
 
iterator_range< location_op_iteratorlocation_ops () const
 Get the locations corresponding to the variable referenced by the debug info intrinsic.
 
ValuegetVariableLocationOp (unsigned OpIdx) const
 
void replaceVariableLocationOp (Value *OldValue, Value *NewValue, bool AllowEmpty=false)
 
void replaceVariableLocationOp (unsigned OpIdx, Value *NewValue)
 
void addVariableLocationOps (ArrayRef< Value * > NewValues, DIExpression *NewExpr)
 Adding a new location operand will always result in this intrinsic using an ArgList, and must always be accompanied by a new expression that uses the new operand.
 
void setVariable (DILocalVariable *NewVar)
 
void setExpression (DIExpression *NewExpr)
 
unsigned getNumVariableLocationOps () const
 
bool hasArgList () const
 
bool hasValidLocation () const
 Returns true if this DPValue has no empty MDNodes in its location list.
 
bool isAddressOfVariable () const
 Does this describe the address of a local variable.
 
LocationType getType () const
 
void setKillLocation ()
 
bool isKillLocation () const
 
DILocalVariablegetVariable () const
 
MDNodegetRawVariable () const
 
DIExpressiongetExpression () const
 
MetadatagetRawLocation () const
 Returns the metadata operand for the first location description.
 
ValuegetValue (unsigned OpIdx=0) const
 
void setRawLocation (Metadata *NewLocation)
 Use of this should generally be avoided; instead, replaceVariableLocationOp and addVariableLocationOps should be used where possible to avoid creating invalid state.
 
std::optional< uint64_tgetFragmentSizeInBits () const
 Get the size (in bits) of the variable, or fragment of the variable that is described.
 
bool isEquivalentTo (const DPValue &Other) const
 
bool isIdenticalToWhenDefined (const DPValue &Other) const
 
DPValueclone () const
 
DbgVariableIntrinsiccreateDebugIntrinsic (Module *M, Instruction *InsertBefore) const
 Convert this DPValue back into a dbg.value intrinsic.
 
void handleChangedLocation (Metadata *NewLocation)
 Handle changes to the location of the Value(s) that we refer to happening "under our feet".
 
void print (raw_ostream &O, bool IsForDebug=false) const
 
void print (raw_ostream &ROS, ModuleSlotTracker &MST, bool IsForDebug) const
 
DbgAssign Methods
bool isDbgAssign () const
 
ValuegetAddress () const
 
MetadatagetRawAddress () const
 
MetadatagetRawAssignID () const
 
DIAssignIDgetAssignID () const
 
DIExpressiongetAddressExpression () const
 
void setAddressExpression (DIExpression *NewExpr)
 
void setAssignId (DIAssignID *New)
 
void setAddress (Value *V)
 
void setKillAddress ()
 Kill the address component.
 
bool isKillAddress () const
 Check whether this kills the address component.
 
- Public Member Functions inherited from llvm::DbgRecord
 DbgRecord (Kind RecordKind, DebugLoc DL)
 
bool isEquivalentTo (const DbgRecord &R) const
 Same as isIdenticalToWhenDefined but checks DebugLoc too.
 
Kind getRecordKind () const
 
void setMarker (DPMarker *M)
 
DPMarkergetMarker ()
 
const DPMarkergetMarker () const
 
BasicBlockgetBlock ()
 
const BasicBlockgetBlock () const
 
FunctiongetFunction ()
 
const FunctiongetFunction () const
 
ModulegetModule ()
 
const ModulegetModule () const
 
LLVMContextgetContext ()
 
const LLVMContextgetContext () const
 
const InstructiongetInstruction () const
 
const BasicBlockgetParent () const
 
BasicBlockgetParent ()
 
void removeFromParent ()
 
void eraseFromParent ()
 
DbgRecordgetNextNode ()
 
DbgRecordgetPrevNode ()
 
void insertBefore (DbgRecord *InsertBefore)
 
void insertAfter (DbgRecord *InsertAfter)
 
void moveBefore (DbgRecord *MoveBefore)
 
void moveAfter (DbgRecord *MoveAfter)
 
DebugLoc getDebugLoc () const
 
void setDebugLoc (DebugLoc Loc)
 
void dump () const
 
void deleteRecord ()
 Methods that dispatch to subclass implementations.
 
DbgRecordclone () const
 
void print (raw_ostream &O, bool IsForDebug=false) const
 
void print (raw_ostream &O, ModuleSlotTracker &MST, bool IsForDebug) const
 
bool isIdenticalToWhenDefined (const DbgRecord &R) const
 
DbgInfoIntrinsiccreateDebugIntrinsic (Module *M, Instruction *InsertBefore) const
 Convert this DbgRecord back into an appropriate llvm.dbg.
 
- Public Member Functions inherited from llvm::ilist_node_impl< OptionsT >
self_iterator getIterator ()
 
const_self_iterator getIterator () const
 
reverse_self_iterator getReverseIterator ()
 
const_reverse_self_iterator getReverseIterator () const
 
bool isSentinel () const
 Check whether this is the sentinel node.
 

Static Public Member Functions

static DPValuecreateDPVAssign (Value *Val, DILocalVariable *Variable, DIExpression *Expression, DIAssignID *AssignID, Value *Address, DIExpression *AddressExpression, const DILocation *DI)
 
static DPValuecreateLinkedDPVAssign (Instruction *LinkedInstr, Value *Val, DILocalVariable *Variable, DIExpression *Expression, Value *Address, DIExpression *AddressExpression, const DILocation *DI)
 
static DPValuecreateDPValue (Value *Location, DILocalVariable *DV, DIExpression *Expr, const DILocation *DI)
 
static DPValuecreateDPValue (Value *Location, DILocalVariable *DV, DIExpression *Expr, const DILocation *DI, DPValue &InsertBefore)
 
static DPValuecreateDPVDeclare (Value *Address, DILocalVariable *DV, DIExpression *Expr, const DILocation *DI)
 
static DPValuecreateDPVDeclare (Value *Address, DILocalVariable *DV, DIExpression *Expr, const DILocation *DI, DPValue &InsertBefore)
 
static auto filter (iterator_range< simple_ilist< DbgRecord >::iterator > R)
 Filter the DbgRecord range to DPValue types only and downcast.
 
static bool classof (const DbgRecord *E)
 Support type inquiry through isa, cast, and dyn_cast.
 

Public Attributes

LocationType Type
 Classification of the debug-info record that this DPValue represents.
 
TrackingMDNodeRef Variable
 
DIExpressionExpression
 
DIExpressionAddressExpression
 
- Public Attributes inherited from llvm::DbgRecord
DPMarkerMarker = nullptr
 Marker that this DbgRecord is linked into.
 

Friends

class DebugValueUser
 

Additional Inherited Members

- Protected Types inherited from llvm::ilist_node_impl< OptionsT >
using self_iterator = typename ilist_select_iterator_type< OptionsT::has_iterator_bits, OptionsT, false, false >::type
 
using const_self_iterator = typename ilist_select_iterator_type< OptionsT::has_iterator_bits, OptionsT, false, true >::type
 
using reverse_self_iterator = typename ilist_select_iterator_type< OptionsT::has_iterator_bits, OptionsT, true, false >::type
 
using const_reverse_self_iterator = typename ilist_select_iterator_type< OptionsT::has_iterator_bits, OptionsT, true, true >::type
 
- Protected Member Functions inherited from llvm::DbgRecord
 ~DbgRecord ()=default
 Similarly to Value, we avoid paying the cost of a vtable by protecting the dtor and having deleteRecord dispatch cleanup.
 
- Protected Member Functions inherited from llvm::ilist_node_impl< OptionsT >
 ilist_node_impl ()=default
 
- Protected Member Functions inherited from llvm::DebugValueUser
ArrayRef< Metadata * > getDebugValues () const
 
DPValuegetUser ()
 
const DPValuegetUser () const
 
void handleChangedValue (void *Old, Metadata *NewDebugValue)
 To be called by ReplaceableMetadataImpl::replaceAllUsesWith, where Old is a pointer to one of the pointers in DebugValues (so should be type Metadata**), and NewDebugValue is the new Metadata* that is replacing *Old.
 
 DebugValueUser ()=default
 
 DebugValueUser (std::array< Metadata *, 3 > DebugValues)
 
 DebugValueUser (DebugValueUser &&X)
 
 DebugValueUser (const DebugValueUser &X)
 
DebugValueUseroperator= (DebugValueUser &&X)
 
DebugValueUseroperator= (const DebugValueUser &X)
 
 ~DebugValueUser ()
 
void resetDebugValues ()
 
void resetDebugValue (size_t Idx, Metadata *DebugValue)
 
bool operator== (const DebugValueUser &X) const
 
bool operator!= (const DebugValueUser &X) const
 
- Protected Attributes inherited from llvm::DbgRecord
DebugLoc DbgLoc
 
Kind RecordKind
 Subclass discriminator.
 
- Protected Attributes inherited from llvm::DebugValueUser
std::array< Metadata *, 3 > DebugValues
 

Detailed Description

Record of a variable value-assignment, aka a non instruction representation of the dbg.value intrinsic.

This class inherits from DebugValueUser to allow LLVM's metadata facilities to update our references to metadata beneath our feet.

Definition at line 205 of file DebugProgramInstruction.h.

Member Enumeration Documentation

◆ LocationType

enum class llvm::DPValue::LocationType : uint8_t
strong
Enumerator
Declare 
Value 
Assign 
End 

Marks the end of the concrete types.

Any 

To indicate all LocationTypes in searches.

Definition at line 209 of file DebugProgramInstruction.h.

Constructor & Destructor Documentation

◆ DPValue() [1/4]

llvm::DPValue::DPValue ( const DbgVariableIntrinsic DVI)

Create a new DPValue representing the intrinsic DVI, for example the assignment represented by a dbg.value.

Definition at line 16 of file DebugProgramInstruction.cpp.

References llvm::DbgVariableIntrinsic::getRawLocation().

◆ DPValue() [2/4]

llvm::DPValue::DPValue ( const DPValue DPV)

Definition at line 43 of file DebugProgramInstruction.cpp.

◆ DPValue() [3/4]

llvm::DPValue::DPValue ( Metadata Location,
DILocalVariable DV,
DIExpression Expr,
const DILocation DI,
LocationType  Type = LocationType::Value 
)

Directly construct a new DPValue representing a dbg.value intrinsic assigning Location to the DV / Expr / DI variable.

Definition at line 49 of file DebugProgramInstruction.cpp.

◆ DPValue() [4/4]

llvm::DPValue::DPValue ( Metadata Value,
DILocalVariable Variable,
DIExpression Expression,
DIAssignID AssignID,
Metadata Address,
DIExpression AddressExpression,
const DILocation DI 
)

Definition at line 54 of file DebugProgramInstruction.cpp.

References llvm::Address, and Value.

Member Function Documentation

◆ addVariableLocationOps()

void llvm::DPValue::addVariableLocationOps ( ArrayRef< Value * >  NewValues,
DIExpression NewExpr 
)

Adding a new location operand will always result in this intrinsic using an ArgList, and must always be accompanied by a new expression that uses the new operand.

Definition at line 284 of file DebugProgramInstruction.cpp.

References assert(), llvm::DIArgList::get(), llvm::getAsMetadata(), llvm::DbgRecord::getContext(), getNumVariableLocationOps(), getVariableLocationOp(), llvm::is_contained(), location_ops(), llvm::SmallVectorTemplateBase< T, bool >::push_back(), setExpression(), setRawLocation(), and llvm::ArrayRef< T >::size().

◆ classof()

static bool llvm::DPValue::classof ( const DbgRecord E)
inlinestatic

Support type inquiry through isa, cast, and dyn_cast.

Definition at line 443 of file DebugProgramInstruction.h.

References E, and llvm::DbgRecord::ValueKind.

◆ clone()

DPValue * llvm::DPValue::clone ( ) const

Definition at line 338 of file DebugProgramInstruction.cpp.

Referenced by insertDPValuesForPHIs().

◆ createDebugIntrinsic()

DbgVariableIntrinsic * llvm::DPValue::createDebugIntrinsic ( Module M,
Instruction InsertBefore 
) const

◆ createDPValue() [1/2]

DPValue * llvm::DPValue::createDPValue ( Value Location,
DILocalVariable DV,
DIExpression Expr,
const DILocation DI 
)
static

Definition at line 126 of file DebugProgramInstruction.cpp.

References llvm::ValueAsMetadata::get(), and Value.

Referenced by createDPValue().

◆ createDPValue() [2/2]

DPValue * llvm::DPValue::createDPValue ( Value Location,
DILocalVariable DV,
DIExpression Expr,
const DILocation DI,
DPValue InsertBefore 
)
static

Definition at line 132 of file DebugProgramInstruction.cpp.

References createDPValue().

◆ createDPVAssign()

DPValue * llvm::DPValue::createDPVAssign ( Value Val,
DILocalVariable Variable,
DIExpression Expression,
DIAssignID AssignID,
Value Address,
DIExpression AddressExpression,
const DILocation DI 
)
static

◆ createDPVDeclare() [1/2]

DPValue * llvm::DPValue::createDPVDeclare ( Value Address,
DILocalVariable DV,
DIExpression Expr,
const DILocation DI 
)
static

◆ createDPVDeclare() [2/2]

DPValue * llvm::DPValue::createDPVDeclare ( Value Address,
DILocalVariable DV,
DIExpression Expr,
const DILocation DI,
DPValue InsertBefore 
)
static

Definition at line 146 of file DebugProgramInstruction.cpp.

References llvm::Address, and createDPVDeclare().

◆ createLinkedDPVAssign()

DPValue * llvm::DPValue::createLinkedDPVAssign ( Instruction LinkedInstr,
Value Val,
DILocalVariable Variable,
DIExpression Expression,
Value Address,
DIExpression AddressExpression,
const DILocation DI 
)
static

◆ filter()

static auto llvm::DPValue::filter ( iterator_range< simple_ilist< DbgRecord >::iterator >  R)
inlinestatic

◆ getAddress()

Value * llvm::DPValue::getAddress ( ) const

◆ getAddressExpression()

DIExpression * llvm::DPValue::getAddressExpression ( ) const
inline

Definition at line 404 of file DebugProgramInstruction.h.

References AddressExpression.

Referenced by createDebugIntrinsic(), and insertNewDbgInst().

◆ getAssignID()

DIAssignID * llvm::DPValue::getAssignID ( ) const

◆ getExpression()

DIExpression * llvm::DPValue::getExpression ( ) const
inline

◆ getFragmentSizeInBits()

std::optional< uint64_t > llvm::DPValue::getFragmentSizeInBits ( ) const

Get the size (in bits) of the variable, or fragment of the variable that is described.

Definition at line 322 of file DebugProgramInstruction.cpp.

References getExpression(), llvm::DIVariable::getSizeInBits(), and getVariable().

Referenced by getFragmentOrEntireVariable(), and valueCoversEntireFragment().

◆ getNumVariableLocationOps()

unsigned llvm::DPValue::getNumVariableLocationOps ( ) const

◆ getRawAddress()

Metadata * llvm::DPValue::getRawAddress ( ) const
inline

Definition at line 399 of file DebugProgramInstruction.h.

References llvm::DebugValueUser::DebugValues, and isDbgAssign().

Referenced by createDebugIntrinsic(), and getAddress().

◆ getRawAssignID()

Metadata * llvm::DPValue::getRawAssignID ( ) const
inline

Definition at line 402 of file DebugProgramInstruction.h.

References llvm::DebugValueUser::DebugValues.

◆ getRawLocation()

Metadata * llvm::DPValue::getRawLocation ( ) const
inline

Returns the metadata operand for the first location description.

i.e., dbg intrinsic dbg.value,declare operand and dbg.assign 1st location operand (the "value componenet"). Note the operand (singular) may be a DIArgList which is a list of values.

Definition at line 361 of file DebugProgramInstruction.h.

References llvm::DebugValueUser::DebugValues.

Referenced by buildOverlapMapAndRecordDeclares(), createDebugIntrinsic(), getNumVariableLocationOps(), getVariableLocationOp(), hasArgList(), and location_ops().

◆ getRawVariable()

MDNode * llvm::DPValue::getRawVariable ( ) const
inline

Definition at line 353 of file DebugProgramInstruction.h.

References Variable.

◆ getType()

LocationType llvm::DPValue::getType ( ) const
inline

◆ getValue()

Value * llvm::DPValue::getValue ( unsigned  OpIdx = 0) const
inline

Definition at line 363 of file DebugProgramInstruction.h.

References getVariableLocationOp().

Referenced by insertNewDbgInst().

◆ getVariable()

DILocalVariable * llvm::DPValue::getVariable ( ) const

◆ getVariableLocationOp()

Value * llvm::DPValue::getVariableLocationOp ( unsigned  OpIdx) const

◆ handleChangedLocation()

void llvm::DPValue::handleChangedLocation ( Metadata NewLocation)

Handle changes to the location of the Value(s) that we refer to happening "under our feet".

◆ hasArgList()

bool llvm::DPValue::hasArgList ( ) const
inline

◆ hasValidLocation()

bool llvm::DPValue::hasValidLocation ( ) const
inline

Returns true if this DPValue has no empty MDNodes in its location list.

Definition at line 342 of file DebugProgramInstruction.h.

References getVariableLocationOp().

◆ isAddressOfVariable()

bool llvm::DPValue::isAddressOfVariable ( ) const
inline

Does this describe the address of a local variable.

True for dbg.addr and dbg.declare, but not dbg.value, which describes its value.

Definition at line 346 of file DebugProgramInstruction.h.

References Declare.

Referenced by llvm::ConvertDebugDeclareToDebugValue(), and valueCoversEntireFragment().

◆ isDbgAssign()

bool llvm::DPValue::isDbgAssign ( ) const
inline

◆ isDbgDeclare()

bool llvm::DPValue::isDbgDeclare ( )
inline

◆ isDbgValue()

bool llvm::DPValue::isDbgValue ( )
inline

Definition at line 316 of file DebugProgramInstruction.h.

References Value.

◆ isEquivalentTo()

bool llvm::DPValue::isEquivalentTo ( const DPValue Other) const
inline

◆ isIdenticalToWhenDefined()

bool llvm::DPValue::isIdenticalToWhenDefined ( const DPValue Other) const
inline

◆ isKillAddress()

bool llvm::DPValue::isKillAddress ( ) const

Check whether this kills the address component.

This doesn't take into account the position of the intrinsic, therefore a returned value of false does not guarentee the address is a valid location for the variable at the intrinsic's position in IR.

Definition at line 432 of file DebugProgramInstruction.cpp.

References Addr, and getAddress().

◆ isKillLocation()

bool llvm::DPValue::isKillLocation ( ) const

◆ location_ops()

iterator_range< DPValue::location_op_iterator > llvm::DPValue::location_ops ( ) const

Get the locations corresponding to the variable referenced by the debug info intrinsic.

Depending on the intrinsic, this could be the variable's value or its address.

Definition at line 180 of file DebugProgramInstruction.cpp.

References assert(), and getRawLocation().

Referenced by addVariableLocationOps(), fixupDebugInfoPostExtraction(), insertDPValuesForPHIs(), isKillLocation(), replaceVariableLocationOp(), setKillLocation(), and llvm::SelectionDAGBuilder::visitDbgInfo().

◆ print() [1/2]

void DPValue::print ( raw_ostream O,
bool  IsForDebug = false 
) const

Definition at line 4898 of file AsmWriter.cpp.

References getModuleFromDPI(), and print().

Referenced by print().

◆ print() [2/2]

void DPValue::print ( raw_ostream ROS,
ModuleSlotTracker MST,
bool  IsForDebug 
) const

◆ replaceVariableLocationOp() [1/2]

void llvm::DPValue::replaceVariableLocationOp ( unsigned  OpIdx,
Value NewValue 
)

◆ replaceVariableLocationOp() [2/2]

void llvm::DPValue::replaceVariableLocationOp ( Value OldValue,
Value NewValue,
bool  AllowEmpty = false 
)

◆ setAddress()

void llvm::DPValue::setAddress ( Value V)
inline

◆ setAddressExpression()

void llvm::DPValue::setAddressExpression ( DIExpression NewExpr)
inline

Definition at line 405 of file DebugProgramInstruction.h.

References AddressExpression.

◆ setAssignId()

void llvm::DPValue::setAssignId ( DIAssignID New)

◆ setExpression()

void llvm::DPValue::setExpression ( DIExpression NewExpr)
inline

◆ setKillAddress()

void llvm::DPValue::setKillAddress ( )

◆ setKillLocation()

void llvm::DPValue::setKillLocation ( )

◆ setRawLocation()

void llvm::DPValue::setRawLocation ( Metadata NewLocation)
inline

Use of this should generally be avoided; instead, replaceVariableLocationOp and addVariableLocationOps should be used where possible to avoid creating invalid state.

Definition at line 370 of file DebugProgramInstruction.h.

References assert(), and llvm::DebugValueUser::resetDebugValue().

Referenced by addVariableLocationOps(), and replaceVariableLocationOp().

◆ setVariable()

void llvm::DPValue::setVariable ( DILocalVariable NewVar)

Friends And Related Function Documentation

◆ DebugValueUser

friend class DebugValueUser
friend

Definition at line 206 of file DebugProgramInstruction.h.

Member Data Documentation

◆ AddressExpression

DIExpression* llvm::DPValue::AddressExpression

◆ Expression

DIExpression* llvm::DPValue::Expression

Definition at line 228 of file DebugProgramInstruction.h.

Referenced by getExpression().

◆ Type

LocationType llvm::DPValue::Type

Classification of the debug-info record that this DPValue represents.

Essentially, "is this a dbg.value or dbg.declare?". dbg.declares are not currently supported, but it would be trivial to do so. FIXME: We could use spare padding bits from DbgRecord for this.

Definition at line 221 of file DebugProgramInstruction.h.

Referenced by getType().

◆ Variable

TrackingMDNodeRef llvm::DPValue::Variable

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