LLVM 20.0.0git
|
DWARF expression. More...
#include "llvm/IR/DebugInfoMetadata.h"
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 Types inherited from llvm::Metadata | |
enum | MetadataKind |
Public Member Functions | |
DEFINE_MDNODE_GET (DIExpression,(ArrayRef< uint64_t > Elements),(Elements)) TempDIExpression clone() const | |
ArrayRef< uint64_t > | getElements () const |
unsigned | getNumElements () const |
uint64_t | getElement (unsigned I) const |
std::optional< SignedOrUnsignedConstant > | isConstant () 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_t > | getActiveBits (DIVariable *Var) |
Return the number of bits that have an active value, i.e. | |
std::optional< FragmentInfo > | getFragmentInfo () 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. | |
DIExpression * | foldConstantMath () |
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_iterator > | expr_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. | |
LLVMContext & | getContext () 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< MDOperand > | operands () const |
const MDOperand & | getOperand (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 |
Public Member Functions inherited from llvm::Metadata | |
unsigned | getMetadataID () const |
void | dump () const |
User-friendly dump. | |
void | dump (const Module *M) const |
void | print (raw_ostream &OS, const Module *M=nullptr, bool IsForDebug=false) const |
Print. | |
void | print (raw_ostream &OS, ModuleSlotTracker &MST, const Module *M=nullptr, bool IsForDebug=false) const |
void | printAsOperand (raw_ostream &OS, const Module *M=nullptr) const |
Print as operand. | |
void | printAsOperand (raw_ostream &OS, ModuleSlotTracker &MST, const Module *M=nullptr) const |
Static Public Member Functions | |
static bool | classof (const Metadata *MD) |
static std::optional< FragmentInfo > | getFragmentInfo (expr_op_iterator Start, expr_op_iterator End) |
Retrieve the details of this fragment expression. | |
static const DIExpression * | convertToUndefExpression (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 DIExpression * | convertToVariadicExpression (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 DIExpression * | extractAddressClass (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 DIExpression * | prepend (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 DIExpression * | prependOpcodes (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 DIExpression * | append (const DIExpression *Expr, ArrayRef< uint64_t > Ops) |
Append the opcodes Ops to DIExpr . | |
static DIExpression * | appendToStack (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 DIExpression * | appendOpsToArg (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 DIExpression * | replaceArg (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 DIExpression * | appendExt (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 MDTuple * | get (LLVMContext &Context, ArrayRef< Metadata * > MDs) |
static MDTuple * | getIfExists (LLVMContext &Context, ArrayRef< Metadata * > MDs) |
static MDTuple * | getDistinct (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 MDNode * | concatenate (MDNode *A, MDNode *B) |
Methods for metadata merging. | |
static MDNode * | intersect (MDNode *A, MDNode *B) |
static MDNode * | getMostGenericTBAA (MDNode *A, MDNode *B) |
static MDNode * | getMostGenericFPMath (MDNode *A, MDNode *B) |
static MDNode * | getMostGenericRange (MDNode *A, MDNode *B) |
static MDNode * | getMostGenericAliasScope (MDNode *A, MDNode *B) |
static MDNode * | getMostGenericAlignmentOrDereferenceable (MDNode *A, MDNode *B) |
static MDNode * | getMergedProfMetadata (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 * > |
Protected Types inherited from llvm::Metadata | |
enum | StorageType { Uniqued , Distinct , Temporary } |
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 () |
MDOperand * | mutable_begin () |
MDOperand * | mutable_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. | |
Protected Member Functions inherited from llvm::Metadata | |
Metadata (unsigned ID, StorageType Storage) | |
~Metadata ()=default | |
void | handleChangedOperand (void *, Metadata *) |
Default handling of a changed operand, which asserts. | |
Static Protected Member Functions inherited from llvm::MDNode | |
template<class T , class StoreT > | |
static T * | storeImpl (T *N, StorageType Storage, StoreT &Store) |
template<class T > | |
static T * | storeImpl (T *N, StorageType Storage) |
Protected Attributes inherited from llvm::Metadata | |
unsigned char | Storage: 7 |
Storage flag for non-uniqued, otherwise unowned, metadata. | |
unsigned char | SubclassData1: 1 |
unsigned short | SubclassData16 = 0 |
unsigned | SubclassData32 = 0 |
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.
using llvm::DIExpression::element_iterator = ArrayRef<uint64_t>::iterator |
Definition at line 2774 of file DebugInfoMetadata.h.
using llvm::DIExpression::ExtOps = std::array<uint64_t, 6> |
Definition at line 3124 of file DebugInfoMetadata.h.
Definition at line 2890 of file DebugInfoMetadata.h.
enum llvm::DIExpression::PrependOps : uint8_t |
Used for DIExpression::prepend.
Enumerator | |
---|---|
ApplyOffset | |
DerefBefore | |
DerefAfter | |
StackValue | |
EntryValue |
Definition at line 3006 of file DebugInfoMetadata.h.
Enumerator | |
---|---|
SignedConstant | |
UnsignedConstant |
Definition at line 2759 of file DebugInfoMetadata.h.
|
static |
Append the opcodes Ops
to DIExpr
.
Unlike appendToStack, the returned expression is a stack value only if DIExpr
is a stack value. If DIExpr
describes a fragment, the returned expression will describe the same fragment.
Definition at line 1944 of file DebugInfoMetadata.cpp.
References llvm::SmallVectorImpl< T >::append(), assert(), llvm::ArrayRef< T >::begin(), llvm::dwarf::DW_OP_LLVM_fragment, llvm::ArrayRef< T >::empty(), llvm::ArrayRef< T >::end(), expr_ops(), llvm::MDNode::get(), and llvm::MDNode::getContext().
Referenced by appendToStack(), combineDIExpressions(), llvm::InstrEmitter::EmitDbgInstrRef(), llvm::LowerDbgDeclare(), processIfEntryValueDbgDeclare(), UpdateDbgValueInst(), upgradeDbgIntrinsicToDbgRecord(), llvm::UpgradeIntrinsicCall(), and walkToAllocaAndPrependOffsetDeref().
|
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().
|
static |
Append Ops
with operations to apply the Offset
.
Definition at line 1717 of file DebugInfoMetadata.cpp.
References llvm::Offset, and llvm::SmallVectorTemplateBase< T, bool >::push_back().
Referenced by llvm::TargetInstrInfo::describeLoadedValue(), llvm::X86InstrInfo::describeLoadedValue(), llvm::SystemZRegisterInfo::eliminateFrameIndex(), llvm::TargetRegisterInfo::getOffsetOpcodes(), llvm::AArch64RegisterInfo::getOffsetOpcodes(), llvm::RISCVRegisterInfo::getOffsetOpcodes(), getSalvageOpsForBinOp(), getSalvageOpsForGEP(), prepend(), and llvm::SelectionDAG::salvageDebugInfo().
|
static |
Create a copy of Expr
by appending the given list of Ops
to each instance of the operand DW_OP_LLVM_arg, \p ArgNo
.
This is used to modify a specific location used by Expr
, such as when salvaging that location.
Definition at line 1854 of file DebugInfoMetadata.cpp.
References llvm::any_of(), assert(), llvm::ArrayRef< T >::begin(), llvm::dwarf::DW_OP_LLVM_arg, llvm::dwarf::DW_OP_LLVM_fragment, llvm::SmallVectorTemplateCommon< T, typename >::end(), llvm::ArrayRef< T >::end(), expr_ops(), llvm::MDNode::get(), llvm::MDNode::getContext(), llvm::SmallVectorImpl< T >::insert(), prependOpcodes(), llvm::SmallVectorTemplateBase< T, bool >::push_back(), and StackValue.
Referenced by llvm::memtag::annotateDebugRecords(), computeExprForSpill(), llvm::SystemZRegisterInfo::eliminateFrameIndex(), LiveDebugValues::MLocTracker::emitLoc(), salvageDbgAssignAddress(), llvm::SelectionDAG::salvageDebugInfo(), llvm::salvageDebugInfoForDbgValue(), llvm::salvageDebugInfoForDbgValues(), salvageDebugInfoImpl(), and llvm::SelectionDAGBuilder::salvageUnresolvedDbgValue().
|
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().
|
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:
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().
|
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().
Definition at line 2880 of file DebugInfoMetadata.h.
References llvm::Metadata::getMetadataID().
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().
|
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().
|
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().
|
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().
|
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.
OffsetInBits | Offset of the piece in bits. |
SizeInBits | Size of the piece in bits. |
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().
|
inline |
Definition at line 2746 of file DebugInfoMetadata.h.
|
inline |
Definition at line 2776 of file DebugInfoMetadata.h.
References llvm::ArrayRef< T >::begin(), and getElements().
Referenced by canonicalizeExpressionOps(), convertToVariadicExpression(), and expr_op_begin().
|
inline |
Definition at line 2777 of file DebugInfoMetadata.h.
References llvm::ArrayRef< T >::end(), and getElements().
Referenced by canonicalizeExpressionOps(), convertToVariadicExpression(), and expr_op_end().
|
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
.
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().
|
inline |
Definition at line 2870 of file DebugInfoMetadata.h.
References elements_end().
Referenced by llvm::DIExpressionCursor::DIExpressionCursor(), expr_ops(), llvm::DbgVariableLocation::extractFromMachineInstruction(), getFragmentInfo(), and isValid().
|
inline |
Definition at line 2873 of file DebugInfoMetadata.h.
References expr_op_begin(), and expr_op_end().
Referenced by append(), appendOpsToArg(), canonicalizeExpressionOps(), constantFold(), convertToVariadicExpression(), createFragmentExpression(), createOrReplaceFragment(), emitDebugValueComment(), getActiveBits(), getNumLocationOperands(), hasAllLocationOps(), isComplex(), isImplicit(), isSingleLocationExpression(), prependOpcodes(), and replaceArg().
|
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().
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().
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().
DIExpression * DIExpression::foldConstantMath | ( | ) |
Try to shorten an expression with constant math operations that can be evaluated at compile time.
Returns a new expression on success, or the old expression if there is nothing to be reduced.
Definition at line 286 of file DIExpressionOptimizer.cpp.
References assert(), canonicalizeDwarfOperations(), llvm::SmallVectorImpl< T >::clear(), consumeOneOperator(), llvm::MDNode::get(), llvm::MDNode::getContext(), isConstantVal(), optimizeDwarfOperations(), llvm::DIExpressionCursor::peek(), llvm::DIExpressionCursor::peekNext(), llvm::DIExpressionCursor::peekNextN(), llvm::SmallVectorTemplateBase< T, bool >::push_back(), llvm::SmallVectorBase< Size_T >::size(), tryFoldCommutativeMath(), tryFoldCommutativeMathWithArgInBetween(), tryFoldConstants(), and tryFoldNoOpMath().
Referenced by salvageDbgAssignAddress(), and llvm::salvageDebugInfoForDbgValues().
|
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.
|
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().
|
inline |
Check if fragments overlap between this DIExpression and Other
.
Definition at line 3148 of file DebugInfoMetadata.h.
References fragmentCmp(), isFragment(), and llvm::Other.
|
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().
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().
Definition at line 2754 of file DebugInfoMetadata.h.
Referenced by llvm::DwarfCompileUnit::addLocationAttribute(), isConstant(), and updateOneDbgValueForAlloca().
Definition at line 2750 of file DebugInfoMetadata.h.
Referenced by appendToStack(), combineDIExpressions(), llvm::GlobalObject::copyMetadata(), elements_begin(), elements_end(), getDerefOffsetInBytes(), and getSingleLocationExpressionElements().
|
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().
|
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().
|
static |
Retrieve the details of this fragment expression.
Definition at line 1673 of file DebugInfoMetadata.cpp.
References llvm::dwarf::DW_OP_LLVM_fragment, End, I, and Info.
Referenced by llvm::DwarfExpression::addFragmentOffset(), appendToStack(), convertToUndefExpression(), llvm::DbgVariableRecord::getFragment(), llvm::DbgVariableIntrinsic::getFragment(), getFragmentOffsetInBits(), llvm::SelectionDAGBuilder::handleDebugValue(), and salvageDbgAssignAddress().
|
inline |
Definition at line 2752 of file DebugInfoMetadata.h.
Referenced by appendToStack(), convertToVariadicExpression(), emitDebugValueComment(), getDerefOffsetInBytes(), getSingleLocationExpressionElements(), isComplex(), isConstant(), TransferTracker::isEntryValueVariable(), isImplicit(), isSingleLocationExpression(), isValid(), llvm::SDDbgValue::print(), llvm::salvageDebugInfoForDbgValue(), llvm::salvageDebugInfoForDbgValues(), llvm::Loc::Single::Single(), and updateOneDbgValueForAlloca().
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().
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().
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().
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().
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().
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().
bool DIExpression::isEntryValue | ( | ) | const |
Check if the expression consists of exactly one entry value operand.
(This is the only configuration of entry values that is supported.)
Definition at line 1371 of file DebugInfoMetadata.cpp.
References llvm::dwarf::DW_OP_LLVM_entry_value, and getSingleLocationExpressionElements().
Referenced by llvm::DwarfCompileUnit::addComplexAddress(), finishCallSiteParams(), llvm::MachineInstr::isDebugEntryValue(), llvm::DbgValueLoc::isEntryVal(), llvm::FastISel::lowerDbgValue(), processIfEntryValueDbgDeclare(), salvageDebugInfoImpl(), and llvm::DwarfExpression::setLocation().
|
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().
|
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().
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().
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().
bool DIExpression::isValid | ( | ) | const |
Definition at line 1425 of file DebugInfoMetadata.cpp.
References llvm::dwarf::DW_OP_LLVM_arg, llvm::dwarf::DW_OP_LLVM_convert, llvm::dwarf::DW_OP_LLVM_entry_value, llvm::dwarf::DW_OP_LLVM_extract_bits_sext, llvm::dwarf::DW_OP_LLVM_extract_bits_zext, llvm::dwarf::DW_OP_LLVM_fragment, llvm::dwarf::DW_OP_LLVM_implicit_pointer, llvm::dwarf::DW_OP_LLVM_tag_offset, expr_op_begin(), expr_op_end(), getNumElements(), and I.
Referenced by llvm::DbgValueLoc::DbgValueLoc(), finishCallSiteParams(), isComplex(), isImplicit(), and isSingleLocationExpression().
|
static |
Prepend DIExpr
with a deref and offset operation and optionally turn it into a stack value or/and an entry value.
Definition at line 1838 of file DebugInfoMetadata.cpp.
References appendOffset(), DerefAfter, DerefBefore, EntryValue, llvm::Offset, prependOpcodes(), llvm::SmallVectorTemplateBase< T, bool >::push_back(), and StackValue.
Referenced by computeExprForSpill(), llvm::TargetInstrInfo::describeLoadedValue(), llvm::MipsInstrInfo::describeLoadedValue(), processDbgDeclare(), TransferTracker::recoverAsEntryValue(), llvm::replaceDbgDeclare(), salvageDebugInfoImpl(), and updateOneDbgValueForAlloca().
|
static |
Prepend DIExpr
with the given opcodes and optionally turn it into a stack value.
Definition at line 1911 of file DebugInfoMetadata.cpp.
References assert(), llvm::dwarf::DW_OP_LLVM_entry_value, llvm::dwarf::DW_OP_LLVM_fragment, llvm::SmallVectorBase< Size_T >::empty(), EntryValue, expr_ops(), llvm::MDNode::get(), llvm::MDNode::getContext(), llvm::SmallVectorTemplateBase< T, bool >::push_back(), and StackValue.
Referenced by llvm::memtag::annotateDebugRecords(), appendOpsToArg(), llvm::TargetInstrInfo::describeLoadedValue(), llvm::FastISel::lowerDbgDeclare(), llvm::FastISel::lowerDbgValue(), prepend(), llvm::TargetRegisterInfo::prependOffsetExpression(), TryToShrinkGlobalToBoolean(), and walkToAllocaAndPrependOffsetDeref().
|
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().
bool DIExpression::startsWithDeref | ( | ) | const |
Return whether the first element a DW_OP_deref.
Definition at line 1378 of file DebugInfoMetadata.cpp.
References getSingleLocationExpressionElements().
|
friend |
Definition at line 2727 of file DebugInfoMetadata.h.
|
friend |
Definition at line 2728 of file DebugInfoMetadata.h.