LLVM  10.0.0svn
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]
Collaboration diagram for llvm::DIExpression:
Collaboration graph
[legend]

Classes

class  expr_op_iterator
 An iterator for expression operands. More...
 
class  ExprOperand
 A lightweight wrapper around an expression operand. More...
 
struct  FragmentInfo
 Holds the characteristics of one fragment of a larger variable. More...
 

Public Types

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
 
- 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_t > getElements () const
 
unsigned getNumElements () const
 
uint64_t getElement (unsigned I) const
 
bool isConstant () const
 Determine whether this represents a standalone constant value. More...
 
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. More...
 
Optional< FragmentInfogetFragmentInfo () const
 Retrieve the details of this fragment expression. More...
 
bool isFragment () const
 Return whether this is a piece of an aggregate variable. More...
 
bool isImplicit () const
 Return whether this is an implicit location description. More...
 
bool isComplex () const
 Return whether the location is computed on the expression stack, meaning it cannot be a simple register location. More...
 
bool extractIfOffset (int64_t &Offset) const
 If this is a constant offset, extract it. More...
 
int fragmentCmp (const DIExpression *Other) const
 Determine the relative position of the fragments described by this DIExpression and Other. More...
 
bool fragmentsOverlap (const DIExpression *Other) const
 Check if fragments overlap between this DIExpression and Other. More...
 
bool isEntryValue () const
 Check if the expression consists of exactly one entry value operand. More...
 
expr_op_iterator expr_op_begin () const
 Visit the elements via ExprOperand wrappers. More...
 
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. More...
 
LLVMContextgetContext () const
 
void replaceOperandWith (unsigned I, Metadata *New)
 Replace a specific operand. More...
 
bool isResolved () const
 Check if node is fully resolved. More...
 
bool isUniqued () const
 
bool isDistinct () const
 
bool isTemporary () const
 
void replaceAllUsesWith (Metadata *MD)
 RAUW a temporary. More...
 
void resolveCycles ()
 Resolve cycles. More...
 
void resolve ()
 Resolve a unique, unresolved node. More...
 
op_iterator op_begin () const
 
op_iterator op_end () const
 
op_range operands () const
 
const MDOperandgetOperand (unsigned I) const
 
unsigned getNumOperands () const
 Return number of MDNode operands. More...
 
bool isTBAAVtableAccess () const
 Check whether MDNode is a vtable access. More...
 

Static Public Member Functions

static bool classof (const Metadata *MD)
 
static Optional< FragmentInfogetFragmentInfo (expr_op_iterator Start, expr_op_iterator End)
 Retrieve the details of this fragment expression. More...
 
static void appendOffset (SmallVectorImpl< uint64_t > &Ops, int64_t Offset)
 Append Ops with operations to apply the Offset. More...
 
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>="">. More...
 
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. More...
 
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. More...
 
static DIExpressionappend (const DIExpression *Expr, ArrayRef< uint64_t > Ops)
 Append the opcodes Ops to DIExpr. More...
 
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. More...
 
static 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. More...
 
static int fragmentCmp (const FragmentInfo &A, const FragmentInfo &B)
 Determine the relative position of the fragments passed in. More...
 
static bool fragmentsOverlap (const FragmentInfo &A, const FragmentInfo &B)
 Check if fragments overlap between a pair of FragmentInfos. More...
 
- 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. More...
 
template<class T >
static std::enable_if< std::is_base_of< MDNode, T >::value, T * >::type replaceWithPermanent (std::unique_ptr< T, TempMDNodeDeleter > N)
 Replace a temporary node with a permanent one. More...
 
template<class T >
static std::enable_if< std::is_base_of< MDNode, T >::value, T * >::type replaceWithUniqued (std::unique_ptr< T, TempMDNodeDeleter > N)
 Replace a temporary node with a uniqued one. More...
 
template<class T >
static std::enable_if< std::is_base_of< MDNode, T >::value, T * >::type replaceWithDistinct (std::unique_ptr< T, TempMDNodeDeleter > N)
 Replace a temporary node with a distinct one. More...
 
static bool classof (const Metadata *MD)
 Methods for support type inquiry through isa, cast, and dyn_cast: More...
 
static MDNodeconcatenate (MDNode *A, MDNode *B)
 Methods for metadata merging. More...
 
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)
 

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=None)
 
 ~MDNode ()=default
 
void * operator new (size_t Size, unsigned NumOps)
 
void operator delete (void *Mem)
 
void operator delete (void *, unsigned)
 Required by std, but never called. More...
 
void operator delete (void *, unsigned, bool)
 Required by std, but never called. More...
 
void dropAllReferences ()
 
MDOperandmutable_begin ()
 
MDOperandmutable_end ()
 
mutable_op_range mutable_operands ()
 
void setOperand (unsigned I, Metadata *New)
 Set an operand. More...
 
void storeDistinctInContext ()
 
- 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 2301 of file DebugInfoMetadata.h.

Member Typedef Documentation

◆ element_iterator

using llvm::DIExpression::element_iterator = ArrayRef<uint64_t>::iterator

Definition at line 2337 of file DebugInfoMetadata.h.

Member Enumeration Documentation

◆ PrependOps

Used for DIExpression::prepend.

Enumerator
ApplyOffset 
DerefBefore 
DerefAfter 
StackValue 
EntryValue 

Definition at line 2486 of file DebugInfoMetadata.h.

Member Function Documentation

◆ append()

DIExpression * DIExpression::append ( const DIExpression Expr,
ArrayRef< uint64_t >  Ops 
)
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 1079 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(), llvm::MDNode::getContext(), and llvm::None.

Referenced by appendToStack(), llvm::LowerDbgDeclare(), and RetagMask().

◆ appendOffset()

void DIExpression::appendOffset ( SmallVectorImpl< uint64_t > &  Ops,
int64_t  Offset 
)
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 1101 of file DebugInfoMetadata.cpp.

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

Referenced by llvm::replaceAllDbgUsesWith().

◆ classof()

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

Definition at line 2438 of file DebugInfoMetadata.h.

References llvm::Metadata::getMetadataID().

◆ createFragmentExpression()

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 1134 of file DebugInfoMetadata.cpp.

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

Referenced by getUnderlyingArgRegs(), llvm::SelectionDAGBuilder::handleDebugValue(), llvm::SelectionDAG::transferDbgValues(), and transferSRADebugInfo().

◆ DEFINE_MDNODE_GET()

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

Definition at line 2321 of file DebugInfoMetadata.h.

◆ elements_begin()

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

Definition at line 2339 of file DebugInfoMetadata.h.

Referenced by llvm::DwarfCompileUnit::constructLabelDIE(), and rotateSign().

◆ elements_end()

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

Definition at line 2340 of file DebugInfoMetadata.h.

Referenced by llvm::DwarfCompileUnit::constructLabelDIE(), and rotateSign().

◆ 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 2425 of file DebugInfoMetadata.h.

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

◆ 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 1012 of file DebugInfoMetadata.cpp.

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

Referenced by llvm::DwarfCompileUnit::addLocationAttribute(), and llvm::DwarfCompileUnit::constructLabelDIE().

◆ 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 987 of file DebugInfoMetadata.cpp.

◆ fragmentCmp() [1/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 2536 of file DebugInfoMetadata.h.

References llvm::DIExpression::FragmentInfo::OffsetInBits, r1(), r2(), and llvm::DIExpression::FragmentInfo::SizeInBits.

◆ fragmentCmp() [2/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 2556 of file DebugInfoMetadata.h.

References getFragmentInfo().

◆ fragmentsOverlap() [1/2]

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

◆ fragmentsOverlap() [2/2]

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

Check if fragments overlap between this DIExpression and Other.

Definition at line 2563 of file DebugInfoMetadata.h.

References isFragment().

◆ getElement()

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

◆ getElements()

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

◆ getFragmentInfo() [1/2]

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

◆ getFragmentInfo() [2/2]

Optional<FragmentInfo> llvm::DIExpression::getFragmentInfo ( ) const
inline

Retrieve the details of this fragment expression.

Definition at line 2458 of file DebugInfoMetadata.h.

Referenced by llvm::DIExpressionCursor::getFragmentInfo().

◆ getNumElements()

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

◆ 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 944 of file DebugInfoMetadata.cpp.

References llvm::dwarf::DW_OP_LLVM_fragment, and llvm::dwarf::DW_OP_LLVM_tag_offset.

Referenced by AssignProtectedObjSet().

◆ isConstant()

bool DIExpression::isConstant ( ) const

◆ isEntryValue()

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

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 2571 of file DebugInfoMetadata.h.

Referenced by llvm::DwarfCompileUnit::addComplexAddress(), llvm::MachineInstr::isDebugEntryValue(), isDescribedByReg(), and llvm::DbgValueLoc::isEntryVal().

◆ isFragment()

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

◆ isImplicit()

bool DIExpression::isImplicit ( ) const

Return whether this is an implicit location description.

Definition at line 929 of file DebugInfoMetadata.cpp.

References llvm::dwarf::DW_OP_LLVM_fragment, llvm::dwarf::DW_OP_LLVM_tag_offset, and N.

Referenced by AssignProtectedObjSet().

◆ 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

◆ startsWithDeref()

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

Return whether the first element a DW_OP_deref.

Definition at line 2443 of file DebugInfoMetadata.h.

Friends And Related Function Documentation

◆ LLVMContextImpl

friend class LLVMContextImpl
friend

Definition at line 2302 of file DebugInfoMetadata.h.

◆ MDNode

friend class MDNode
friend

Definition at line 2303 of file DebugInfoMetadata.h.


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