LLVM  mainline
Public Member Functions | Static Public Member Functions | Friends
llvm::GlobalVariable Class Reference

#include <GlobalVariable.h>

Inheritance diagram for llvm::GlobalVariable:
Inheritance graph
[legend]
Collaboration diagram for llvm::GlobalVariable:
Collaboration graph
[legend]

List of all members.

Public Member Functions

void * operator new (size_t s)
 Allocate a User with an operand pointer co-allocated.
 GlobalVariable (Type *Ty, bool isConstant, LinkageTypes Linkage, Constant *Initializer=nullptr, const Twine &Name="", ThreadLocalMode=NotThreadLocal, unsigned AddressSpace=0, bool isExternallyInitialized=false)
 GlobalVariable ctor - If a parent module is specified, the global is automatically inserted into the end of the specified modules global list.
 GlobalVariable (Module &M, Type *Ty, bool isConstant, LinkageTypes Linkage, Constant *Initializer, const Twine &Name="", GlobalVariable *InsertBefore=nullptr, ThreadLocalMode=NotThreadLocal, unsigned AddressSpace=0, bool isExternallyInitialized=false)
 GlobalVariable ctor - This creates a global and inserts it before the specified other global.
 ~GlobalVariable () override
 DECLARE_TRANSPARENT_OPERAND_ACCESSORS (Value)
 Provide fast operand accessors.
bool hasInitializer () const
 Definitions have initializers, declarations don't.
bool hasDefinitiveInitializer () const
 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.
bool hasUniqueInitializer () const
 hasUniqueInitializer - Whether the global variable has an initializer, and any changes made to the initializer will turn up in the final executable.
const ConstantgetInitializer () const
 getInitializer - Return the initializer for this global variable.
ConstantgetInitializer ()
void setInitializer (Constant *InitVal)
 setInitializer - Sets the initializer for this global variable, removing any existing initializer if InitVal==NULL.
bool isConstant () const
 If the value is a global constant, its value is immutable throughout the runtime execution of the program.
void setConstant (bool Val)
bool isExternallyInitialized () const
void setExternallyInitialized (bool Val)
void copyAttributesFrom (const GlobalValue *Src) override
 copyAttributesFrom - copy all additional attributes (those not needed to create a GlobalVariable) from the GlobalVariable Src to this one.
void removeFromParent () override
 removeFromParent - This method unlinks 'this' from the containing module, but does not delete it.
void eraseFromParent () override
 eraseFromParent - This method unlinks 'this' from the containing module and deletes it.

Static Public Member Functions

static bool classof (const Value *V)

Friends

class SymbolTableListTraits< GlobalVariable >

Detailed Description

Definition at line 34 of file GlobalVariable.h.


Constructor & Destructor Documentation

GlobalVariable::GlobalVariable ( Type Ty,
bool  isConstant,
LinkageTypes  Linkage,
Constant Initializer = nullptr,
const Twine Name = "",
ThreadLocalMode  TLMode = NotThreadLocal,
unsigned  AddressSpace = 0,
bool  isExternallyInitialized = false 
)

GlobalVariable ctor - If a parent module is specified, the global is automatically inserted into the end of the specified modules global list.

Definition at line 183 of file Globals.cpp.

References llvm::Value::getType(), and llvm::GlobalValue::setThreadLocalMode().

GlobalVariable::GlobalVariable ( Module M,
Type Ty,
bool  isConstant,
LinkageTypes  Linkage,
Constant Initializer,
const Twine Name = "",
GlobalVariable InsertBefore = nullptr,
ThreadLocalMode  TLMode = NotThreadLocal,
unsigned  AddressSpace = 0,
bool  isExternallyInitialized = false 
)
llvm::GlobalVariable::~GlobalVariable ( ) [inline, override]

Definition at line 67 of file GlobalVariable.h.

References llvm::User::setGlobalVariableNumOperands().


Member Function Documentation

static bool llvm::GlobalVariable::classof ( const Value V) [inline, static]

Reimplemented from llvm::GlobalObject.

Definition at line 163 of file GlobalVariable.h.

References llvm::Value::getValueID().

void GlobalVariable::copyAttributesFrom ( const GlobalValue Src) [override, virtual]

copyAttributesFrom - copy all additional attributes (those not needed to create a GlobalVariable) from the GlobalVariable Src to this one.

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

Reimplemented from llvm::GlobalObject.

Definition at line 258 of file Globals.cpp.

References setExternallyInitialized(), and llvm::GlobalValue::setThreadLocalMode().

Referenced by llvm::orc::cloneGlobalVariableDecl(), llvm::CloneModule(), INITIALIZE_PASS(), PerformHeapAllocSRoA(), SRAGlobal(), and TryToShrinkGlobalToBoolean().

Provide fast operand accessors.

void GlobalVariable::eraseFromParent ( ) [override, virtual]

Definition at line 125 of file GlobalVariable.h.

References hasInitializer().

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:

= global SomeType* null - Initializer is both definitive and unique.

= global weak SomeType* null - Initializer is neither definitive nor unique.

= global weak_odr SomeType* null - Initializer is definitive, but not unique.

Definition at line 95 of file GlobalVariable.h.

References hasInitializer(), isExternallyInitialized(), and llvm::GlobalValue::mayBeOverridden().

Referenced by FoldReinterpretLoadFromConstPtr(), llvm::getConstantStringInfo(), and llvm::ObjectSizeOffsetVisitor::visitGlobalVariable().

hasUniqueInitializer - Whether the global variable has an initializer, and any changes made to the initializer will turn up in the final executable.

Definition at line 107 of file GlobalVariable.h.

References isExternallyInitialized(), and llvm::GlobalValue::isStrongDefinitionForLinker().

Referenced by isSimpleEnoughPointerToCommit().

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.

Definition at line 138 of file GlobalVariable.h.

Referenced by AnalyzeLoadFromClobberingMemInst(), CleanupPointerRootUsers(), llvm::orc::cloneGlobalVariableDecl(), FoldReinterpretLoadFromConstPtr(), llvm::getConstantStringInfo(), llvm::TargetLoweringObjectFile::getKindForGlobal(), INITIALIZE_PASS(), isGOTEquivalentCandidate(), isSuitableForBSS(), and SRAGlobal().

Definition at line 141 of file GlobalVariable.h.

Referenced by hasDefinitiveInitializer(), hasUniqueInitializer(), and SRAGlobal().

void* llvm::GlobalVariable::operator new ( size_t  Size) [inline]

Allocate a User with an operand pointer co-allocated.

This is used for subclasses which need to allocate a variable number of operands, ie, 'hung off uses'.

Reimplemented from llvm::User.

Definition at line 49 of file GlobalVariable.h.

References operator new().

void GlobalVariable::removeFromParent ( ) [override, virtual]

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

Implements llvm::GlobalValue.

Definition at line 227 of file Globals.cpp.

References llvm::Module::getGlobalList(), llvm::ilist_node< GlobalVariable >::getIterator(), llvm::GlobalValue::getParent(), and llvm::iplist< NodeTy, Traits >::remove().

Referenced by setUsedInitializer().

void llvm::GlobalVariable::setConstant ( bool  Val) [inline]

Definition at line 139 of file GlobalVariable.h.

Referenced by EvaluateStaticConstructor().

Definition at line 144 of file GlobalVariable.h.

Referenced by copyAttributesFrom(), and SRAGlobal().

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.

Definition at line 235 of file Globals.cpp.

References llvm::Value::getType(), llvm::GlobalValue::getValueType(), hasInitializer(), and llvm::User::setGlobalVariableNumOperands().

Referenced by llvm::CloneModule(), CommitValueTo(), and llvm::orc::moveGlobalVariableInitializer().


Friends And Related Function Documentation

friend class SymbolTableListTraits< GlobalVariable > [friend]

Definition at line 35 of file GlobalVariable.h.


The documentation for this class was generated from the following files: