LLVM 20.0.0git
Classes | Public Types | Public Member Functions | Static Public Member Functions | Friends | List of all members
llvm::DIExpression Class Reference

DWARF expression. More...

#include "llvm/IR/DebugInfoMetadata.h"

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

Classes

class  expr_op_iterator
 An iterator for expression operands. More...
 
class  ExprOperand
 A lightweight wrapper around an expression operand. More...
 

Public Types

enum  SignedOrUnsignedConstant { SignedConstant , UnsignedConstant }
 
enum  PrependOps : uint8_t {
  ApplyOffset = 0 , DerefBefore = 1 << 0 , DerefAfter = 1 << 1 , StackValue = 1 << 2 ,
  EntryValue = 1 << 3
}
 Used for DIExpression::prepend. More...
 
using element_iterator = ArrayRef< uint64_t >::iterator
 
using FragmentInfo = DbgVariableFragmentInfo
 
using ExtOps = std::array< uint64_t, 6 >
 
- Public Types inherited from llvm::MDNode
using op_iterator = const MDOperand *
 
using op_range = iterator_range< op_iterator >
 

Public Member Functions

 DEFINE_MDNODE_GET (DIExpression,(ArrayRef< uint64_t > Elements),(Elements)) TempDIExpression clone() const
 
ArrayRef< uint64_tgetElements () const
 
unsigned getNumElements () const
 
uint64_t getElement (unsigned I) const
 
std::optional< SignedOrUnsignedConstantisConstant () const
 Determine whether this represents a constant value, if so.
 
uint64_t getNumLocationOperands () const
 Return the number of unique location operands referred to (via DW_OP_LLVM_arg) in this expression; this is not necessarily the number of instances of DW_OP_LLVM_arg within the expression.
 
element_iterator elements_begin () const
 
element_iterator elements_end () const
 
bool isValid () const
 
bool startsWithDeref () const
 Return whether the first element a DW_OP_deref.
 
bool isDeref () const
 Return whether there is exactly one operator and it is a DW_OP_deref;.
 
std::optional< uint64_tgetActiveBits (DIVariable *Var)
 Return the number of bits that have an active value, i.e.
 
std::optional< FragmentInfogetFragmentInfo () const
 Retrieve the details of this fragment expression.
 
bool isFragment () const
 Return whether this is a piece of an aggregate variable.
 
bool isImplicit () const
 Return whether this is an implicit location description.
 
bool isComplex () const
 Return whether the location is computed on the expression stack, meaning it cannot be a simple register location.
 
bool isSingleLocationExpression () const
 Return whether the evaluated expression makes use of a single location at the start of the expression, i.e.
 
std::optional< ArrayRef< uint64_t > > getSingleLocationExpressionElements () const
 Returns a reference to the elements contained in this expression, skipping past the leading DW_OP_LLVM_arg, 0 if one is present.
 
bool extractIfOffset (int64_t &Offset) const
 If this is a constant offset, extract it.
 
bool extractLeadingOffset (int64_t &OffsetInBytes, SmallVectorImpl< uint64_t > &RemainingOps) const
 Assuming that the expression operates on an address, extract a constant offset and the successive ops.
 
bool hasAllLocationOps (unsigned N) const
 Returns true iff this DIExpression contains at least one instance of DW_OP_LLVM_arg, n for all n in [0, N).
 
int fragmentCmp (const DIExpression *Other) const
 Determine the relative position of the fragments described by this DIExpression and Other.
 
bool fragmentsOverlap (const DIExpression *Other) const
 Check if fragments overlap between this DIExpression and Other.
 
bool isEntryValue () const
 Check if the expression consists of exactly one entry value operand.
 
std::pair< DIExpression *, const ConstantInt * > constantFold (const ConstantInt *CI)
 Try to shorten an expression with an initial constant operand.
 
DIExpressionfoldConstantMath ()
 Try to shorten an expression with constant math operations that can be evaluated at compile time.
 
expr_op_iterator expr_op_begin () const
 Visit the elements via ExprOperand wrappers.
 
expr_op_iterator expr_op_end () const
 
iterator_range< expr_op_iteratorexpr_ops () const
 
- Public Member Functions inherited from llvm::MDNode
 MDNode (const MDNode &)=delete
 
void operator= (const MDNode &)=delete
 
void * operator new (size_t)=delete
 
TempMDNode clone () const
 Create a (temporary) clone of this.
 
LLVMContextgetContext () const
 
void replaceOperandWith (unsigned I, Metadata *New)
 Replace a specific operand.
 
bool isResolved () const
 Check if node is fully resolved.
 
bool isUniqued () const
 
bool isDistinct () const
 
bool isTemporary () const
 
bool isReplaceable () const
 
bool isAlwaysReplaceable () const
 
unsigned getNumTemporaryUses () const
 
void replaceAllUsesWith (Metadata *MD)
 RAUW a temporary.
 
void resolveCycles ()
 Resolve cycles.
 
void resolve ()
 Resolve a unique, unresolved node.
 
op_iterator op_begin () const
 
op_iterator op_end () const
 
ArrayRef< MDOperandoperands () const
 
const MDOperandgetOperand (unsigned I) const
 
unsigned getNumOperands () const
 Return number of MDNode operands.
 
bool isTBAAVtableAccess () const
 Check whether MDNode is a vtable access.
 
void printTree (raw_ostream &OS, const Module *M=nullptr) const
 Print in tree shape.
 
void printTree (raw_ostream &OS, ModuleSlotTracker &MST, const Module *M=nullptr) const
 
void dumpTree () const
 User-friendly dump in tree shape.
 
void dumpTree (const Module *M) const
 

Static Public Member Functions

static bool classof (const Metadata *MD)
 
static std::optional< FragmentInfogetFragmentInfo (expr_op_iterator Start, expr_op_iterator End)
 Retrieve the details of this fragment expression.
 
static const DIExpressionconvertToUndefExpression (const DIExpression *Expr)
 Removes all elements from Expr that do not apply to an undef debug value, which includes every operator that computes the value/location on the DWARF stack, including any DW_OP_LLVM_arg elements (making the result of this function always a single-location expression) while leaving everything that defines what the computed value applies to, i.e.
 
static const DIExpressionconvertToVariadicExpression (const DIExpression *Expr)
 If Expr is a non-variadic expression (i.e.
 
static std::optional< const DIExpression * > convertToNonVariadicExpression (const DIExpression *Expr)
 If Expr is a valid single-location expression, i.e.
 
static void canonicalizeExpressionOps (SmallVectorImpl< uint64_t > &Ops, const DIExpression *Expr, bool IsIndirect)
 Inserts the elements of Expr into Ops modified to a canonical form, which uses DW_OP_LLVM_arg (i.e.
 
static bool isEqualExpression (const DIExpression *FirstExpr, bool FirstIndirect, const DIExpression *SecondExpr, bool SecondIndirect)
 Determines whether two debug values should produce equivalent DWARF expressions, using their DIExpressions and directness, ignoring the differences between otherwise identical expressions in variadic and non-variadic form and not considering the debug operands.
 
static void appendOffset (SmallVectorImpl< uint64_t > &Ops, int64_t Offset)
 Append Ops with operations to apply the Offset.
 
static const DIExpressionextractAddressClass (const DIExpression *Expr, unsigned &AddrClass)
 Checks if the last 4 elements of the expression are DW_OP_constu <DWARF Address Space> DW_OP_swap DW_OP_xderef and extracts the <DWARF Address Space>.
 
static DIExpressionprepend (const DIExpression *Expr, uint8_t Flags, int64_t Offset=0)
 Prepend DIExpr with a deref and offset operation and optionally turn it into a stack value or/and an entry value.
 
static DIExpressionprependOpcodes (const DIExpression *Expr, SmallVectorImpl< uint64_t > &Ops, bool StackValue=false, bool EntryValue=false)
 Prepend DIExpr with the given opcodes and optionally turn it into a stack value.
 
static DIExpressionappend (const DIExpression *Expr, ArrayRef< uint64_t > Ops)
 Append the opcodes Ops to DIExpr.
 
static DIExpressionappendToStack (const DIExpression *Expr, ArrayRef< uint64_t > Ops)
 Convert DIExpr into a stack value if it isn't one already by appending DW_OP_deref if needed, and appending Ops to the resulting expression.
 
static DIExpressionappendOpsToArg (const DIExpression *Expr, ArrayRef< uint64_t > Ops, unsigned ArgNo, bool StackValue=false)
 Create a copy of Expr by appending the given list of Ops to each instance of the operand DW_OP_LLVM_arg, \p ArgNo.
 
static DIExpressionreplaceArg (const DIExpression *Expr, uint64_t OldArg, uint64_t NewArg)
 Create a copy of Expr with each instance of DW_OP_LLVM_arg, \p OldArg replaced with DW_OP_LLVM_arg, \p NewArg, and each instance of DW_OP_LLVM_arg, Arg with DW_OP_LLVM_arg, Arg - 1 for all Arg > OldArg.
 
static std::optional< DIExpression * > createFragmentExpression (const DIExpression *Expr, unsigned OffsetInBits, unsigned SizeInBits)
 Create a DIExpression to describe one part of an aggregate variable that is fragmented across multiple Values.
 
static int fragmentCmp (const FragmentInfo &A, const FragmentInfo &B)
 Determine the relative position of the fragments passed in.
 
static bool calculateFragmentIntersect (const DataLayout &DL, const Value *SliceStart, uint64_t SliceOffsetInBits, uint64_t SliceSizeInBits, const Value *DbgPtr, int64_t DbgPtrOffsetInBits, int64_t DbgExtractOffsetInBits, DIExpression::FragmentInfo VarFrag, std::optional< DIExpression::FragmentInfo > &Result, int64_t &OffsetFromLocationInBits)
 Computes a fragment, bit-extract operation if needed, and new constant offset to describe a part of a variable covered by some memory.
 
static ExtOps getExtOps (unsigned FromSize, unsigned ToSize, bool Signed)
 Returns the ops for a zero- or sign-extension in a DIExpression.
 
static DIExpressionappendExt (const DIExpression *Expr, unsigned FromSize, unsigned ToSize, bool Signed)
 Append a zero- or sign-extension to Expr.
 
static bool fragmentsOverlap (const FragmentInfo &A, const FragmentInfo &B)
 Check if fragments overlap between a pair of FragmentInfos.
 
- Static Public Member Functions inherited from llvm::MDNode
static MDTupleget (LLVMContext &Context, ArrayRef< Metadata * > MDs)
 
static MDTuplegetIfExists (LLVMContext &Context, ArrayRef< Metadata * > MDs)
 
static MDTuplegetDistinct (LLVMContext &Context, ArrayRef< Metadata * > MDs)
 
static TempMDTuple getTemporary (LLVMContext &Context, ArrayRef< Metadata * > MDs)
 
static void deleteTemporary (MDNode *N)
 Deallocate a node created by getTemporary.
 
template<class T >
static std::enable_if_t< std::is_base_of< MDNode, T >::value, T * > replaceWithPermanent (std::unique_ptr< T, TempMDNodeDeleter > N)
 Replace a temporary node with a permanent one.
 
template<class T >
static std::enable_if_t< std::is_base_of< MDNode, T >::value, T * > replaceWithUniqued (std::unique_ptr< T, TempMDNodeDeleter > N)
 Replace a temporary node with a uniqued one.
 
template<class T >
static std::enable_if_t< std::is_base_of< MDNode, T >::value, T * > replaceWithDistinct (std::unique_ptr< T, TempMDNodeDeleter > N)
 Replace a temporary node with a distinct one.
 
static bool classof (const Metadata *MD)
 Methods for support type inquiry through isa, cast, and dyn_cast:
 
static MDNodeconcatenate (MDNode *A, MDNode *B)
 Methods for metadata merging.
 
static MDNodeintersect (MDNode *A, MDNode *B)
 
static MDNodegetMostGenericTBAA (MDNode *A, MDNode *B)
 
static MDNodegetMostGenericFPMath (MDNode *A, MDNode *B)
 
static MDNodegetMostGenericRange (MDNode *A, MDNode *B)
 
static MDNodegetMostGenericAliasScope (MDNode *A, MDNode *B)
 
static MDNodegetMostGenericAlignmentOrDereferenceable (MDNode *A, MDNode *B)
 
static MDNodegetMergedProfMetadata (MDNode *A, MDNode *B, const Instruction *AInstr, const Instruction *BInstr)
 Merge !prof metadata from two instructions.
 

Friends

class LLVMContextImpl
 
class MDNode
 

Additional Inherited Members

- Protected Types inherited from llvm::MDNode
using mutable_op_range = iterator_range< MDOperand * >
 
 Active type of storage. More...
- Protected Member Functions inherited from llvm::MDNode
 MDNode (LLVMContext &Context, unsigned ID, StorageType Storage, ArrayRef< Metadata * > Ops1, ArrayRef< Metadata * > Ops2=std::nullopt)
 
 ~MDNode ()=default
 
void * operator new (size_t Size, size_t NumOps, StorageType Storage)
 
void operator delete (void *Mem)
 
void operator delete (void *, unsigned)
 Required by std, but never called.
 
void operator delete (void *, unsigned, bool)
 Required by std, but never called.
 
void dropAllReferences ()
 
MDOperandmutable_begin ()
 
MDOperandmutable_end ()
 
mutable_op_range mutable_operands ()
 
void setOperand (unsigned I, Metadata *New)
 Set an operand.
 
unsigned getNumUnresolved () const
 
void setNumUnresolved (unsigned N)
 
void storeDistinctInContext ()
 
void resize (size_t NumOps)
 Resize the node to hold NumOps operands.
 
- Static Protected Member Functions inherited from llvm::MDNode
template<class T , class StoreT >
static TstoreImpl (T *N, StorageType Storage, StoreT &Store)
 
template<class T >
static TstoreImpl (T *N, StorageType Storage)
 

Detailed Description

DWARF expression.

This is (almost) a DWARF expression that modifies the location of a variable, or the location of a single piece of a variable, or (when using DW_OP_stack_value) is the constant variable value.

TODO: Co-allocate the expression elements. TODO: Separate from MDNode, or otherwise drop Distinct and Temporary storage types.

Definition at line 2726 of file DebugInfoMetadata.h.

Member Typedef Documentation

◆ element_iterator

Definition at line 2774 of file DebugInfoMetadata.h.

◆ ExtOps

using llvm::DIExpression::ExtOps = std::array<uint64_t, 6>

Definition at line 3124 of file DebugInfoMetadata.h.

◆ FragmentInfo

Definition at line 2890 of file DebugInfoMetadata.h.

Member Enumeration Documentation

◆ PrependOps

Used for DIExpression::prepend.

Enumerator
ApplyOffset 
DerefBefore 
DerefAfter 
StackValue 
EntryValue 

Definition at line 3006 of file DebugInfoMetadata.h.

◆ SignedOrUnsignedConstant

Enumerator
SignedConstant 
UnsignedConstant 

Definition at line 2759 of file DebugInfoMetadata.h.

Member Function Documentation

◆ append()

DIExpression * DIExpression::append ( const DIExpression Expr,
ArrayRef< uint64_t Ops 
)
static

◆ appendExt()

DIExpression * DIExpression::appendExt ( const DIExpression Expr,
unsigned  FromSize,
unsigned  ToSize,
bool  Signed 
)
static

Append a zero- or sign-extension to Expr.

Converts the expression to a stack value if it isn't one already.

Definition at line 2247 of file DebugInfoMetadata.cpp.

References appendToStack(), getExtOps(), and Signed.

Referenced by llvm::X86InstrInfo::describeLoadedValue(), and llvm::replaceAllDbgUsesWith().

◆ appendOffset()

void DIExpression::appendOffset ( SmallVectorImpl< uint64_t > &  Ops,
int64_t  Offset 
)
static

◆ appendOpsToArg()

DIExpression * DIExpression::appendOpsToArg ( const DIExpression Expr,
ArrayRef< uint64_t Ops,
unsigned  ArgNo,
bool  StackValue = false 
)
static

◆ appendToStack()

DIExpression * DIExpression::appendToStack ( const DIExpression Expr,
ArrayRef< uint64_t Ops 
)
static

Convert DIExpr into a stack value if it isn't one already by appending DW_OP_deref if needed, and appending Ops to the resulting expression.

If DIExpr describes a fragment, the returned expression will describe the same fragment.

Definition at line 1968 of file DebugInfoMetadata.cpp.

References append(), llvm::SmallVectorImpl< T >::append(), assert(), llvm::ArrayRef< T >::back(), llvm::ArrayRef< T >::begin(), llvm::ArrayRef< T >::drop_back(), llvm::ArrayRef< T >::empty(), llvm::ArrayRef< T >::end(), getElements(), getFragmentInfo(), getNumElements(), and llvm::SmallVectorTemplateBase< T, bool >::push_back().

Referenced by appendExt().

◆ calculateFragmentIntersect()

bool DIExpression::calculateFragmentIntersect ( const DataLayout DL,
const Value SliceStart,
uint64_t  SliceOffsetInBits,
uint64_t  SliceSizeInBits,
const Value DbgPtr,
int64_t  DbgPtrOffsetInBits,
int64_t  DbgExtractOffsetInBits,
DIExpression::FragmentInfo  VarFrag,
std::optional< DIExpression::FragmentInfo > &  Result,
int64_t &  OffsetFromLocationInBits 
)
static

Computes a fragment, bit-extract operation if needed, and new constant offset to describe a part of a variable covered by some memory.

See declaration for more info.

The memory region starts at: SliceStart + SliceOffsetInBits And is size: SliceSizeInBits

The location of the existing variable fragment VarFrag is: DbgPtr + DbgPtrOffsetInBits + DbgExtractOffsetInBits.

It is intended that these arguments are derived from a debug record:

  • DbgPtr is the (single) DIExpression operand.
  • DbgPtrOffsetInBits is the constant offset applied to DbgPtr.
  • DbgExtractOffsetInBits is the offset from a DW_OP_LLVM_bit_extract_[sz]ext operation.

Results and return value:

  • Return false if the result can't be calculated for any reason.
  • Result is set to nullopt if the intersect equals VarFarg.
  • Result contains a zero-sized fragment if there's no intersect.
  • OffsetFromLocationInBits is set to the difference between the first bit of the variable location and the first bit of the slice. The magnitude of a negative value therefore indicates the number of bits into the variable fragment that the memory region begins.

We don't pass in a debug record directly to get the constituent parts and offsets because different debug records store the information in different places (dbg_assign has two DIExpressions - one contains the fragment info for the entire intrinsic).

Definition at line 2095 of file DebugInfoMetadata.cpp.

References DL, llvm::Value::getPointerOffsetFrom(), llvm::DbgVariableFragmentInfo::intersect(), llvm::DbgVariableFragmentInfo::OffsetInBits, and llvm::DbgVariableFragmentInfo::SizeInBits.

Referenced by calculateFragmentIntersectImpl().

◆ canonicalizeExpressionOps()

void DIExpression::canonicalizeExpressionOps ( SmallVectorImpl< uint64_t > &  Ops,
const DIExpression Expr,
bool  IsIndirect 
)
static

Inserts the elements of Expr into Ops modified to a canonical form, which uses DW_OP_LLVM_arg (i.e.

is a variadic expression) and folds the implied derefence from the IsIndirect flag into the expression. This allows us to check equivalence between expressions with differing directness or variadicness.

Definition at line 1630 of file DebugInfoMetadata.cpp.

References llvm::SmallVectorImpl< T >::append(), llvm::dwarf::DW_OP_LLVM_arg, llvm::dwarf::DW_OP_LLVM_fragment, elements_begin(), elements_end(), expr_ops(), llvm::none_of(), and llvm::SmallVectorTemplateBase< T, bool >::push_back().

Referenced by isEqualExpression().

◆ classof()

static bool llvm::DIExpression::classof ( const Metadata MD)
inlinestatic

Definition at line 2880 of file DebugInfoMetadata.h.

References llvm::Metadata::getMetadataID().

◆ constantFold()

std::pair< DIExpression *, const ConstantInt * > DIExpression::constantFold ( const ConstantInt CI)

Try to shorten an expression with an initial constant operand.

Returns a new expression and constant on success, or the original expression and constant on failure.

Definition at line 2164 of file DebugInfoMetadata.cpp.

References assert(), llvm::dwarf::DW_OP_LLVM_convert, expr_ops(), llvm::First, llvm::MDNode::get(), llvm::MDNode::getContext(), llvm::ConstantInt::getValue(), llvm::APInt::sextOrTrunc(), and llvm::APInt::zextOrTrunc().

Referenced by llvm::InstrEmitter::EmitDbgValueFromSingleOp(), and llvm::FastISel::lowerDbgValue().

◆ convertToNonVariadicExpression()

std::optional< const DIExpression * > DIExpression::convertToNonVariadicExpression ( const DIExpression Expr)
static

If Expr is a valid single-location expression, i.e.

it refers to only a single debug operand at the start of the expression, then return that expression in a non-variadic form by removing DW_OP_LLVM_arg from the expression if it is present; otherwise returns std::nullopt. See also getSingleLocationExpressionElements above, which skips checking isSingleLocationExpression and returns a list of elements rather than a DIExpression.

Definition at line 1620 of file DebugInfoMetadata.cpp.

References llvm::MDNode::get(), llvm::MDNode::getContext(), and getSingleLocationExpressionElements().

Referenced by llvm::Loc::EntryValue::addExpr(), emitDebugValueComment(), getDebugLocValue(), and TransferTracker::recoverAsEntryValue().

◆ convertToUndefExpression()

const DIExpression * DIExpression::convertToUndefExpression ( const DIExpression Expr)
static

Removes all elements from Expr that do not apply to an undef debug value, which includes every operator that computes the value/location on the DWARF stack, including any DW_OP_LLVM_arg elements (making the result of this function always a single-location expression) while leaving everything that defines what the computed value applies to, i.e.

the fragment information.

Definition at line 1597 of file DebugInfoMetadata.cpp.

References llvm::SmallVectorImpl< T >::append(), llvm::dwarf::DW_OP_LLVM_fragment, llvm::MDNode::get(), llvm::MDNode::getContext(), getFragmentInfo(), llvm::DbgVariableFragmentInfo::OffsetInBits, and llvm::DbgVariableFragmentInfo::SizeInBits.

Referenced by llvm::InstrEmitter::EmitDbgNoLocation(), and llvm::SelectionDAGBuilder::handleKillDebugValue().

◆ convertToVariadicExpression()

const DIExpression * DIExpression::convertToVariadicExpression ( const DIExpression Expr)
static

If Expr is a non-variadic expression (i.e.

one that does not contain DW_OP_LLVM_arg), returns Expr converted to variadic form by adding a leading [DW_OP_LLVM_arg, 0] to the expression; otherwise returns Expr.

Definition at line 1607 of file DebugInfoMetadata.cpp.

References llvm::any_of(), llvm::SmallVectorImpl< T >::append(), llvm::dwarf::DW_OP_LLVM_arg, elements_begin(), elements_end(), expr_ops(), llvm::MDNode::get(), llvm::MDNode::getContext(), getNumElements(), and llvm::SmallVectorImpl< T >::reserve().

Referenced by llvm::InstrEmitter::EmitDbgInstrRef(), and llvm::SelectionDAG::salvageDebugInfo().

◆ createFragmentExpression()

std::optional< DIExpression * > DIExpression::createFragmentExpression ( const DIExpression Expr,
unsigned  OffsetInBits,
unsigned  SizeInBits 
)
static

Create a DIExpression to describe one part of an aggregate variable that is fragmented across multiple Values.

The DW_OP_LLVM_fragment operation will be appended to the elements of Expr. If Expr already contains a DW_OP_LLVM_fragment OffsetInBits is interpreted as an offset into the existing fragment.

Parameters
OffsetInBitsOffset of the piece in bits.
SizeInBitsSize of the piece in bits.
Returns
Creating a fragment expression may fail if Expr contains arithmetic operations that would be truncated.

Definition at line 2002 of file DebugInfoMetadata.cpp.

References assert(), llvm::dwarf::DW_OP_LLVM_extract_bits_sext, llvm::dwarf::DW_OP_LLVM_extract_bits_zext, llvm::dwarf::DW_OP_LLVM_fragment, expr_ops(), llvm::MDNode::get(), llvm::MDNode::getContext(), isImplicit(), and llvm::SmallVectorTemplateBase< T, bool >::push_back().

Referenced by emitDbgAssign(), llvm::SelectionDAGBuilder::handleDebugValue(), migrateDebugInfo(), shortenAssignment(), llvm::SelectionDAG::transferDbgValues(), and transferSRADebugInfo().

◆ DEFINE_MDNODE_GET()

llvm::DIExpression::DEFINE_MDNODE_GET ( DIExpression  ,
(ArrayRef< uint64_t > Elements)  ,
(Elements)   
) const
inline

Definition at line 2746 of file DebugInfoMetadata.h.

◆ elements_begin()

element_iterator llvm::DIExpression::elements_begin ( ) const
inline

◆ elements_end()

element_iterator llvm::DIExpression::elements_end ( ) const
inline

◆ expr_op_begin()

expr_op_iterator llvm::DIExpression::expr_op_begin ( ) const
inline

Visit the elements via ExprOperand wrappers.

These range iterators visit elements through ExprOperand wrappers. This is not guaranteed to be a valid range unless isValid() gives true.

Precondition
isValid() gives true.

Definition at line 2867 of file DebugInfoMetadata.h.

References elements_begin().

Referenced by llvm::DIExpressionCursor::DIExpressionCursor(), expr_ops(), llvm::DbgVariableLocation::extractFromMachineInstruction(), getFragmentInfo(), and isValid().

◆ expr_op_end()

expr_op_iterator llvm::DIExpression::expr_op_end ( ) const
inline

◆ expr_ops()

iterator_range< expr_op_iterator > llvm::DIExpression::expr_ops ( ) const
inline

◆ extractAddressClass()

const DIExpression * DIExpression::extractAddressClass ( const DIExpression Expr,
unsigned AddrClass 
)
static

Checks if the last 4 elements of the expression are DW_OP_constu <DWARF Address Space> DW_OP_swap DW_OP_xderef and extracts the <DWARF Address Space>.

Definition at line 1813 of file DebugInfoMetadata.cpp.

References llvm::MDNode::get(), llvm::MDNode::getContext(), and getSingleLocationExpressionElements().

Referenced by llvm::DwarfCompileUnit::addLocationAttribute().

◆ extractIfOffset()

bool DIExpression::extractIfOffset ( int64_t &  Offset) const

If this is a constant offset, extract it.

If there is no expression, return true with an offset of zero.

Definition at line 1732 of file DebugInfoMetadata.cpp.

References getSingleLocationExpressionElements(), and llvm::Offset.

Referenced by transferSRADebugInfo().

◆ extractLeadingOffset()

bool DIExpression::extractLeadingOffset ( int64_t &  OffsetInBytes,
SmallVectorImpl< uint64_t > &  RemainingOps 
) const

Assuming that the expression operates on an address, extract a constant offset and the successive ops.

Return false if the expression contains any incompatible ops (including non-zero DW_OP_LLVM_args - only a single address operand to the expression is permitted).

We don't try very hard to interpret the expression because we assume that foldConstantMath has canonicalized the expression.

Definition at line 1763 of file DebugInfoMetadata.cpp.

References llvm::SmallVectorImpl< T >::append(), llvm::SmallVectorImpl< T >::clear(), llvm::dwarf::DW_OP_LLVM_extract_bits_sext, llvm::dwarf::DW_OP_LLVM_extract_bits_zext, llvm::dwarf::DW_OP_LLVM_fragment, and getSingleLocationExpressionElements().

◆ foldConstantMath()

DIExpression * DIExpression::foldConstantMath ( )

◆ fragmentCmp() [1/2]

int llvm::DIExpression::fragmentCmp ( const DIExpression Other) const
inline

Determine the relative position of the fragments described by this DIExpression and Other.

Calls static fragmentCmp implementation.

Definition at line 3141 of file DebugInfoMetadata.h.

References fragmentCmp(), getFragmentInfo(), and llvm::Other.

◆ fragmentCmp() [2/2]

static int llvm::DIExpression::fragmentCmp ( const FragmentInfo A,
const FragmentInfo B 
)
inlinestatic

Determine the relative position of the fragments passed in.

Returns -1 if this is entirely before Other, 0 if this and Other overlap, 1 if this is entirely after Other.

Definition at line 3074 of file DebugInfoMetadata.h.

References A, B, r1(), and r2().

Referenced by fragmentCmp(), and fragmentsOverlap().

◆ fragmentsOverlap() [1/2]

bool llvm::DIExpression::fragmentsOverlap ( const DIExpression Other) const
inline

Check if fragments overlap between this DIExpression and Other.

Definition at line 3148 of file DebugInfoMetadata.h.

References fragmentCmp(), isFragment(), and llvm::Other.

◆ fragmentsOverlap() [2/2]

static bool llvm::DIExpression::fragmentsOverlap ( const FragmentInfo A,
const FragmentInfo B 
)
inlinestatic

Check if fragments overlap between a pair of FragmentInfos.

Definition at line 3135 of file DebugInfoMetadata.h.

References A, B, and fragmentCmp().

Referenced by llvm::SelectionDAGBuilder::dropDanglingDebugInfo(), handleNewDebugValue(), and stashEntryDbgValues().

◆ getActiveBits()

std::optional< uint64_t > DIExpression::getActiveBits ( DIVariable Var)

Return the number of bits that have an active value, i.e.

those that aren't known to be zero/sign (depending on the type of Var) and which are within the size of this fragment (if it is one). If we can't deduce anything from the expression this will return the size of Var.

Definition at line 1682 of file DebugInfoMetadata.cpp.

References llvm::dwarf::DW_OP_LLVM_extract_bits_sext, llvm::dwarf::DW_OP_LLVM_extract_bits_zext, llvm::dwarf::DW_OP_LLVM_fragment, expr_ops(), llvm::DIVariable::getSignedness(), llvm::DIVariable::getSizeInBits(), and llvm::DIBasicType::Signed.

Referenced by valueCoversEntireFragment().

◆ getElement()

uint64_t llvm::DIExpression::getElement ( unsigned  I) const
inline

◆ getElements()

ArrayRef< uint64_t > llvm::DIExpression::getElements ( ) const
inline

◆ getExtOps()

DIExpression::ExtOps DIExpression::getExtOps ( unsigned  FromSize,
unsigned  ToSize,
bool  Signed 
)
static

Returns the ops for a zero- or sign-extension in a DIExpression.

Definition at line 2239 of file DebugInfoMetadata.cpp.

References llvm::dwarf::DW_OP_LLVM_convert, and Signed.

Referenced by appendExt(), getSalvageOpsForTrunc(), llvm::SelectionDAG::salvageDebugInfo(), and llvm::salvageDebugInfoImpl().

◆ getFragmentInfo() [1/2]

std::optional< FragmentInfo > llvm::DIExpression::getFragmentInfo ( ) const
inline

Retrieve the details of this fragment expression.

Definition at line 2903 of file DebugInfoMetadata.h.

References expr_op_begin(), expr_op_end(), and getFragmentInfo().

Referenced by fragmentCmp(), getFragmentInfo(), llvm::DIExpressionCursor::getFragmentInfo(), and isFragment().

◆ getFragmentInfo() [2/2]

std::optional< DIExpression::FragmentInfo > DIExpression::getFragmentInfo ( expr_op_iterator  Start,
expr_op_iterator  End 
)
static

◆ getNumElements()

unsigned llvm::DIExpression::getNumElements ( ) const
inline

◆ getNumLocationOperands()

uint64_t DIExpression::getNumLocationOperands ( ) const

Return the number of unique location operands referred to (via DW_OP_LLVM_arg) in this expression; this is not necessarily the number of instances of DW_OP_LLVM_arg within the expression.

For example, for the expression: (DW_OP_LLVM_arg 0, DW_OP_LLVM_arg 1, DW_OP_plus, DW_OP_LLVM_arg 0, DW_OP_mul) This function would return 2, as there are two unique location operands (0 and 1).

Definition at line 2202 of file DebugInfoMetadata.cpp.

References assert(), llvm::dwarf::DW_OP_LLVM_arg, expr_ops(), and hasAllLocationOps().

Referenced by LiveDebugValues::DbgValueProperties::getLocationOpCount(), llvm::salvageDebugInfoForDbgValues(), salvageDebugInfoImpl(), and llvm::SelectionDAGBuilder::salvageUnresolvedDbgValue().

◆ getSingleLocationExpressionElements()

std::optional< ArrayRef< uint64_t > > DIExpression::getSingleLocationExpressionElements ( ) const

Returns a reference to the elements contained in this expression, skipping past the leading DW_OP_LLVM_arg, 0 if one is present.

Similar to convertToNonVariadicExpression, but faster and cheaper - it does not check whether the expression is a single-location expression, and it returns elements rather than creating a new DIExpression.

Definition at line 1580 of file DebugInfoMetadata.cpp.

References llvm::ArrayRef< T >::drop_front(), llvm::dwarf::DW_OP_LLVM_arg, getElements(), getNumElements(), and isSingleLocationExpression().

Referenced by convertToNonVariadicExpression(), extractAddressClass(), extractIfOffset(), extractLeadingOffset(), isDeref(), isEntryValue(), and startsWithDeref().

◆ hasAllLocationOps()

bool DIExpression::hasAllLocationOps ( unsigned  N) const

Returns true iff this DIExpression contains at least one instance of DW_OP_LLVM_arg, n for all n in [0, N).

Definition at line 1802 of file DebugInfoMetadata.cpp.

References llvm::detail::DenseSetImpl< ValueT, MapTy, ValueInfoT >::contains(), llvm::dwarf::DW_OP_LLVM_arg, expr_ops(), Idx, llvm::detail::DenseSetImpl< ValueT, MapTy, ValueInfoT >::insert(), and N.

Referenced by getNumLocationOperands().

◆ isComplex()

bool DIExpression::isComplex ( ) const

Return whether the location is computed on the expression stack, meaning it cannot be a simple register location.

Definition at line 1536 of file DebugInfoMetadata.cpp.

References llvm::dwarf::DW_OP_LLVM_arg, llvm::dwarf::DW_OP_LLVM_fragment, llvm::dwarf::DW_OP_LLVM_tag_offset, expr_ops(), getNumElements(), and isValid().

Referenced by LiveDebugValues::MLocTracker::emitLoc(), llvm::DbgVariableRecord::isKillLocation(), and UpdateDbgValueInst().

◆ isConstant()

std::optional< DIExpression::SignedOrUnsignedConstant > DIExpression::isConstant ( ) const

Determine whether this represents a constant value, if so.

Definition at line 2213 of file DebugInfoMetadata.cpp.

References llvm::dwarf::DW_OP_LLVM_fragment, getElement(), getNumElements(), SignedConstant, and UnsignedConstant.

Referenced by llvm::DwarfCompileUnit::addLocationAttribute().

◆ isDeref()

bool DIExpression::isDeref ( ) const

Return whether there is exactly one operator and it is a DW_OP_deref;.

Definition at line 1384 of file DebugInfoMetadata.cpp.

References getSingleLocationExpressionElements().

Referenced by TransferTracker::isEntryValueVariable().

◆ isEntryValue()

bool DIExpression::isEntryValue ( ) const

◆ isEqualExpression()

bool DIExpression::isEqualExpression ( const DIExpression FirstExpr,
bool  FirstIndirect,
const DIExpression SecondExpr,
bool  SecondIndirect 
)
static

Determines whether two debug values should produce equivalent DWARF expressions, using their DIExpressions and directness, ignoring the differences between otherwise identical expressions in variadic and non-variadic form and not considering the debug operands.

FirstExpr is the DIExpression for the first debug value. FirstIndirect should be true if the first debug value is indirect; in IR this should be true for dbg.declare intrinsics and false for dbg.values, and in MIR this should be true only for DBG_VALUE instructions whose second operand is an immediate value. SecondExpr and SecondIndirect have the same meaning as the prior arguments, but apply to the second debug value.

Definition at line 1660 of file DebugInfoMetadata.cpp.

References canonicalizeExpressionOps().

Referenced by llvm::DbgValueLoc::isEquivalent(), llvm::MachineInstr::isEquivalentDbgInstr(), and LiveDebugValues::DbgValueProperties::isJoinable().

◆ isFragment()

bool llvm::DIExpression::isFragment ( ) const
inline

Return whether this is a piece of an aggregate variable.

Definition at line 2908 of file DebugInfoMetadata.h.

References getFragmentInfo().

Referenced by llvm::DwarfExpression::addFragmentOffset(), fragmentsOverlap(), and llvm::DbgValueLoc::isFragment().

◆ isImplicit()

bool DIExpression::isImplicit ( ) const

Return whether this is an implicit location description.

Definition at line 1517 of file DebugInfoMetadata.cpp.

References expr_ops(), getNumElements(), and isValid().

Referenced by combineDIExpressions(), createFragmentExpression(), and LiveDebugValues::MLocTracker::emitLoc().

◆ isSingleLocationExpression()

bool DIExpression::isSingleLocationExpression ( ) const

Return whether the evaluated expression makes use of a single location at the start of the expression, i.e.

if it contains only a single DW_OP_LLVM_arg op as its first operand, or if it contains none.

Definition at line 1559 of file DebugInfoMetadata.cpp.

References llvm::dwarf::DW_OP_LLVM_arg, expr_ops(), getNumElements(), and isValid().

Referenced by LiveDebugValues::MLocTracker::emitLoc(), getSingleLocationExpressionElements(), and salvageDebugInfoImpl().

◆ isValid()

bool DIExpression::isValid ( ) const

◆ prepend()

DIExpression * DIExpression::prepend ( const DIExpression Expr,
uint8_t  Flags,
int64_t  Offset = 0 
)
static

◆ prependOpcodes()

DIExpression * DIExpression::prependOpcodes ( const DIExpression Expr,
SmallVectorImpl< uint64_t > &  Ops,
bool  StackValue = false,
bool  EntryValue = false 
)
static

◆ replaceArg()

DIExpression * DIExpression::replaceArg ( const DIExpression Expr,
uint64_t  OldArg,
uint64_t  NewArg 
)
static

Create a copy of Expr with each instance of DW_OP_LLVM_arg, \p OldArg replaced with DW_OP_LLVM_arg, \p NewArg, and each instance of DW_OP_LLVM_arg, Arg with DW_OP_LLVM_arg, Arg - 1 for all Arg > OldArg.

This is used when replacing one of the operands of a debug value list with another operand in the same list and deleting the old operand.

Definition at line 1889 of file DebugInfoMetadata.cpp.

References assert(), llvm::dwarf::DW_OP_LLVM_arg, expr_ops(), llvm::MDNode::get(), llvm::MDNode::getContext(), and llvm::SmallVectorTemplateBase< T, bool >::push_back().

◆ startsWithDeref()

bool DIExpression::startsWithDeref ( ) const

Return whether the first element a DW_OP_deref.

Definition at line 1378 of file DebugInfoMetadata.cpp.

References getSingleLocationExpressionElements().

Friends And Related Function Documentation

◆ LLVMContextImpl

friend class LLVMContextImpl
friend

Definition at line 2727 of file DebugInfoMetadata.h.

◆ MDNode

friend class MDNode
friend

Definition at line 2728 of file DebugInfoMetadata.h.


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