class GlobalVariable
Declaration
class GlobalVariable : public GlobalObject, public ilist_node { /* 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/GlobalVariable.h:39
Inherits from: GlobalObject, ilist_node
Member Variables
- private llvm::AttributeSet Attrs
- private bool isConstantGlobal
- private bool isExternallyInitializedConstant
Inherited from GlobalObject:
- protected ObjComdat = nullptr
- protected static GlobalObjectSubClassDataBits = GlobalValueSubClassDataBits - GlobalObjectBits
Inherited from GlobalValue:
- protected ValueType
- protected Linkage
- protected Visibility
- protected UnnamedAddrVal
- protected DllStorageClass
- protected ThreadLocal
- protected HasLLVMReservedName
- protected IsDSOLocal
- protected HasPartition
- protected HasSanitizerMetadata
- protected IntID = (unsigned int)0U
- protected Parent = nullptr
- protected static 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
- public GlobalVariable(llvm::Module & M, llvm::Type * Ty, bool isConstant, llvm::GlobalValue::LinkageTypes Linkage, llvm::Constant * Initializer, const llvm::Twine & Name = "", llvm::GlobalVariable * InsertBefore = nullptr, llvm::GlobalValue::ThreadLocalMode = NotThreadLocal, Optional<unsigned int> AddressSpace = None, bool isExternallyInitialized = false)
- public GlobalVariable(const llvm::GlobalVariable &)
- public GlobalVariable(llvm::Type * Ty, bool isConstant, llvm::GlobalValue::LinkageTypes Linkage, llvm::Constant * Initializer = nullptr, const llvm::Twine & Name = "", llvm::GlobalValue::ThreadLocalMode = NotThreadLocal, unsigned int AddressSpace = 0, bool isExternallyInitialized = false)
- public void addAttribute(llvm::StringRef Kind, llvm::StringRef Val = llvm::StringRef())
- public void addAttribute(Attribute::AttrKind Kind)
- public void addDebugInfo(llvm::DIGlobalVariableExpression * GV)
- public static bool classof(const llvm::Value * V)
- public void copyAttributesFrom(const llvm::GlobalVariable * Src)
- public void dropAllReferences()
- public void eraseFromParent()
- public llvm::Attribute getAttribute(llvm::StringRef Kind) const
- public llvm::Attribute getAttribute(Attribute::AttrKind Kind) const
- public llvm::AttributeSet getAttributes() const
- public llvm::AttributeList getAttributesAsList(unsigned int index) const
- public void getDebugInfo(SmallVectorImpl<llvm::DIGlobalVariableExpression *> & GVs) const
- public inline llvm::Constant * getInitializer()
- public inline const llvm::Constant * getInitializer() const
- public bool hasAttribute(Attribute::AttrKind Kind) const
- public bool hasAttribute(llvm::StringRef Kind) const
- public bool hasAttributes() const
- public inline bool hasDefinitiveInitializer() const
- public bool hasImplicitSection() const
- public inline bool hasInitializer() const
- public inline bool hasUniqueInitializer() const
- public bool isConstant() const
- public bool isExternallyInitialized() const
- public void removeFromParent()
- public void setAttributes(llvm::AttributeSet A)
- public void setConstant(bool Val)
- public void setExternallyInitialized(bool Val)
- public void setInitializer(llvm::Constant * InitVal)
- public ~GlobalVariable()
Inherited from GlobalObject:
- public addTypeMetadata
- public canIncreaseAlignment
- public classof
- protected copyAttributesFrom
- public copyMetadata
- public getAlign
- public getAlignment
- public getComdat
- public getComdat
- public getGlobalObjectSubClassData
- public getSection
- public getVCallVisibility
- public hasComdat
- public hasSection
- public setAlignment
- public setComdat
- public setGlobalObjectSubClassData
- public setSection
- public setVCallVisibilityMetadata
Inherited from GlobalValue:
- public canBeOmittedFromSymbolTable
- public canBenefitFromLocalAlias
- public classof
- protected copyAttributesFrom
- public dropLLVMManglingEscape
- public eraseFromParent
- public getAbsoluteSymbolRange
- public getAddressSpace
- public getAliaseeObject
- public getAliaseeObject
- public getComdat
- public getComdat
- public getDLLStorageClass
- public getGUID
- public getGUID
- public getGlobalIdentifier
- public getGlobalIdentifier
- protected getGlobalValueSubClassData
- public getLinkOnceLinkage
- public getLinkage
- public getMinUnnamedAddr
- public getParent
- public getParent
- public getPartition
- public getSanitizerMetadata
- public getSection
- public getThreadLocalMode
- public getType
- public getUnnamedAddr
- public getValueType
- public getVisibility
- public getWeakLinkage
- public hasAppendingLinkage
- public hasAtLeastLocalUnnamedAddr
- public hasAvailableExternallyLinkage
- public hasComdat
- public hasCommonLinkage
- public hasDLLExportStorageClass
- public hasDLLImportStorageClass
- public hasDefaultVisibility
- public hasExactDefinition
- public hasExternalLinkage
- public hasExternalWeakLinkage
- public hasGlobalUnnamedAddr
- public hasHiddenVisibility
- public hasInternalLinkage
- public hasLinkOnceAnyLinkage
- public hasLinkOnceLinkage
- public hasLinkOnceODRLinkage
- public hasLocalLinkage
- public hasPartition
- public hasPrivateLinkage
- public hasProtectedVisibility
- public hasSanitizerMetadata
- public hasSection
- public hasValidDeclarationLinkage
- public hasWeakAnyLinkage
- public hasWeakLinkage
- public hasWeakODRLinkage
- public isAbsoluteSymbolRef
- public isAppendingLinkage
- public isAvailableExternallyLinkage
- public isCommonLinkage
- public isDSOLocal
- public isDeclaration
- public isDeclarationForLinker
- public isDefinitionExact
- public isDiscardableIfUnused
- public isDiscardableIfUnused
- public isExternalLinkage
- public isExternalWeakLinkage
- public isImplicitDSOLocal
- public isInternalLinkage
- public isInterposable
- public isInterposableLinkage
- public isLinkOnceAnyLinkage
- public isLinkOnceLinkage
- public isLinkOnceODRLinkage
- public isLocalLinkage
- public isMaterializable
- public isPrivateLinkage
- public isStrongDefinitionForLinker
- public isTagged
- public isThreadLocal
- public isValidDeclarationLinkage
- public isWeakAnyLinkage
- public isWeakForLinker
- public isWeakForLinker
- public isWeakLinkage
- public isWeakODRLinkage
- public materialize
- public removeFromParent
- public removeSanitizerMetadata
- public setDLLStorageClass
- public setDSOLocal
- protected setGlobalValueSubClassData
- public setLinkage
- protected setParent
- public setPartition
- public setSanitizerMetadata
- public setThreadLocal
- public setThreadLocalMode
- public setUnnamedAddr
- public setVisibility
Inherited from Constant:
- public classof
- public containsConstantExpression
- public containsPoisonElement
- public containsUndefOrPoisonElement
- public destroyConstant
- public getAggregateElement
- public getAggregateElement
- public getAllOnesValue
- public getIntegerValue
- public getNullValue
- public getSplatValue
- public getUniqueInteger
- public handleOperandChange
- public hasExactInverseFP
- public hasOneLiveUse
- public hasZeroLiveUses
- public isAllOnesValue
- public isConstantUsed
- public isDLLImportDependent
- public isElementWiseEqual
- public isFiniteNonZeroFP
- public isManifestConstant
- public isMinSignedValue
- public isNaN
- public isNegativeZeroValue
- public isNormalFP
- public isNotMinSignedValue
- public isNotOneValue
- public isNullValue
- public isOneValue
- public isThreadDependent
- public isZeroValue
- public mergeUndefsWith
- public needsDynamicRelocation
- public needsRelocation
- public removeDeadConstantUsers
- public replaceUndefsWith
- public stripPointerCasts
- public stripPointerCasts
Inherited from User:
- protected Op
- protected Op
- protected OpFrom
- protected allocHungoffUses
- public classof
- public dropAllReferences
- public getDescriptor
- public getDescriptor
- public getNumOperands
- public getOperand
- public getOperandList
- public getOperandList
- public getOperandUse
- public getOperandUse
- protected growHungoffUses
- public isDroppable
- public op_begin
- public op_begin
- public op_end
- public op_end
- public operand_values
- public operand_values
- public operands
- public operands
- public replaceUsesOfWith
- public setGlobalVariableNumOperands
- public setNumHungOffUseOperands
- public setOperand
- public value_op_begin
- public value_op_begin
- public value_op_end
- public value_op_end
Inherited from Value:
- public DoPHITranslation
- public DoPHITranslation
- protected addMetadata
- protected addMetadata
- public addUse
- public assertModuleIsMaterialized
- public assertModuleIsMaterializedImpl
- public canBeFreed
- protected clearMetadata
- public clearSubclassOptionalData
- public deleteValue
- public dropDroppableUse
- public dropDroppableUses
- public dropDroppableUsesIn
- public dump
- protected eraseMetadata
- protected getAllMetadata
- public getContext
- protected getMetadata
- protected getMetadata
- protected getMetadata
- protected getMetadata
- public getName
- public getNameOrAsOperand
- public getNumUses
- public getPointerAlignment
- public getPointerDereferenceableBytes
- public getRawSubclassOptionalData
- public getSingleUndroppableUse
- public getSingleUndroppableUse
- protected getSubclassDataFromValue
- public getType
- public getUniqueUndroppableUser
- public getUniqueUndroppableUser
- public getValueID
- public getValueName
- protected hasMetadata
- protected hasMetadata
- protected hasMetadata
- public hasNUndroppableUses
- public hasNUndroppableUsesOrMore
- public hasNUses
- public hasNUsesOrMore
- public hasName
- public hasOneUse
- public hasOneUser
- public hasSameSubclassOptionalData
- public hasValueHandle
- public isSwiftError
- public isTransitiveUsedByMetadataOnly
- public isUsedByMetadata
- public isUsedInBasicBlock
- public materialized_use_begin
- public materialized_use_begin
- public materialized_use_empty
- public materialized_user_begin
- public materialized_user_begin
- public materialized_users
- public materialized_users
- public materialized_uses
- public materialized_uses
- public mutateType
- public print
- public print
- public printAsOperand
- public printAsOperand
- public replaceAllUsesWith
- public replaceNonMetadataUsesWith
- public replaceUsesOutsideBlock
- public replaceUsesWithIf
- public reverseUseList
- protected setMetadata
- protected setMetadata
- public setName
- public setValueName
- protected setValueSubclassData
- public sortUseList
- public stripAndAccumulateConstantOffsets
- public stripAndAccumulateConstantOffsets
- public stripAndAccumulateInBoundsConstantOffsets
- public stripAndAccumulateInBoundsConstantOffsets
- public stripInBoundsConstantOffsets
- public stripInBoundsConstantOffsets
- public stripInBoundsOffsets
- public stripInBoundsOffsets
- public stripPointerCasts
- public stripPointerCasts
- public stripPointerCastsAndAliases
- public stripPointerCastsAndAliases
- public stripPointerCastsForAliasAnalysis
- public stripPointerCastsForAliasAnalysis
- public stripPointerCastsSameRepresentation
- public stripPointerCastsSameRepresentation
- public takeName
- public use_begin
- public use_begin
- public use_empty
- public use_end
- public use_end
- public user_back
- public user_back
- public user_begin
- public user_begin
- public user_empty
- public user_end
- public user_end
- public users
- public users
- public uses
- public uses
Methods
¶GlobalVariable(
llvm::Module& M,
llvm::Type* Ty,
bool isConstant,
llvm::GlobalValue::LinkageTypes Linkage,
llvm::Constant* Initializer,
const llvm::Twine& Name = "",
llvm::GlobalVariable* InsertBefore = nullptr,
llvm::GlobalValue::ThreadLocalMode =
NotThreadLocal,
Optional<unsigned int> AddressSpace = None,
bool isExternallyInitialized = false)
GlobalVariable(
llvm::Module& M,
llvm::Type* Ty,
bool isConstant,
llvm::GlobalValue::LinkageTypes Linkage,
llvm::Constant* Initializer,
const llvm::Twine& Name = "",
llvm::GlobalVariable* InsertBefore = nullptr,
llvm::GlobalValue::ThreadLocalMode =
NotThreadLocal,
Optional<unsigned int> AddressSpace = None,
bool isExternallyInitialized = false)
Description
GlobalVariable ctor - This creates a global and inserts it before the specified other global.
Declared at: llvm/include/llvm/IR/GlobalVariable.h:58
Parameters
- llvm::Module& M
- llvm::Type* Ty
- bool isConstant
- llvm::GlobalValue::LinkageTypes Linkage
- llvm::Constant* Initializer
- const llvm::Twine& Name = ""
- llvm::GlobalVariable* InsertBefore = nullptr
- llvm::GlobalValue::ThreadLocalMode = NotThreadLocal
- Optional<unsigned int> AddressSpace = None
- bool isExternallyInitialized = false
¶GlobalVariable(const llvm::GlobalVariable&)
GlobalVariable(const llvm::GlobalVariable&)
Declared at: llvm/include/llvm/IR/GlobalVariable.h:64
Parameters
- const llvm::GlobalVariable&
¶GlobalVariable(
llvm::Type* Ty,
bool isConstant,
llvm::GlobalValue::LinkageTypes Linkage,
llvm::Constant* Initializer = nullptr,
const llvm::Twine& Name = "",
llvm::GlobalValue::ThreadLocalMode =
NotThreadLocal,
unsigned int AddressSpace = 0,
bool isExternallyInitialized = false)
GlobalVariable(
llvm::Type* Ty,
bool isConstant,
llvm::GlobalValue::LinkageTypes Linkage,
llvm::Constant* Initializer = nullptr,
const llvm::Twine& Name = "",
llvm::GlobalValue::ThreadLocalMode =
NotThreadLocal,
unsigned int AddressSpace = 0,
bool isExternallyInitialized = false)
Description
GlobalVariable ctor - If a parent module is specified, the global is automatically inserted into the end of the specified modules global list.
Declared at: llvm/include/llvm/IR/GlobalVariable.h:52
Parameters
- llvm::Type* Ty
- bool isConstant
- llvm::GlobalValue::LinkageTypes Linkage
- llvm::Constant* Initializer = nullptr
- const llvm::Twine& Name = ""
- llvm::GlobalValue::ThreadLocalMode = NotThreadLocal
- unsigned int AddressSpace = 0
- bool isExternallyInitialized = false
¶void addAttribute(
llvm::StringRef Kind,
llvm::StringRef Val = llvm::StringRef())
void addAttribute(
llvm::StringRef Kind,
llvm::StringRef Val = llvm::StringRef())
Description
Add attribute to this global.
Declared at: llvm/include/llvm/IR/GlobalVariable.h:192
Parameters
- llvm::StringRef Kind
- llvm::StringRef Val = llvm::StringRef()
¶void addAttribute(Attribute::AttrKind Kind)
void addAttribute(Attribute::AttrKind Kind)
Description
Add attribute to this global.
Declared at: llvm/include/llvm/IR/GlobalVariable.h:187
Parameters
- Attribute::AttrKind Kind
¶void addDebugInfo(
llvm::DIGlobalVariableExpression* GV)
void addDebugInfo(
llvm::DIGlobalVariableExpression* GV)
Description
Attach a DIGlobalVariableExpression.
Declared at: llvm/include/llvm/IR/GlobalVariable.h:181
Parameters
¶static bool classof(const llvm::Value* V)
static bool classof(const llvm::Value* V)
Declared at: llvm/include/llvm/IR/GlobalVariable.h:250
Parameters
- const llvm::Value* V
¶void copyAttributesFrom(
const llvm::GlobalVariable* Src)
void copyAttributesFrom(
const llvm::GlobalVariable* Src)
Description
copyAttributesFrom - copy all additional attributes (those not needed to create a GlobalVariable) from the GlobalVariable Src to this one.
Declared at: llvm/include/llvm/IR/GlobalVariable.h:164
Parameters
- const llvm::GlobalVariable* Src
¶void dropAllReferences()
void dropAllReferences()
Description
Drop all references in preparation to destroy the GlobalVariable. This drops not only the reference to the initializer but also to any metadata.
Declared at: llvm/include/llvm/IR/GlobalVariable.h:178
¶void eraseFromParent()
void eraseFromParent()
Description
eraseFromParent - This method unlinks 'this' from the containing module and deletes it.
Declared at: llvm/include/llvm/IR/GlobalVariable.h:174
¶llvm::Attribute getAttribute(
llvm::StringRef Kind) const
llvm::Attribute getAttribute(
llvm::StringRef Kind) const
Description
Return the attribute object.
Declared at: llvm/include/llvm/IR/GlobalVariable.h:217
Parameters
- llvm::StringRef Kind
¶llvm::Attribute getAttribute(
Attribute::AttrKind Kind) const
llvm::Attribute getAttribute(
Attribute::AttrKind Kind) const
Description
Return the attribute object.
Declared at: llvm/include/llvm/IR/GlobalVariable.h:212
Parameters
- Attribute::AttrKind Kind
¶llvm::AttributeSet getAttributes() const
llvm::AttributeSet getAttributes() const
Description
Return the attribute set for this global
Declared at: llvm/include/llvm/IR/GlobalVariable.h:222
¶llvm::AttributeList getAttributesAsList(
unsigned int index) const
llvm::AttributeList getAttributesAsList(
unsigned int index) const
Description
Return attribute set as list with index. FIXME: This may not be required once ValueEnumerators in bitcode-writer can enumerate attribute-set.
Declared at: llvm/include/llvm/IR/GlobalVariable.h:229
Parameters
- unsigned int index
¶void getDebugInfo(
SmallVectorImpl<
llvm::DIGlobalVariableExpression*>& GVs)
const
void getDebugInfo(
SmallVectorImpl<
llvm::DIGlobalVariableExpression*>& GVs)
const
Description
Fill the vector with all debug info attachements.
Declared at: llvm/include/llvm/IR/GlobalVariable.h:184
Parameters
- SmallVectorImpl< llvm::DIGlobalVariableExpression*>& GVs
¶inline llvm::Constant* getInitializer()
inline llvm::Constant* getInitializer()
Declared at: llvm/include/llvm/IR/GlobalVariable.h:139
¶inline const llvm::Constant* getInitializer()
const
inline const llvm::Constant* getInitializer()
const
Description
getInitializer - Return the initializer for this global variable. It is illegal to call this method if the global is external, because we cannot tell what the value is initialized to!
Declared at: llvm/include/llvm/IR/GlobalVariable.h:135
¶bool hasAttribute(Attribute::AttrKind Kind) const
bool hasAttribute(Attribute::AttrKind Kind) const
Description
Return true if the attribute exists.
Declared at: llvm/include/llvm/IR/GlobalVariable.h:197
Parameters
- Attribute::AttrKind Kind
¶bool hasAttribute(llvm::StringRef Kind) const
bool hasAttribute(llvm::StringRef Kind) const
Description
Return true if the attribute exists.
Declared at: llvm/include/llvm/IR/GlobalVariable.h:202
Parameters
- llvm::StringRef Kind
¶bool hasAttributes() const
bool hasAttributes() const
Description
Return true if any attributes exist.
Declared at: llvm/include/llvm/IR/GlobalVariable.h:207
¶inline bool hasDefinitiveInitializer() const
inline bool hasDefinitiveInitializer() const
Description
hasDefinitiveInitializer - Whether the global variable has an initializer, and any other instances of the global (this can happen due to weak linkage) are guaranteed to have the same initializer. Note that if you want to transform a global, you must use hasUniqueInitializer() instead, because of the *_odr linkage type. Example: @a = global SomeType* null - Initializer is both definitive and unique. @b = global weak SomeType* null - Initializer is neither definitive nor unique. @c = global weak_odr SomeType* null - Initializer is definitive, but not unique.
Declared at: llvm/include/llvm/IR/GlobalVariable.h:109
¶bool hasImplicitSection() const
bool hasImplicitSection() const
Description
Check if section name is present
Declared at: llvm/include/llvm/IR/GlobalVariable.h:242
¶inline bool hasInitializer() const
inline bool hasInitializer() const
Description
Definitions have initializers, declarations don't.
Declared at: llvm/include/llvm/IR/GlobalVariable.h:91
¶inline bool hasUniqueInitializer() const
inline bool hasUniqueInitializer() const
Description
hasUniqueInitializer - Whether the global variable has an initializer, and any changes made to the initializer will turn up in the final executable.
Declared at: llvm/include/llvm/IR/GlobalVariable.h:121
¶bool isConstant() const
bool isConstant() const
Description
If the value is a global constant, its value is immutable throughout the runtime execution of the program. Assigning a value into the constant leads to undefined behavior.
Declared at: llvm/include/llvm/IR/GlobalVariable.h:152
¶bool isExternallyInitialized() const
bool isExternallyInitialized() const
Declared at: llvm/include/llvm/IR/GlobalVariable.h:155
¶void removeFromParent()
void removeFromParent()
Description
removeFromParent - This method unlinks 'this' from the containing module, but does not delete it.
Declared at: llvm/include/llvm/IR/GlobalVariable.h:169
¶void setAttributes(llvm::AttributeSet A)
void setAttributes(llvm::AttributeSet A)
Description
Set attribute list for this global
Declared at: llvm/include/llvm/IR/GlobalVariable.h:237
Parameters
¶void setConstant(bool Val)
void setConstant(bool Val)
Declared at: llvm/include/llvm/IR/GlobalVariable.h:153
Parameters
- bool Val
¶void setExternallyInitialized(bool Val)
void setExternallyInitialized(bool Val)
Declared at: llvm/include/llvm/IR/GlobalVariable.h:158
Parameters
- bool Val
¶void setInitializer(llvm::Constant* InitVal)
void setInitializer(llvm::Constant* InitVal)
Description
setInitializer - Sets the initializer for this global variable, removing any existing initializer if InitVal==NULL. If this GV has type T*, the initializer must have type T.
Declared at: llvm/include/llvm/IR/GlobalVariable.h:146
Parameters
- llvm::Constant* InitVal
¶~GlobalVariable()
~GlobalVariable()
Declared at: llvm/include/llvm/IR/GlobalVariable.h:67