class Value

Declaration

class Value { /* full declaration omitted */ };

Description

LLVM Value Representation This is a very important LLVM class. It is the base class of all values computed by a program that may be used as operands to other values. Value is the super class of other important classes such as Instruction and Function. All Values have a Type. Type is not a subclass of Value. Some values can have a name and they belong to some Module. Setting the name on the Value automatically updates the module's symbol table. Every value has a "use list" that keeps track of which other Values are using this Value. A Value can also have an arbitrary number of ValueHandle objects that watch it and listen to RAUW and Destroy events. See llvm/IR/ValueHandle.h for details.

Declared at: llvm/include/llvm/IR/Value.h:74

Member Variables

protected unsigned char SubclassOptionalData
This member is similar to SubclassData, however it is for holding information which may be used to aid optimization, but which may be cleared to zero without affecting conservative interpretation.
protected unsigned int NumUserOperands
protected unsigned int IsUsedByMD
protected unsigned int HasName
protected unsigned int HasHungOffUses
protected unsigned int HasDescriptor
public static const unsigned int MaxAlignmentExponent = 29
This is the greatest alignment value supported by load, store, and alloca instructions, and global values.
public static const unsigned int MaximumAlignment = 1U << MaxAlignmentExponent

Method Overview

Methods

llvm::Value* DoPHITranslation(
    const llvm::BasicBlock* CurBB,
    const llvm::BasicBlock* PredBB)

Declared at: llvm/include/llvm/IR/Value.h:645

Parameters

const llvm::BasicBlock* CurBB
const llvm::BasicBlock* PredBB

const llvm::Value* DoPHITranslation(
    const llvm::BasicBlock* CurBB,
    const llvm::BasicBlock* PredBB) const

Description

Translate PHI node to its predecessor from the given basic block. If this value is a PHI node with CurBB as its parent, return the value in the PHI node corresponding to PredBB. If not, return ourself. This is useful if you want to know the value something has in a predecessor block.

Declared at: llvm/include/llvm/IR/Value.h:643

Parameters

const llvm::BasicBlock* CurBB
const llvm::BasicBlock* PredBB

Value(const llvm::Value&)

Declared at: llvm/include/llvm/IR/Value.h:216

Parameters

const llvm::Value&

Value(llvm::Type* Ty, unsigned int scid)

Declared at: llvm/include/llvm/IR/Value.h:206

Parameters

llvm::Type* Ty
unsigned int scid

void addUse(llvm::Use& U)

Description

This method should only be used by the Use class.

Declared at: llvm/include/llvm/IR/Value.h:457

Parameters

llvm::Use& U

void assertModuleIsMaterialized() const

Declared at: llvm/include/llvm/IR/Value.h:337

void assertModuleIsMaterializedImpl() const

Declared at: llvm/include/llvm/IR/Value.h:333

void clearSubclassOptionalData()

Description

Clear the optional flags contained in this value.

Declared at: llvm/include/llvm/IR/Value.h:496

void deleteValue()

Description

Delete a pointer to a generic Value.

Declared at: llvm/include/llvm/IR/Value.h:220

void dump() const

Description

Support for debugging, callable in GDB: V->dump()

Declared at: llvm/include/llvm/IR/Value.h:223

llvm::LLVMContext& getContext() const

Description

All values hold a context through their type.

Declared at: llvm/include/llvm/IR/Value.h:249

llvm::StringRef getName() const

Description

Return a constant reference to the value's name. This guaranteed to return the same reference as long as the value is not modified. If the value has a name, this does a hashtable lookup, so it's not free.

Declared at: llvm/include/llvm/IR/Value.h:268

unsigned int getNumUses() const

Description

This method computes the number of uses of this Value. This is a linear time operation. Use hasOneUse, hasNUses, or hasNUsesOrMore to check for specific values.

Declared at: llvm/include/llvm/IR/Value.h:454

llvm::MaybeAlign getPointerAlignment(
    const llvm::DataLayout& DL) const

Description

Returns an alignment of the pointer value. Returns an alignment which is either specified explicitly, e.g. via align attribute of a function argument, or guaranteed by DataLayout.

Declared at: llvm/include/llvm/IR/Value.h:635

Parameters

const llvm::DataLayout& DL

uint64_t getPointerDereferenceableBytes(
    const llvm::DataLayout& DL,
    bool& CanBeNull) const

Description

Returns the number of bytes known to be dereferenceable for the pointer value. If CanBeNull is set by this function the pointer can either be null or be dereferenceable up to the returned number of bytes.

Declared at: llvm/include/llvm/IR/Value.h:628

Parameters

const llvm::DataLayout& DL
bool& CanBeNull

unsigned int getRawSubclassOptionalData() const

Description

Return the raw optional flags value contained in this value. This should only be used when testing two Values for equivalence.

Declared at: llvm/include/llvm/IR/Value.h:491

unsigned short getSubclassDataFromValue() const

Declared at: llvm/include/llvm/IR/Value.h:714

llvm::Type* getType() const

Description

All values are typed, get the type of this value.

Declared at: llvm/include/llvm/IR/Value.h:246

unsigned int getValueID() const

Description

Return an ID for the concrete type of this object. This is used to implement the classof checks. This should not be used for any other purpose, as the values may change as LLVM evolves. Also, note that for instructions, the Instruction's opcode is added to InstructionVal. So this means three things: # there is no value with code InstructionVal (no opcode==0). # there are more possible values for the value type than in ValueTy enum. # the InstructionVal enumerator must be the highest valued enumerator in the ValueTy enum.

Declared at: llvm/include/llvm/IR/Value.h:484

llvm::ValueName* getValueName() const

Declared at: llvm/include/llvm/IR/Value.h:253

bool hasNUses(unsigned int N) const

Description

Return true if this Value has exactly N users.

Declared at: llvm/include/llvm/IR/Value.h:440

Parameters

unsigned int N

bool hasNUsesOrMore(unsigned int N) const

Description

Return true if this value has N users or more. This is logically equivalent to getNumUses() >= N.

Declared at: llvm/include/llvm/IR/Value.h:445

Parameters

unsigned int N

bool hasName() const

Declared at: llvm/include/llvm/IR/Value.h:252

bool hasOneUse() const

Description

Return true if there is exactly one user of this value. This is specialized because it is a common request and does not require traversing the whole use list.

Declared at: llvm/include/llvm/IR/Value.h:433

bool hasSameSubclassOptionalData(
    const llvm::Value* V) const

Description

Check the optional flags for equality.

Declared at: llvm/include/llvm/IR/Value.h:501

Parameters

const llvm::Value* V

bool hasValueHandle() const

Description

Return true if there is a value handle associated with this value.

Declared at: llvm/include/llvm/IR/Value.h:506

bool isSwiftError() const

Description

Return true if this value is a swifterror value. swifterror values can be either a function argument or an alloca with a swifterror attribute.

Declared at: llvm/include/llvm/IR/Value.h:515

bool isUsedByMetadata() const

Description

Return true if there is metadata referencing this value.

Declared at: llvm/include/llvm/IR/Value.h:509

bool isUsedInBasicBlock(
    const llvm::BasicBlock* BB) const

Description

Check if this value is used in the specified basic block.

Declared at: llvm/include/llvm/IR/Value.h:448

Parameters

const llvm::BasicBlock* BB

llvm::Value::use_iterator materialized_use_begin()

Declared at: llvm/include/llvm/IR/Value.h:355

llvm::Value::const_use_iterator
materialized_use_begin() const

Declared at: llvm/include/llvm/IR/Value.h:356

bool materialized_use_empty() const

Declared at: llvm/include/llvm/IR/Value.h:348

llvm::Value::user_iterator
materialized_user_begin()

Declared at: llvm/include/llvm/IR/Value.h:392

llvm::Value::const_user_iterator
materialized_user_begin() const

Declared at: llvm/include/llvm/IR/Value.h:393

iterator_range<llvm::Value::const_user_iterator>
materialized_users() const

Declared at: llvm/include/llvm/IR/Value.h:417

iterator_range<llvm::Value::user_iterator>
materialized_users()

Declared at: llvm/include/llvm/IR/Value.h:414

iterator_range<llvm::Value::use_iterator>
materialized_uses()

Declared at: llvm/include/llvm/IR/Value.h:369

iterator_range<llvm::Value::const_use_iterator>
materialized_uses() const

Declared at: llvm/include/llvm/IR/Value.h:372

void mutateType(llvm::Type* Ty)

Description

Mutate the type of this Value to be of the specified type. Note that this is an extremely dangerous operation which can create completely invalid IR very easily. It is strongly recommended that you recreate IR objects with the right types instead of mutating them in place.

Declared at: llvm/include/llvm/IR/Value.h:663

Parameters

llvm::Type* Ty

void print(llvm::raw_ostream& O,
           llvm::ModuleSlotTracker& MST,
           bool IsForDebug = false) const

Declared at: llvm/include/llvm/IR/Value.h:228

Parameters

llvm::raw_ostream& O
llvm::ModuleSlotTracker& MST
bool IsForDebug = false

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

Description

Implement operator < < on Value. @ {

Declared at: llvm/include/llvm/IR/Value.h:227

Parameters

llvm::raw_ostream& O
bool IsForDebug = false

void printAsOperand(
    llvm::raw_ostream& O,
    bool PrintType = true,
    const llvm::Module* M = nullptr) const

Description

Print the name of this Value out to the specified raw_ostream. This is useful when you just want to print 'int %reg126', not the instruction that generated it. If you specify a Module for context, then even constanst get pretty-printed; for example, the type of a null pointer is printed symbolically. @ {

Declared at: llvm/include/llvm/IR/Value.h:239

Parameters

llvm::raw_ostream& O
bool PrintType = true
const llvm::Module* M = nullptr

void printAsOperand(
    llvm::raw_ostream& O,
    bool PrintType,
    llvm::ModuleSlotTracker& MST) const

Declared at: llvm/include/llvm/IR/Value.h:241

Parameters

llvm::raw_ostream& O
bool PrintType
llvm::ModuleSlotTracker& MST

void replaceAllUsesWith(llvm::Value* V)

Description

Change all uses of this to point to a new Value. Go through the uses list for this definition and make each use point to "V" instead of "this". After this completes, 'this's use list is guaranteed to be empty.

Declared at: llvm/include/llvm/IR/Value.h:289

Parameters

llvm::Value* V

void replaceNonMetadataUsesWith(llvm::Value* V)

Description

Change non-metadata uses of this to point to a new Value. Go through the uses list for this definition and make each use point to "V" instead of "this". This function skips metadata entries in the list.

Declared at: llvm/include/llvm/IR/Value.h:295

Parameters

llvm::Value* V

void replaceUsesOutsideBlock(llvm::Value* V,
                             llvm::BasicBlock* BB)

Description

replaceUsesOutsideBlock - Go through the uses list for this definition and make each use point to "V" instead of "this" when the use is outside the block. 'This's use list is expected to have at least one element. Unlike replaceAllUsesWith() this function does not support basic block values or constant users.

Declared at: llvm/include/llvm/IR/Value.h:321

Parameters

llvm::Value* V
llvm::BasicBlock* BB

void replaceUsesWithIf(
    llvm::Value* New,
    llvm::function_ref<bool(Use&)> ShouldReplace)

Description

Go through the uses list for this definition and make each use point to "V" if the callback ShouldReplace returns true for the given Use. Unlike replaceAllUsesWith() this function does not support basic block values or constant users.

Declared at: llvm/include/llvm/IR/Value.h:301

Parameters

llvm::Value* New
llvm::function_ref<bool(Use&)> ShouldReplace

void reverseUseList()

Description

Reverse the use-list.

Declared at: llvm/include/llvm/IR/Value.h:674

void setName(const llvm::Twine& Name)

Description

Change the name of the value. Choose a new unique name if the provided name is taken.

Declared at: llvm/include/llvm/IR/Value.h:275

Parameters

const llvm::Twine& Name
The new name; or "" if the value's name should be removed.

void setValueName(llvm::ValueName* VN)

Declared at: llvm/include/llvm/IR/Value.h:254

Parameters

llvm::ValueName* VN

void setValueSubclassData(unsigned short D)

Declared at: llvm/include/llvm/IR/Value.h:715

Parameters

unsigned short D

template <class Compare>
void sortUseList(Compare Cmp)

Description

Sort the use-list. Sorts the Value's use-list by Cmp using a stable mergesort. Cmp is expected to compare two \a Use references.

Declared at: llvm/include/llvm/IR/Value.h:671

Templates

Compare

Parameters

Compare Cmp

llvm::Value* stripAndAccumulateConstantOffsets(
    const llvm::DataLayout& DL,
    llvm::APInt& Offset,
    bool AllowNonInbounds)

Declared at: llvm/include/llvm/IR/Value.h:593

Parameters

const llvm::DataLayout& DL
llvm::APInt& Offset
bool AllowNonInbounds

const llvm::Value*
stripAndAccumulateConstantOffsets(
    const llvm::DataLayout& DL,
    llvm::APInt& Offset,
    bool AllowNonInbounds) const

Description

Accumulate the constant offset this value has compared to a base pointer. Only 'getelementptr' instructions (GEPs) with constant indices are accumulated but other instructions, e.g., casts, are stripped away as well. The accumulated constant offset is added to \p Offset and the base pointer is returned. The APInt \p Offset has to have a bit-width equal to the IntPtr type for the address space of 'this' pointer value, e.g., use DataLayout::getIndexTypeSizeInBits(Ty). If \p AllowNonInbounds is true, constant offsets in GEPs are stripped and accumulated even if the GEP is not "inbounds". If this is called on a non-pointer value, it returns 'this' and the\p Offset is not modified. Note that this function will never return a nullptr. It will also never manipulate the \p Offset in a way that would not match the difference between the underlying value and the returned one. Thus, if no constant offset was found, the returned value is the underlying one and \p Offset is unchanged.

Declared at: llvm/include/llvm/IR/Value.h:590

Parameters

const llvm::DataLayout& DL
llvm::APInt& Offset
bool AllowNonInbounds

llvm::Value*
stripAndAccumulateInBoundsConstantOffsets(
    const llvm::DataLayout& DL,
    llvm::APInt& Offset)

Declared at: llvm/include/llvm/IR/Value.h:607

Parameters

const llvm::DataLayout& DL
llvm::APInt& Offset

const llvm::Value*
stripAndAccumulateInBoundsConstantOffsets(
    const llvm::DataLayout& DL,
    llvm::APInt& Offset) const

Description

This is a wrapper around stripAndAccumulateConstantOffsets with the in-bounds requirement set to false.

Declared at: llvm/include/llvm/IR/Value.h:602

Parameters

const llvm::DataLayout& DL
llvm::APInt& Offset

llvm::Value* stripInBoundsConstantOffsets()

Declared at: llvm/include/llvm/IR/Value.h:564

const llvm::Value* stripInBoundsConstantOffsets()
    const

Description

Strip off pointer casts and all-constant inbounds GEPs. Returns the original pointer value. If this is called on a non-pointer value, it returns 'this'.

Declared at: llvm/include/llvm/IR/Value.h:563

llvm::Value* stripInBoundsOffsets()

Declared at: llvm/include/llvm/IR/Value.h:618

const llvm::Value* stripInBoundsOffsets() const

Description

Strip off pointer casts and inbounds GEPs. Returns the original pointer value. If this is called on a non-pointer value, it returns 'this'.

Declared at: llvm/include/llvm/IR/Value.h:617

const llvm::Value* stripPointerCasts() const

Description

Strip off pointer casts, all-zero GEPs and address space casts. Returns the original uncasted value. If this is called on a non-pointer value, it returns 'this'.

Declared at: llvm/include/llvm/IR/Value.h:521

llvm::Value* stripPointerCasts()

Declared at: llvm/include/llvm/IR/Value.h:522

const llvm::Value* stripPointerCastsAndAliases()
    const

Description

Strip off pointer casts, all-zero GEPs, address space casts, and aliases. Returns the original uncasted value. If this is called on a non-pointer value, it returns 'this'.

Declared at: llvm/include/llvm/IR/Value.h:531

llvm::Value* stripPointerCastsAndAliases()

Declared at: llvm/include/llvm/IR/Value.h:532

const llvm::Value*
stripPointerCastsAndInvariantGroups() const

Description

Strip off pointer casts, all-zero GEPs and invariant group info. Returns the original uncasted value. If this is called on a non-pointer value, it returns 'this'. This function should be used only in Alias analysis.

Declared at: llvm/include/llvm/IR/Value.h:553

llvm::Value* stripPointerCastsAndInvariantGroups()

Declared at: llvm/include/llvm/IR/Value.h:554

const llvm::Value*
stripPointerCastsSameRepresentation() const

Description

Strip off pointer casts, all-zero GEPs and address space casts but ensures the representation of the result stays the same. Returns the original uncasted value with the same representation. If this is called on a non-pointer value, it returns 'this'.

Declared at: llvm/include/llvm/IR/Value.h:542

llvm::Value* stripPointerCastsSameRepresentation()

Declared at: llvm/include/llvm/IR/Value.h:543

void takeName(llvm::Value* V)

Description

Transfer the name from V to this value. After taking V's name, sets V's name to empty.

Declared at: llvm/include/llvm/IR/Value.h:282

Parameters

llvm::Value* V

llvm::Value::use_iterator use_begin()

Declared at: llvm/include/llvm/IR/Value.h:359

llvm::Value::const_use_iterator use_begin() const

Declared at: llvm/include/llvm/IR/Value.h:363

bool use_empty() const

Declared at: llvm/include/llvm/IR/Value.h:343

llvm::Value::use_iterator use_end()

Declared at: llvm/include/llvm/IR/Value.h:367

llvm::Value::const_use_iterator use_end() const

Declared at: llvm/include/llvm/IR/Value.h:368

const llvm::User* user_back() const

Declared at: llvm/include/llvm/IR/Value.h:410

llvm::User* user_back()

Declared at: llvm/include/llvm/IR/Value.h:406

llvm::Value::const_user_iterator user_begin()
    const

Declared at: llvm/include/llvm/IR/Value.h:400

llvm::Value::user_iterator user_begin()

Declared at: llvm/include/llvm/IR/Value.h:396

bool user_empty() const

Declared at: llvm/include/llvm/IR/Value.h:384

llvm::Value::const_user_iterator user_end() const

Declared at: llvm/include/llvm/IR/Value.h:405

llvm::Value::user_iterator user_end()

Declared at: llvm/include/llvm/IR/Value.h:404

iterator_range<llvm::Value::const_user_iterator>
users() const

Declared at: llvm/include/llvm/IR/Value.h:424

iterator_range<llvm::Value::user_iterator> users()

Declared at: llvm/include/llvm/IR/Value.h:420

iterator_range<llvm::Value::const_use_iterator>
uses() const

Declared at: llvm/include/llvm/IR/Value.h:379

iterator_range<llvm::Value::use_iterator> uses()

Declared at: llvm/include/llvm/IR/Value.h:375

~Value()

Description

Value's destructor should be virtual by design, but that would require that Value and all of its subclasses have a vtable that effectively duplicates the information in the value ID. As a size optimization, the destructor has been protected, and the caller should manually call deleteValue.

Declared at: llvm/include/llvm/IR/Value.h:213