LLVM API Documentation
#include <GlobalVariable.h>
Friends | |
class | SymbolTableListTraits< GlobalVariable, Module > |
Additional Inherited Members | |
![]() | |
static const unsigned | MaximumAlignment = 1u << 29 |
![]() | |
GlobalValue (Type *ty, ValueTy vty, Use *Ops, unsigned NumOps, LinkageTypes linkage, const Twine &Name) | |
![]() | |
Constant (Type *ty, ValueTy vty, Use *Ops, unsigned NumOps) | |
void | destroyConstantImpl () |
![]() | |
void * | operator new (size_t s, unsigned Us) |
User (Type *ty, unsigned vty, Use *OpList, unsigned NumOps) | |
Use * | allocHungoffUses (unsigned) const |
void | dropHungoffUses () |
template<int Idx> | |
Use & | Op () |
template<int Idx> | |
const Use & | Op () const |
![]() | |
virtual void | printCustom (raw_ostream &O) const |
Value (Type *Ty, unsigned scid) | |
unsigned short | getSubclassDataFromValue () const |
void | setValueSubclassData (unsigned short D) |
![]() | |
ilist_node () | |
![]() | |
template<int Idx, typename U > | |
static Use & | OpFrom (const U *that) |
![]() | |
LinkageTypes | Linkage: 5 |
unsigned | Visibility: 2 |
unsigned | Alignment: 16 |
unsigned | UnnamedAddr: 1 |
Module * | Parent |
std::string | Section |
![]() | |
Use * | OperandList |
unsigned | NumOperands |
![]() | |
unsigned char | SubclassOptionalData: 7 |
Definition at line 35 of file GlobalVariable.h.
Enumerator | |
---|---|
NotThreadLocal | |
GeneralDynamicTLSModel | |
LocalDynamicTLSModel | |
InitialExecTLSModel | |
LocalExecTLSModel |
Definition at line 58 of file GlobalVariable.h.
GlobalVariable::GlobalVariable | ( | Type * | Ty, |
bool | isConstant, | ||
LinkageTypes | Linkage, | ||
Constant * | Initializer = 0 , |
||
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 84 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 = 0 , |
||
ThreadLocalMode | TLMode = NotThreadLocal , |
||
unsigned | AddressSpace = 0 , |
||
bool | isExternallyInitialized = false |
||
) |
GlobalVariable ctor - This creates a global and inserts it before the specified other global.
Definition at line 104 of file Globals.cpp.
References llvm::LeakDetector::addGarbageObject(), llvm::Module::getGlobalList(), llvm::GlobalValue::getParent(), llvm::Value::getType(), llvm::iplist< NodeTy, Traits >::insert(), and llvm::iplist< NodeTy, Traits >::push_back().
|
inline |
Definition at line 80 of file GlobalVariable.h.
References llvm::User::NumOperands.
Definition at line 194 of file GlobalVariable.h.
References llvm::Value::getValueID(), and llvm::Value::GlobalVariableVal.
|
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 183 of file Globals.cpp.
References llvm::GlobalValue::copyAttributesFrom(), isThreadLocal(), and setThreadLocal().
Referenced by llvm::CloneModule(), and INITIALIZE_PASS().
llvm::GlobalVariable::DECLARE_TRANSPARENT_OPERAND_ACCESSORS | ( | Value | ) |
Provide fast operand accessors.
|
virtual |
eraseFromParent - This method unlinks 'this' from the containing module and deletes it.
Implements llvm::GlobalValue.
Definition at line 142 of file Globals.cpp.
References llvm::iplist< NodeTy, Traits >::erase(), llvm::Module::getGlobalList(), and llvm::GlobalValue::getParent().
Referenced by INITIALIZE_PASS(), InstallGlobalCtors(), OptimizeAwayTrappingUsesOfLoads(), OptimizeGlobalAddressOfMalloc(), PerformHeapAllocSRoA(), setUsedInitializer(), and TryToShrinkGlobalToBoolean().
|
inline |
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!
Definition at line 138 of file GlobalVariable.h.
References hasInitializer().
Referenced by llvm::MachineModuleInfo::AnalyzeModule(), llvm::collectUsedGlobalVariables(), llvm::AsmPrinter::EmitGlobalVariable(), llvm::ExecutionEngine::EmitGlobalVariable(), llvm::AsmPrinter::EmitSpecialLLVMGlobal(), llvm::ExtractTypeInfo(), FindUsedValues(), findUsedValues(), llvm::InstCombiner::FoldCmpLoadFromIndexedGlobal(), FoldReinterpretLoadFromConstPtr(), llvm::getConstantStringInfo(), llvm::TargetLoweringObjectFile::getKindForGlobal(), INITIALIZE_PASS(), InstallGlobalCtors(), isSimpleEnoughPointerToCommit(), isSuitableForBSS(), LLVMGetInitializer(), OptimizeOnceStoredGlobal(), ParseGlobalCtors(), llvm::AssemblyWriter::printGlobal(), llvm::ExecutionEngine::runStaticConstructorsDestructors(), SRAGlobal(), and TryToShrinkGlobalToBoolean().
|
inline |
Definition at line 142 of file GlobalVariable.h.
References hasInitializer().
|
inline |
Definition at line 164 of file GlobalVariable.h.
Referenced by getEncodedThreadLocalMode(), getSelectedTLSModel(), INITIALIZE_PASS(), InstallGlobalCtors(), OptimizeGlobalAddressOfMalloc(), PerformHeapAllocSRoA(), llvm::AssemblyWriter::printGlobal(), SRAGlobal(), and TryToShrinkGlobalToBoolean().
|
inline |
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().
|
inline |
Definitions have initializers, declarations don't.
Definition at line 89 of file GlobalVariable.h.
References llvm::GlobalValue::isDeclaration().
Referenced by llvm::MachineModuleInfo::AnalyzeModule(), llvm::collectUsedGlobalVariables(), CommitValueTo(), llvm::AsmPrinter::EmitGlobalVariable(), llvm::AsmPrinter::EmitSpecialLLVMGlobal(), llvm::ExtractTypeInfo(), getInitializer(), llvm::DataLayout::getPreferredAlignment(), hasDefinitiveInitializer(), hasUniqueInitializer(), INITIALIZE_PASS(), LLVMGetInitializer(), llvm::AssemblyWriter::printGlobal(), and setInitializer().
|
inline |
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().
|
inline |
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().
|
inline |
Definition at line 168 of file GlobalVariable.h.
Referenced by hasDefinitiveInitializer(), hasUniqueInitializer(), and llvm::AssemblyWriter::printGlobal().
|
inline |
If the value is "Thread Local", its value isn't shared by the threads.
Definition at line 159 of file GlobalVariable.h.
References NotThreadLocal.
Referenced by copyAttributesFrom(), llvm::CompileUnit::createGlobalVariableDIE(), llvm::ExecutionEngine::EmitGlobalVariable(), llvm::SelectionDAG::getGlobalAddress(), llvm::TargetLoweringObjectFile::getKindForGlobal(), and llvm::JIT::getMemoryForGV().
|
inline |
Definition at line 54 of file GlobalVariable.h.
|
virtual |
removeFromParent - This method unlinks 'this' from the containing module, but does not delete it.
Implements llvm::GlobalValue.
Definition at line 138 of file Globals.cpp.
References llvm::Module::getGlobalList(), llvm::GlobalValue::getParent(), and llvm::iplist< NodeTy, Traits >::remove().
Referenced by setUsedInitializer().
Override Constant's implementation of this method so we can replace constant initializers.
Reimplemented from llvm::Constant.
Definition at line 146 of file Globals.cpp.
References llvm::User::getNumOperands(), llvm::User::getOperand(), and llvm::User::setOperand().
|
inline |
Definition at line 156 of file GlobalVariable.h.
|
inline |
Definition at line 171 of file GlobalVariable.h.
void GlobalVariable::setInitializer | ( | Constant * | InitVal | ) |
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 166 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().
|
inline |
Definition at line 160 of file GlobalVariable.h.
References GeneralDynamicTLSModel, and NotThreadLocal.
Referenced by copyAttributesFrom().
|
inline |
Definition at line 163 of file GlobalVariable.h.
Referenced by LLVMSetThreadLocalMode().
|
friend |
Definition at line 36 of file GlobalVariable.h.