class GlobalValue

Declaration

class GlobalValue : public Constant { /* full declaration omitted */ };

Description

This is an important base class in LLVM. It provides the common facilities of all constant values in an LLVM program. A constant is a value that is immutable at runtime. Functions are constants because their address is immutable. Same with global variables. All constants share the capabilities provided in this class. All constants can have a null value. They can have an operand list. Constants can be simple (integer and floating point values), complex (arrays and structures), or expression based (computations yielding a constant value composed of only certain operators and other constant values). Note that Constants are immutable (once created they never change) and are fully shared by structural equivalence. This means that two structurally equivalent constants will always have the same address. Constants are created on demand as needed and never deleted: thus clients don't have to worry about the lifetime of the objects. LLVM Constant Representation

Declared at: llvm/include/llvm/IR/GlobalValue.h:44

Inherits from: Constant

Member Variables

protected llvm::Type* ValueType
protected unsigned int Linkage
protected unsigned int Visibility
protected unsigned int UnnamedAddrVal
protected unsigned int DllStorageClass
protected unsigned int ThreadLocal
protected unsigned int HasLLVMReservedName
True if the function's name starts with "llvm.". This corresponds to the value of Function::isIntrinsic(), which may be true even if Function::intrinsicID() returns Intrinsic::not_intrinsic.
protected unsigned int IsDSOLocal
If true then there is a definition within the same linkage unit and that definition cannot be runtime preempted.
protected unsigned int HasPartition
True if this symbol has a partition name assigned (see https://lld.llvm.org/Partitions.html).
protected unsigned int HasSanitizerMetadata
True if this symbol has sanitizer metadata available. Should only happen if sanitizers were enabled when building the translation unit which contains this GV.
private unsigned int SubClassData
protected Intrinsic::ID IntID = (unsigned int)0U
This is stored here to save space in Function on 64-bit hosts.
protected llvm::Module* Parent = nullptr
protected static const unsigned int GlobalValueSubClassDataBits = 15

Inherited from Value:

protected SubclassOptionalData
protected NumUserOperands
protected IsUsedByMD
protected HasName
protected HasMetadata
protected HasHungOffUses
protected HasDescriptor
public static MaxAlignmentExponent = 32
public static MaximumAlignment = 1ULL << MaxAlignmentExponent

Method Overview

Inherited from Constant:

Inherited from User:

Inherited from Value:

Methods

GlobalValue(
    llvm::Type* Ty,
    llvm::Value::ValueTy VTy,
    llvm::Use* Ops,
    unsigned int NumOps,
    llvm::GlobalValue::LinkageTypes Linkage,
    const llvm::Twine& Name,
    unsigned int AddressSpace)

Declared at: llvm/include/llvm/IR/GlobalValue.h:76

Parameters

llvm::Type* Ty
llvm::Value::ValueTy VTy
llvm::Use* Ops
unsigned int NumOps
llvm::GlobalValue::LinkageTypes Linkage
const llvm::Twine& Name
unsigned int AddressSpace

GlobalValue(const llvm::GlobalValue&)

Declared at: llvm/include/llvm/IR/GlobalValue.h:191

Parameters

const llvm::GlobalValue&

bool canBeOmittedFromSymbolTable() const

Description

True if GV can be left out of the object symbol table. This is the case for linkonce_odr values whose address is not significant. While legal, it is not normally profitable to omit them from the .o symbol table. Using this analysis makes sense when the information can be passed down to the linker or we are in LTO.

Declared at: llvm/include/llvm/IR/GlobalValue.h:652

bool canBenefitFromLocalAlias() const

Declared at: llvm/include/llvm/IR/GlobalValue.h:490

static bool classof(const llvm::Value* V)

Declared at: llvm/include/llvm/IR/GlobalValue.h:640

Parameters

const llvm::Value* V

void copyAttributesFrom(
    const llvm::GlobalValue* Src)

Description

Copy all additional attributes (those not needed to create a GlobalValue) from the GlobalValue Src to this one.

Declared at: llvm/include/llvm/IR/GlobalValue.h:536

Parameters

const llvm::GlobalValue* Src

void destroyConstantImpl()

Declared at: llvm/include/llvm/IR/GlobalValue.h:127

static llvm::StringRef dropLLVMManglingEscape(
    llvm::StringRef Name)

Description

If the given string begins with the GlobalValue name mangling escape character ' \ 1', drop it. This function applies a specific mangling that is used in PGO profiles, among other things. If you're trying to get a symbol name for an arbitrary GlobalValue, this is not the function you're looking for; see Mangler.h.

Declared at: llvm/include/llvm/IR/GlobalValue.h:546

Parameters

llvm::StringRef Name

void eraseFromParent()

Description

This method unlinks 'this' from the containing module and deletes it.

Declared at: llvm/include/llvm/IR/GlobalValue.h:633

Optional<llvm::ConstantRange>
getAbsoluteSymbolRange() const

Description

If this is an absolute symbol reference, returns the range of the symbol, otherwise returns None.

Declared at: llvm/include/llvm/IR/GlobalValue.h:626

unsigned int getAddressSpace() const

Declared at: llvm/include/llvm/IR/GlobalValue.h:193

const llvm::GlobalObject* getAliaseeObject() const

Declared at: llvm/include/llvm/IR/GlobalValue.h:615

llvm::GlobalObject* getAliaseeObject()

Declared at: llvm/include/llvm/IR/GlobalValue.h:616

const llvm::Comdat* getComdat() const

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

llvm::Comdat* getComdat()

Declared at: llvm/include/llvm/IR/GlobalValue.h:229

llvm::GlobalValue::DLLStorageClassTypes
getDLLStorageClass() const

Declared at: llvm/include/llvm/IR/GlobalValue.h:261

llvm::GlobalValue::GUID getGUID() const

Description

Return a 64-bit global unique ID constructed from global value name (i.e. returned by getGlobalIdentifier()).

Declared at: llvm/include/llvm/IR/GlobalValue.h:575

static llvm::GlobalValue::GUID getGUID(
    llvm::StringRef GlobalName)

Description

Return a 64-bit global unique ID constructed from global value name (i.e. returned by getGlobalIdentifier()).

Declared at: llvm/include/llvm/IR/GlobalValue.h:571

Parameters

llvm::StringRef GlobalName

static std::string getGlobalIdentifier(
    llvm::StringRef Name,
    GlobalValue::LinkageTypes Linkage,
    llvm::StringRef FileName)

Description

Return the modified name for a global value suitable to be used as the key for a global lookup (e.g. profile or ThinLTO). The value's original name is \c Name and has linkage of type\c Linkage. The value is defined in module \c FileName.

Declared at: llvm/include/llvm/IR/GlobalValue.h:556

Parameters

llvm::StringRef Name
GlobalValue::LinkageTypes Linkage
llvm::StringRef FileName

std::string getGlobalIdentifier() const

Description

Return the modified name for this global value suitable to be used as the key for a global lookup (e.g. profile or ThinLTO).

Declared at: llvm/include/llvm/IR/GlobalValue.h:562

unsigned int getGlobalValueSubClassData() const

Declared at: llvm/include/llvm/IR/GlobalValue.h:163

static llvm::GlobalValue::LinkageTypes
getLinkOnceLinkage(bool ODR)

Declared at: llvm/include/llvm/IR/GlobalValue.h:350

Parameters

bool ODR

llvm::GlobalValue::LinkageTypes getLinkage() const

Declared at: llvm/include/llvm/IR/GlobalValue.h:525

static llvm::GlobalValue::UnnamedAddr
getMinUnnamedAddr(
    llvm::GlobalValue::UnnamedAddr A,
    llvm::GlobalValue::UnnamedAddr B)

Declared at: llvm/include/llvm/IR/GlobalValue.h:219

Parameters

llvm::GlobalValue::UnnamedAddr A
llvm::GlobalValue::UnnamedAddr B

llvm::Module* getParent()

Description

Get the module that this global value is contained inside of...

Declared at: llvm/include/llvm/IR/GlobalValue.h:636

const llvm::Module* getParent() const

Declared at: llvm/include/llvm/IR/GlobalValue.h:637

llvm::StringRef getPartition() const

Declared at: llvm/include/llvm/IR/GlobalValue.h:294

const llvm::GlobalValue::SanitizerMetadata&
getSanitizerMetadata() const

Declared at: llvm/include/llvm/IR/GlobalValue.h:338

llvm::StringRef getSection() const

Declared at: llvm/include/llvm/IR/GlobalValue.h:273

llvm::GlobalValue::ThreadLocalMode
getThreadLocalMode() const

Declared at: llvm/include/llvm/IR/GlobalValue.h:257

llvm::PointerType* getType() const

Description

Global values are always pointers.

Declared at: llvm/include/llvm/IR/GlobalValue.h:276

llvm::GlobalValue::UnnamedAddr getUnnamedAddr()
    const

Declared at: llvm/include/llvm/IR/GlobalValue.h:214

llvm::Type* getValueType() const

Declared at: llvm/include/llvm/IR/GlobalValue.h:278

llvm::GlobalValue::VisibilityTypes getVisibility()
    const

Declared at: llvm/include/llvm/IR/GlobalValue.h:234

static llvm::GlobalValue::LinkageTypes
getWeakLinkage(bool ODR)

Declared at: llvm/include/llvm/IR/GlobalValue.h:353

Parameters

bool ODR

llvm::Value* handleOperandChangeImpl(
    llvm::Value* From,
    llvm::Value* To)

Declared at: llvm/include/llvm/IR/GlobalValue.h:128

Parameters

llvm::Value* From
llvm::Value* To

bool hasAppendingLinkage() const

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

bool hasAtLeastLocalUnnamedAddr() const

Description

Returns true if this value's address is not significant in this module. This attribute is intended to be used only by the code generator and LTO to allow the linker to decide whether the global needs to be in the symbol table. It should probably not be used in optimizations, as the value may have uses outside the module; use hasGlobalUnnamedAddr() instead.

Declared at: llvm/include/llvm/IR/GlobalValue.h:210

bool hasAvailableExternallyLinkage() const

Declared at: llvm/include/llvm/IR/GlobalValue.h:493

bool hasComdat() const

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

bool hasCommonLinkage() const

Declared at: llvm/include/llvm/IR/GlobalValue.h:513

bool hasDLLExportStorageClass() const

Declared at: llvm/include/llvm/IR/GlobalValue.h:267

bool hasDLLImportStorageClass() const

Declared at: llvm/include/llvm/IR/GlobalValue.h:264

bool hasDefaultVisibility() const

Declared at: llvm/include/llvm/IR/GlobalValue.h:235

bool hasExactDefinition() const

Description

Return true if this global has an exact defintion.

Declared at: llvm/include/llvm/IR/GlobalValue.h:476

bool hasExternalLinkage() const

Declared at: llvm/include/llvm/IR/GlobalValue.h:492

bool hasExternalWeakLinkage() const

Declared at: llvm/include/llvm/IR/GlobalValue.h:510

bool hasGlobalUnnamedAddr() const

Declared at: llvm/include/llvm/IR/GlobalValue.h:201

bool hasHiddenVisibility() const

Declared at: llvm/include/llvm/IR/GlobalValue.h:236

bool hasInternalLinkage() const

Declared at: llvm/include/llvm/IR/GlobalValue.h:507

bool hasLinkOnceAnyLinkage() const

Declared at: llvm/include/llvm/IR/GlobalValue.h:497

bool hasLinkOnceLinkage() const

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

bool hasLinkOnceODRLinkage() const

Declared at: llvm/include/llvm/IR/GlobalValue.h:500

bool hasLocalLinkage() const

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

bool hasPartition() const

Declared at: llvm/include/llvm/IR/GlobalValue.h:291

bool hasPrivateLinkage() const

Declared at: llvm/include/llvm/IR/GlobalValue.h:508

bool hasProtectedVisibility() const

Declared at: llvm/include/llvm/IR/GlobalValue.h:237

bool hasSanitizerMetadata() const

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

bool hasSection() const

Declared at: llvm/include/llvm/IR/GlobalValue.h:272

bool hasValidDeclarationLinkage() const

Declared at: llvm/include/llvm/IR/GlobalValue.h:514

bool hasWeakAnyLinkage() const

Declared at: llvm/include/llvm/IR/GlobalValue.h:504

bool hasWeakLinkage() const

Declared at: llvm/include/llvm/IR/GlobalValue.h:503

bool hasWeakODRLinkage() const

Declared at: llvm/include/llvm/IR/GlobalValue.h:505

bool isAbsoluteSymbolRef() const

Description

Returns whether this is a reference to an absolute symbol.

Declared at: llvm/include/llvm/IR/GlobalValue.h:622

static bool isAppendingLinkage(
    llvm::GlobalValue::LinkageTypes Linkage)

Declared at: llvm/include/llvm/IR/GlobalValue.h:381

Parameters

llvm::GlobalValue::LinkageTypes Linkage

static bool isAvailableExternallyLinkage(
    llvm::GlobalValue::LinkageTypes Linkage)

Declared at: llvm/include/llvm/IR/GlobalValue.h:360

Parameters

llvm::GlobalValue::LinkageTypes Linkage

static bool isCommonLinkage(
    llvm::GlobalValue::LinkageTypes Linkage)

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

Parameters

llvm::GlobalValue::LinkageTypes Linkage

bool isDSOLocal() const

Declared at: llvm/include/llvm/IR/GlobalValue.h:287

bool isDeclaration() const

Description

Return true if the primary definition of this global value is outside of the current translation unit.

Declared at: llvm/include/llvm/IR/GlobalValue.h:596

bool isDeclarationForLinker() const

Declared at: llvm/include/llvm/IR/GlobalValue.h:598

bool isDefinitionExact() const

Description

Return true if the currently visible definition of this global (if any) is exactly the definition we will see at runtime. Non-exact linkage types inhibits most non-inlining IPO, since a differently optimized variant of the same function can have different observable or undefined behavior than in the variant currently visible. For instance, we could have started with void foo(int *v) { int t = 5 / v[0]; (void) t; } and "refined" it to void foo(int *v) { } However, we cannot infer readnone for `foo`, since that would justify DSE'ing a store to `v[0]` across a call to `foo`, which can cause undefined behavior if the linker replaces the actual call destination with the unoptimized `foo`. Inlining is okay across non-exact linkage types as long as they're not interposable (see \c isInterposable), since in such cases the currently visible variant is *a* correct implementation of the original source function; it just isn't the *only* correct implementation.

Declared at: llvm/include/llvm/IR/GlobalValue.h:471

bool isDiscardableIfUnused() const

Declared at: llvm/include/llvm/IR/GlobalValue.h:527

static bool isDiscardableIfUnused(
    llvm::GlobalValue::LinkageTypes Linkage)

Description

Whether the definition of this global may be discarded if it is not used in its compilation unit.

Declared at: llvm/include/llvm/IR/GlobalValue.h:430

Parameters

llvm::GlobalValue::LinkageTypes Linkage

static bool isExternalLinkage(
    llvm::GlobalValue::LinkageTypes Linkage)

Declared at: llvm/include/llvm/IR/GlobalValue.h:357

Parameters

llvm::GlobalValue::LinkageTypes Linkage

static bool isExternalWeakLinkage(
    llvm::GlobalValue::LinkageTypes Linkage)

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

Parameters

llvm::GlobalValue::LinkageTypes Linkage

bool isImplicitDSOLocal() const

Declared at: llvm/include/llvm/IR/GlobalValue.h:280

static bool isInternalLinkage(
    llvm::GlobalValue::LinkageTypes Linkage)

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

Parameters

llvm::GlobalValue::LinkageTypes Linkage

bool isInterposable() const

Description

Return true if this global's definition can be substituted with an *arbitrary* definition at link time or load time. We cannot do any IPO or inlining across interposable call edges, since the callee can be replaced with something arbitrary.

Declared at: llvm/include/llvm/IR/GlobalValue.h:489

static bool isInterposableLinkage(
    llvm::GlobalValue::LinkageTypes Linkage)

Description

Whether the definition of this global may be replaced by something non-equivalent at link time. For example, if a function has weak linkage then the code defining it may be replaced by different code.

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

Parameters

llvm::GlobalValue::LinkageTypes Linkage

static bool isLinkOnceAnyLinkage(
    llvm::GlobalValue::LinkageTypes Linkage)

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

Parameters

llvm::GlobalValue::LinkageTypes Linkage

static bool isLinkOnceLinkage(
    llvm::GlobalValue::LinkageTypes Linkage)

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

Parameters

llvm::GlobalValue::LinkageTypes Linkage

static bool isLinkOnceODRLinkage(
    llvm::GlobalValue::LinkageTypes Linkage)

Declared at: llvm/include/llvm/IR/GlobalValue.h:366

Parameters

llvm::GlobalValue::LinkageTypes Linkage

static bool isLocalLinkage(
    llvm::GlobalValue::LinkageTypes Linkage)

Declared at: llvm/include/llvm/IR/GlobalValue.h:390

Parameters

llvm::GlobalValue::LinkageTypes Linkage

bool isMaterializable() const

Description

If this function's Module is being lazily streamed in functions from disk or some other source, this method can be used to check to see if the function has been read in yet or not.

Declared at: llvm/include/llvm/IR/GlobalValue.h:587

static bool isPrivateLinkage(
    llvm::GlobalValue::LinkageTypes Linkage)

Declared at: llvm/include/llvm/IR/GlobalValue.h:387

Parameters

llvm::GlobalValue::LinkageTypes Linkage

bool isStrongDefinitionForLinker() const

Description

Returns true if this global's definition will be the one chosen by the linker. NB! Ideally this should not be used at the IR level at all. If you're interested in optimization constraints implied by the linker's ability to choose an implementation, prefer using \c hasExactDefinition.

Declared at: llvm/include/llvm/IR/GlobalValue.h:611

bool isTagged() const

Declared at: llvm/include/llvm/IR/GlobalValue.h:346

bool isThreadLocal() const

Description

If the value is "Thread Local", its value isn't shared by the threads.

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

static bool isValidDeclarationLinkage(
    llvm::GlobalValue::LinkageTypes Linkage)

Declared at: llvm/include/llvm/IR/GlobalValue.h:399

Parameters

llvm::GlobalValue::LinkageTypes Linkage

static bool isWeakAnyLinkage(
    llvm::GlobalValue::LinkageTypes Linkage)

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

Parameters

llvm::GlobalValue::LinkageTypes Linkage

static bool isWeakForLinker(
    llvm::GlobalValue::LinkageTypes Linkage)

Description

Whether the definition of this global may be replaced at link time. NB: Using this method outside of the code generators is almost always a mistake: when working at the IR level use isInterposable instead as it knows about ODR semantics.

Declared at: llvm/include/llvm/IR/GlobalValue.h:439

Parameters

llvm::GlobalValue::LinkageTypes Linkage

bool isWeakForLinker() const

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

static bool isWeakLinkage(
    llvm::GlobalValue::LinkageTypes Linkage)

Declared at: llvm/include/llvm/IR/GlobalValue.h:378

Parameters

llvm::GlobalValue::LinkageTypes Linkage

static bool isWeakODRLinkage(
    llvm::GlobalValue::LinkageTypes Linkage)

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

Parameters

llvm::GlobalValue::LinkageTypes Linkage

llvm::Error materialize()

Description

Make sure this GlobalValue is fully read.

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

bool mayBeDerefined() const

Description

Returns true if the definition of this global may be replaced by a differently optimized variant of the same source level function at link time.

Declared at: llvm/include/llvm/IR/GlobalValue.h:133

void removeFromParent()

Description

This method unlinks 'this' from the containing module, but does not delete it.

Declared at: llvm/include/llvm/IR/GlobalValue.h:630

void removeSanitizerMetadata()

Declared at: llvm/include/llvm/IR/GlobalValue.h:344

void setDLLStorageClass(
    llvm::GlobalValue::DLLStorageClassTypes C)

Declared at: llvm/include/llvm/IR/GlobalValue.h:270

Parameters

llvm::GlobalValue::DLLStorageClassTypes C

void setDSOLocal(bool Local)

Declared at: llvm/include/llvm/IR/GlobalValue.h:285

Parameters

bool Local

void setGlobalValueSubClassData(unsigned int V)

Declared at: llvm/include/llvm/IR/GlobalValue.h:166

Parameters

unsigned int V

void setLinkage(
    llvm::GlobalValue::LinkageTypes LT)

Declared at: llvm/include/llvm/IR/GlobalValue.h:518

Parameters

llvm::GlobalValue::LinkageTypes LT

void setParent(llvm::Module* parent)

Declared at: llvm/include/llvm/IR/GlobalValue.h:174

Parameters

llvm::Module* parent

void setPartition(llvm::StringRef Part)

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

Parameters

llvm::StringRef Part

void setSanitizerMetadata(
    llvm::GlobalValue::SanitizerMetadata Meta)

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

Parameters

llvm::GlobalValue::SanitizerMetadata Meta

void setThreadLocal(bool Val)

Declared at: llvm/include/llvm/IR/GlobalValue.h:250

Parameters

bool Val

void setThreadLocalMode(
    llvm::GlobalValue::ThreadLocalMode Val)

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

Parameters

llvm::GlobalValue::ThreadLocalMode Val

void setUnnamedAddr(
    llvm::GlobalValue::UnnamedAddr Val)

Declared at: llvm/include/llvm/IR/GlobalValue.h:217

Parameters

llvm::GlobalValue::UnnamedAddr Val

void setVisibility(
    llvm::GlobalValue::VisibilityTypes V)

Declared at: llvm/include/llvm/IR/GlobalValue.h:240

Parameters

llvm::GlobalValue::VisibilityTypes V

~GlobalValue()

Declared at: llvm/include/llvm/IR/GlobalValue.h:178