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 Intrinsic::ID IntID
This is stored here to save space in Function on 64-bit hosts.
protected llvm::Module* Parent
protected static const unsigned int GlobalValueSubClassDataBits = 16

Inherited from Value:

protected SubclassOptionalData
protected NumUserOperands
protected IsUsedByMD
protected HasName
protected HasHungOffUses
protected HasDescriptor
public static MaxAlignmentExponent = 29
public static MaximumAlignment = 1U << 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:192

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:591

bool canIncreaseAlignment() const

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

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

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

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:471

Parameters

const llvm::GlobalValue* Src

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:481

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:572

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:565

unsigned int getAddressSpace() const

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

unsigned int getAlignment() const

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

const llvm::GlobalObject* getBaseObject() const

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

llvm::GlobalObject* getBaseObject()

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

const llvm::Comdat* getComdat() const

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

llvm::Comdat* getComdat()

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

llvm::GlobalValue::DLLStorageClassTypes
getDLLStorageClass() const

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

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:510

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:506

Parameters

llvm::StringRef GlobalName

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:497

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:491

Parameters

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

unsigned int getGlobalValueSubClassData() const

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

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

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

Parameters

bool ODR

llvm::GlobalValue::LinkageTypes getLinkage() const

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

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

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

Parameters

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

const llvm::Module* getParent() const

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

llvm::Module* getParent()

Description

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

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

llvm::StringRef getPartition() const

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

llvm::StringRef getSection() const

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

llvm::GlobalValue::ThreadLocalMode
getThreadLocalMode() const

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

llvm::PointerType* getType() const

Description

Global values are always pointers.

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

llvm::GlobalValue::UnnamedAddr getUnnamedAddr()
    const

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

llvm::Type* getValueType() const

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

llvm::GlobalValue::VisibilityTypes getVisibility()
    const

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

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

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

Parameters

bool ODR

bool hasAppendingLinkage() const

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

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:212

bool hasAvailableExternallyLinkage() const

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

bool hasComdat() const

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

bool hasCommonLinkage() const

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

bool hasDLLExportStorageClass() const

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

bool hasDLLImportStorageClass() const

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

bool hasDefaultVisibility() const

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

bool hasExactDefinition() const

Description

Return true if this global has an exact defintion.

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

bool hasExternalLinkage() const

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

bool hasExternalWeakLinkage() const

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

bool hasGlobalUnnamedAddr() const

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

bool hasHiddenVisibility() const

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

bool hasInternalLinkage() const

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

bool hasLinkOnceLinkage() const

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

bool hasLinkOnceODRLinkage() const

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

bool hasLocalLinkage() const

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

bool hasPartition() const

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

bool hasPrivateLinkage() const

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

bool hasProtectedVisibility() const

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

bool hasSection() const

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

bool hasValidDeclarationLinkage() const

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

bool hasWeakAnyLinkage() const

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

bool hasWeakLinkage() const

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

bool hasWeakODRLinkage() const

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

bool isAbsoluteSymbolRef() const

Description

Returns whether this is a reference to an absolute symbol.

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

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

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

Parameters

llvm::GlobalValue::LinkageTypes Linkage

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

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

Parameters

llvm::GlobalValue::LinkageTypes Linkage

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

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

Parameters

llvm::GlobalValue::LinkageTypes Linkage

bool isDSOLocal() const

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

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:531

bool isDeclarationForLinker() const

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

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:411

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:370

Parameters

llvm::GlobalValue::LinkageTypes Linkage

bool isDiscardableIfUnused() const

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

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

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

Parameters

llvm::GlobalValue::LinkageTypes Linkage

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

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

Parameters

llvm::GlobalValue::LinkageTypes Linkage

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

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

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. We cannot do any IPO or inlinining across interposable call edges, since the callee can be replaced with something arbitrary at link time.

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

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:346

Parameters

llvm::GlobalValue::LinkageTypes Linkage

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

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

Parameters

llvm::GlobalValue::LinkageTypes Linkage

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

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

Parameters

llvm::GlobalValue::LinkageTypes Linkage

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

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

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:522

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

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

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:546

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:250

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

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

Parameters

llvm::GlobalValue::LinkageTypes Linkage

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

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

Parameters

llvm::GlobalValue::LinkageTypes Linkage

bool isWeakForLinker() const

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

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:379

Parameters

llvm::GlobalValue::LinkageTypes Linkage

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

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

Parameters

llvm::GlobalValue::LinkageTypes Linkage

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

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

Parameters

llvm::GlobalValue::LinkageTypes Linkage

llvm::Error materialize()

Description

Make sure this GlobalValue is fully read.

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

void removeFromParent()

Description

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

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

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

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

Parameters

llvm::GlobalValue::DLLStorageClassTypes C

void setDSOLocal(bool Local)

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

Parameters

bool Local

void setGlobalValueSubClassData(unsigned int V)

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

Parameters

unsigned int V

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

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

Parameters

llvm::GlobalValue::LinkageTypes LT

void setParent(llvm::Module* parent)

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

Parameters

llvm::Module* parent

void setPartition(llvm::StringRef Part)

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

Parameters

llvm::StringRef Part

void setThreadLocal(bool Val)

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

Parameters

bool Val

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

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

Parameters

llvm::GlobalValue::ThreadLocalMode Val

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

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

Parameters

llvm::GlobalValue::UnnamedAddr Val

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

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

Parameters

llvm::GlobalValue::VisibilityTypes V

~GlobalValue()

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