class DIExpression

Declaration

class DIExpression : public MDNode { /* full declaration omitted */ };

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.

Declared at: llvm/include/llvm/IR/DebugInfoMetadata.h:2558

Inherits from: MDNode

Member Variables

private std::vector<uint64_t> Elements

Inherited from Metadata:

protected Storage
protected SubclassData1
protected SubclassData16 = 0
protected SubclassData32 = 0

Method Overview

  • private DIExpression(llvm::LLVMContext & C, llvm::Metadata::StorageType Storage, ArrayRef<uint64_t> Elements)
  • public static llvm::DIExpression * append(const llvm::DIExpression * Expr, ArrayRef<uint64_t> Ops)
  • public static llvm::DIExpression * appendExt(const llvm::DIExpression * Expr, unsigned int FromSize, unsigned int ToSize, bool Signed)
  • public static void appendOffset(SmallVectorImpl<uint64_t> & Ops, int64_t Offset)
  • public static llvm::DIExpression * appendOpsToArg(const llvm::DIExpression * Expr, ArrayRef<uint64_t> Ops, unsigned int ArgNo, bool StackValue = false)
  • public static llvm::DIExpression * appendToStack(const llvm::DIExpression * Expr, ArrayRef<uint64_t> Ops)
  • public static bool classof(const llvm::Metadata * MD)
  • public llvm::TempDIExpression clone() const
  • private llvm::TempDIExpression cloneImpl() const
  • public std::pair<DIExpression *, const ConstantInt *> constantFold(const llvm::ConstantInt * CI)
  • public static Optional<llvm::DIExpression *> createFragmentExpression(const llvm::DIExpression * Expr, unsigned int OffsetInBits, unsigned int SizeInBits)
  • public llvm::DIExpression::element_iterator elements_begin() const
  • public llvm::DIExpression::element_iterator elements_end() const
  • public llvm::DIExpression::expr_op_iterator expr_op_begin() const
  • public llvm::DIExpression::expr_op_iterator expr_op_end() const
  • public iterator_range<llvm::DIExpression::expr_op_iterator> expr_ops() const
  • public static const llvm::DIExpression * extractAddressClass(const llvm::DIExpression * Expr, unsigned int & AddrClass)
  • public bool extractIfOffset(int64_t & Offset) const
  • public int fragmentCmp(const llvm::DIExpression * Other) const
  • public static int fragmentCmp(const llvm::DIExpression::FragmentInfo & A, const llvm::DIExpression::FragmentInfo & B)
  • public bool fragmentsOverlap(const llvm::DIExpression * Other) const
  • public static bool fragmentsOverlap(const llvm::DIExpression::FragmentInfo & A, const llvm::DIExpression::FragmentInfo & B)
  • public uint64_t getElement(unsigned int I) const
  • public ArrayRef<uint64_t> getElements() const
  • public static llvm::DIExpression::ExtOps getExtOps(unsigned int FromSize, unsigned int ToSize, bool Signed)
  • public Optional<llvm::DIExpression::FragmentInfo> getFragmentInfo() const
  • public static Optional<llvm::DIExpression::FragmentInfo> getFragmentInfo(llvm::DIExpression::expr_op_iterator Start, llvm::DIExpression::expr_op_iterator End)
  • private static llvm::DIExpression * getImpl(llvm::LLVMContext & Context, ArrayRef<uint64_t> Elements, llvm::Metadata::StorageType Storage, bool ShouldCreate = true)
  • public unsigned int getNumElements() const
  • public uint64_t getNumLocationOperands() const
  • public bool hasAllLocationOps(unsigned int N) const
  • public bool isComplex() const
  • public llvm::Optional<SignedOrUnsignedConstant> isConstant() const
  • public bool isEntryValue() const
  • public bool isFragment() const
  • public bool isImplicit() const
  • public bool isValid() const
  • public static llvm::DIExpression * prepend(const llvm::DIExpression * Expr, uint8_t Flags, int64_t Offset = 0)
  • public static llvm::DIExpression * prependOpcodes(const llvm::DIExpression * Expr, SmallVectorImpl<uint64_t> & Ops, bool StackValue = false, bool EntryValue = false)
  • public static llvm::DIExpression * replaceArg(const llvm::DIExpression * Expr, uint64_t OldArg, uint64_t NewArg)
  • public bool startsWithDeref() const
  • private ~DIExpression()

Inherited from MDNode:

Inherited from Metadata:

Methods

DIExpression(llvm::LLVMContext& C,
             llvm::Metadata::StorageType Storage,
             ArrayRef<uint64_t> Elements)

Declared at: llvm/include/llvm/IR/DebugInfoMetadata.h:2564

Parameters

llvm::LLVMContext& C
llvm::Metadata::StorageType Storage
ArrayRef<uint64_t> Elements

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

Description

Append the opcodes \p Ops to \p DIExpr. Unlike \ref appendToStack, the returned expression is a stack value only if \p DIExpr is a stack value. If \p DIExpr describes a fragment, the returned expression will describe the same fragment.

Declared at: llvm/include/llvm/IR/DebugInfoMetadata.h:2786

Parameters

const llvm::DIExpression* Expr
ArrayRef<uint64_t> Ops

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

Description

Append a zero- or sign-extension to \p Expr. Converts the expression to a stack value if it isn't one already.

Declared at: llvm/include/llvm/IR/DebugInfoMetadata.h:2850

Parameters

const llvm::DIExpression* Expr
unsigned int FromSize
unsigned int ToSize
bool Signed

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

Description

Append \p Ops with operations to apply the \p Offset.

Declared at: llvm/include/llvm/IR/DebugInfoMetadata.h:2745

Parameters

SmallVectorImpl<uint64_t>& Ops
int64_t Offset

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

Description

Create a copy of \p Expr by appending the given list of \p Ops to each instance of the operand `DW_OP_LLVM_arg, \p ArgNo`. This is used to modify a specific location used by \p Expr, such as when salvaging that location.

Declared at: llvm/include/llvm/IR/DebugInfoMetadata.h:2799

Parameters

const llvm::DIExpression* Expr
ArrayRef<uint64_t> Ops
unsigned int ArgNo
bool StackValue = false

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

Description

Convert \p DIExpr into a stack value if it isn't one already by appending DW_OP_deref if needed, and appending \p Ops to the resulting expression. If \p DIExpr describes a fragment, the returned expression will describe the same fragment.

Declared at: llvm/include/llvm/IR/DebugInfoMetadata.h:2792

Parameters

const llvm::DIExpression* Expr
ArrayRef<uint64_t> Ops

static bool classof(const llvm::Metadata* MD)

Declared at: llvm/include/llvm/IR/DebugInfoMetadata.h:2712

Parameters

const llvm::Metadata* MD

llvm::TempDIExpression clone() const

Declared at: llvm/include/llvm/IR/DebugInfoMetadata.h:2580

llvm::TempDIExpression cloneImpl() const

Declared at: llvm/include/llvm/IR/DebugInfoMetadata.h:2573

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

Description

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.

Declared at: llvm/include/llvm/IR/DebugInfoMetadata.h:2881

Parameters

const llvm::ConstantInt* CI

static Optional<llvm::DIExpression*>
createFragmentExpression(
    const llvm::DIExpression* Expr,
    unsigned int OffsetInBits,
    unsigned int SizeInBits)

Description

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 \c Expr. If \c Expr already contains a \c DW_OP_LLVM_fragment \c OffsetInBits is interpreted as an offset into the existing fragment.

Declared at: llvm/include/llvm/IR/DebugInfoMetadata.h:2824

Parameters

const llvm::DIExpression* Expr
unsigned int OffsetInBits
Offset of the piece in bits.
unsigned int SizeInBits
Size of the piece in bits.

Returns

Creating a fragment expression may fail if \c Expr contains arithmetic operations that would be truncated.

llvm::DIExpression::element_iterator
elements_begin() const

Declared at: llvm/include/llvm/IR/DebugInfoMetadata.h:2608

llvm::DIExpression::element_iterator
elements_end() const

Declared at: llvm/include/llvm/IR/DebugInfoMetadata.h:2609

llvm::DIExpression::expr_op_iterator
expr_op_begin() const

Description

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

Declared at: llvm/include/llvm/IR/DebugInfoMetadata.h:2699

llvm::DIExpression::expr_op_iterator expr_op_end()
    const

Declared at: llvm/include/llvm/IR/DebugInfoMetadata.h:2702

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

Declared at: llvm/include/llvm/IR/DebugInfoMetadata.h:2705

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

Description

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

Declared at: llvm/include/llvm/IR/DebugInfoMetadata.h:2758

Parameters

const llvm::DIExpression* Expr
unsigned int& AddrClass

bool extractIfOffset(int64_t& Offset) const

Description

If this is a constant offset, extract it. If there is no expression, return true with an offset of zero.

Declared at: llvm/include/llvm/IR/DebugInfoMetadata.h:2749

Parameters

int64_t& Offset

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

Description

Determine the relative position of the fragments described by this DIExpression and \p Other. Calls static fragmentCmp implementation.

Declared at: llvm/include/llvm/IR/DebugInfoMetadata.h:2860

Parameters

const llvm::DIExpression* Other

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

Description

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.

Declared at: llvm/include/llvm/IR/DebugInfoMetadata.h:2830

Parameters

const llvm::DIExpression::FragmentInfo& A
const llvm::DIExpression::FragmentInfo& B

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

Description

Check if fragments overlap between this DIExpression and \p Other.

Declared at: llvm/include/llvm/IR/DebugInfoMetadata.h:2867

Parameters

const llvm::DIExpression* Other

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

Description

Check if fragments overlap between a pair of FragmentInfos.

Declared at: llvm/include/llvm/IR/DebugInfoMetadata.h:2854

Parameters

const llvm::DIExpression::FragmentInfo& A
const llvm::DIExpression::FragmentInfo& B

uint64_t getElement(unsigned int I) const

Declared at: llvm/include/llvm/IR/DebugInfoMetadata.h:2586

Parameters

unsigned int I

ArrayRef<uint64_t> getElements() const

Declared at: llvm/include/llvm/IR/DebugInfoMetadata.h:2582

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

Description

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

Declared at: llvm/include/llvm/IR/DebugInfoMetadata.h:2846

Parameters

unsigned int FromSize
unsigned int ToSize
bool Signed

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

Description

Retrieve the details of this fragment expression.

Declared at: llvm/include/llvm/IR/DebugInfoMetadata.h:2730

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

Description

Retrieve the details of this fragment expression.

Declared at: llvm/include/llvm/IR/DebugInfoMetadata.h:2726

Parameters

llvm::DIExpression::expr_op_iterator Start
llvm::DIExpression::expr_op_iterator End

static llvm::DIExpression* getImpl(
    llvm::LLVMContext& Context,
    ArrayRef<uint64_t> Elements,
    llvm::Metadata::StorageType Storage,
    bool ShouldCreate = true)

Declared at: llvm/include/llvm/IR/DebugInfoMetadata.h:2569

Parameters

llvm::LLVMContext& Context
ArrayRef<uint64_t> Elements
llvm::Metadata::StorageType Storage
bool ShouldCreate = true

unsigned int getNumElements() const

Declared at: llvm/include/llvm/IR/DebugInfoMetadata.h:2584

uint64_t getNumLocationOperands() const

Description

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

Declared at: llvm/include/llvm/IR/DebugInfoMetadata.h:2604

bool hasAllLocationOps(unsigned int N) const

Description

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

Declared at: llvm/include/llvm/IR/DebugInfoMetadata.h:2753

Parameters

unsigned int N

bool isComplex() const

Description

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

Declared at: llvm/include/llvm/IR/DebugInfoMetadata.h:2742

llvm::Optional<SignedOrUnsignedConstant>
isConstant() const

Description

Determine whether this represents a constant value, if so

Declared at: llvm/include/llvm/IR/DebugInfoMetadata.h:2594

bool isEntryValue() const

Description

Check if the expression consists of exactly one entry value operand. (This is the only configuration of entry values that is supported.)

Declared at: llvm/include/llvm/IR/DebugInfoMetadata.h:2875

bool isFragment() const

Description

Return whether this is a piece of an aggregate variable.

Declared at: llvm/include/llvm/IR/DebugInfoMetadata.h:2735

bool isImplicit() const

Description

Return whether this is an implicit location description.

Declared at: llvm/include/llvm/IR/DebugInfoMetadata.h:2738

bool isValid() const

Description

@ }

Declared at: llvm/include/llvm/IR/DebugInfoMetadata.h:2710

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

Description

Prepend \p DIExpr with a deref and offset operation and optionally turn it into a stack value or/and an entry value.

Declared at: llvm/include/llvm/IR/DebugInfoMetadata.h:2772

Parameters

const llvm::DIExpression* Expr
uint8_t Flags
int64_t Offset = 0

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

Description

Prepend \p DIExpr with the given opcodes and optionally turn it into a stack value.

Declared at: llvm/include/llvm/IR/DebugInfoMetadata.h:2777

Parameters

const llvm::DIExpression* Expr
SmallVectorImpl<uint64_t>& Ops
bool StackValue = false
bool EntryValue = false

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

Description

Create a copy of \p 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 > \p 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.

Declared at: llvm/include/llvm/IR/DebugInfoMetadata.h:2809

Parameters

const llvm::DIExpression* Expr
uint64_t OldArg
uint64_t NewArg

bool startsWithDeref() const

Description

Return whether the first element a DW_OP_deref.

Declared at: llvm/include/llvm/IR/DebugInfoMetadata.h:2717

~DIExpression()

Declared at: llvm/include/llvm/IR/DebugInfoMetadata.h:2567