LLVM API Documentation

Public Types | 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 Types

enum  ThreadLocalMode {
  NotThreadLocal = 0, GeneralDynamicTLSModel, LocalDynamicTLSModel, InitialExecTLSModel,
  LocalExecTLSModel
}

Public Member Functions

void * operator new (size_t s)
 GlobalVariable (Type *Ty, bool isConstant, LinkageTypes Linkage, Constant *Initializer=nullptr, const Twine &Name="", ThreadLocalMode=NotThreadLocal, unsigned AddressSpace=0, bool isExternallyInitialized=false)
 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 ()
 DECLARE_TRANSPARENT_OPERAND_ACCESSORS (Value)
 Provide fast operand accessors.
bool hasInitializer () const
bool hasDefinitiveInitializer () const
bool hasUniqueInitializer () const
const ConstantgetInitializer () const
ConstantgetInitializer ()
void setInitializer (Constant *InitVal)
bool isConstant () const
void setConstant (bool Val)
bool isThreadLocal () const
 If the value is "Thread Local", its value isn't shared by the threads.
void setThreadLocal (bool Val)
void setThreadLocalMode (ThreadLocalMode Val)
ThreadLocalMode getThreadLocalMode () const
bool isExternallyInitialized () const
void setExternallyInitialized (bool Val)
void copyAttributesFrom (const GlobalValue *Src) override
void removeFromParent () override
void eraseFromParent () override
void replaceUsesOfWithOnConstant (Value *From, Value *To, Use *U) override

Static Public Member Functions

static bool classof (const Value *V)

Friends

class SymbolTableListTraits< GlobalVariable, Module >

Detailed Description

Definition at line 35 of file GlobalVariable.h.


Member Enumeration Documentation

Enumerator:
NotThreadLocal 
GeneralDynamicTLSModel 
LocalDynamicTLSModel 
InitialExecTLSModel 
LocalExecTLSModel 

Definition at line 58 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 91 of file Globals.cpp.

References llvm::LeakDetector::addGarbageObject(), and llvm::Value::getType().

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 
)

Definition at line 80 of file GlobalVariable.h.

References llvm::User::NumOperands.


Member Function Documentation

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

Reimplemented from llvm::GlobalValue.

Definition at line 194 of file GlobalVariable.h.

References llvm::Value::getValueID(), and llvm::Value::GlobalVariableVal.

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.

Reimplemented from llvm::GlobalValue.

Definition at line 190 of file Globals.cpp.

References getThreadLocalMode(), and setThreadLocalMode().

Referenced by llvm::CloneModule(), and INITIALIZE_PASS().

Provide fast operand accessors.

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

Definition at line 142 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 107 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 119 of file GlobalVariable.h.

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

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 155 of file GlobalVariable.h.

Referenced by AnalyzeLoadFromClobberingMemInst(), CleanupPointerRootUsers(), FoldReinterpretLoadFromConstPtr(), llvm::getConstantStringInfo(), llvm::TargetLoweringObjectFile::getKindForGlobal(), llvm::JIT::getMemoryForGV(), INITIALIZE_PASS(), InstallGlobalCtors(), isSuitableForBSS(), llvm::AssemblyWriter::printGlobal(), and SRAGlobal().

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

Reimplemented from llvm::User.

Definition at line 54 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 145 of file Globals.cpp.

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

Referenced by setUsedInitializer().

void GlobalVariable::replaceUsesOfWithOnConstant ( Value From,
Value To,
Use U 
) [override, virtual]

Override Constant's implementation of this method so we can replace constant initializers.

Reimplemented from llvm::Constant.

Definition at line 153 of file Globals.cpp.

References llvm::User::getNumOperands(), llvm::User::getOperand(), and llvm::User::setOperand().

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

Definition at line 156 of file GlobalVariable.h.

Definition at line 171 of file GlobalVariable.h.

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 173 of file Globals.cpp.

References llvm::SequentialType::getElementType(), llvm::GlobalValue::getType(), llvm::Value::getType(), hasInitializer(), and llvm::User::NumOperands.

Referenced by llvm::CloneModule(), CommitValueTo(), and InstallGlobalCtors().

Definition at line 160 of file GlobalVariable.h.

References GeneralDynamicTLSModel, and NotThreadLocal.

Definition at line 163 of file GlobalVariable.h.

Referenced by copyAttributesFrom(), and LLVMSetThreadLocalMode().


Friends And Related Function Documentation

friend class SymbolTableListTraits< GlobalVariable, Module > [friend]

Definition at line 36 of file GlobalVariable.h.


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