LLVM API Documentation
#include <GlobalVariable.h>
Definition at line 35 of file GlobalVariable.h.
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 131 of file Globals.cpp.
References llvm::LeakDetector::addGarbageObject(), 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 |
||
) |
GlobalVariable ctor - This creates a global and inserts it before the specified other global.
Definition at line 150 of file Globals.cpp.
References llvm::LeakDetector::addGarbageObject(), llvm::Module::getGlobalList(), llvm::GlobalValue::getParent(), llvm::Value::getType(), llvm::iplist< NodeTy, Traits >::insert(), llvm::iplist< NodeTy, Traits >::push_back(), and llvm::GlobalValue::setThreadLocalMode().
llvm::GlobalVariable::~GlobalVariable | ( | ) | [inline] |
Definition at line 69 of file GlobalVariable.h.
References llvm::User::NumOperands.
static bool llvm::GlobalVariable::classof | ( | const Value * | V | ) | [inline, static] |
Reimplemented from llvm::GlobalObject.
Definition at line 173 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::GlobalObject.
Definition at line 228 of file Globals.cpp.
References llvm::GlobalValue::getThreadLocalMode(), and llvm::GlobalValue::setThreadLocalMode().
Referenced by llvm::CloneModule(), INITIALIZE_PASS(), and upgradeGlobalArray().
Provide fast operand accessors.
void GlobalVariable::eraseFromParent | ( | ) | [override, virtual] |
eraseFromParent - This method unlinks 'this' from the containing module and deletes it.
Implements llvm::GlobalValue.
Definition at line 187 of file Globals.cpp.
References llvm::iplist< NodeTy, Traits >::erase(), llvm::Module::getGlobalList(), and llvm::GlobalValue::getParent().
Referenced by INITIALIZE_PASS(), OptimizeAwayTrappingUsesOfLoads(), OptimizeGlobalAddressOfMalloc(), PerformHeapAllocSRoA(), setUsedInitializer(), and TryToShrinkGlobalToBoolean().
const Constant* llvm::GlobalVariable::getInitializer | ( | ) | const [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 127 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(), isSimpleEnoughPointerToCommit(), isSuitableForBSS(), LLVMGetInitializer(), llvm::AMDGPUTargetLowering::LowerGlobalAddress(), OptimizeOnceStoredGlobal(), llvm::AssemblyWriter::printGlobal(), llvm::ExecutionEngine::runStaticConstructorsDestructors(), SRAGlobal(), TryToShrinkGlobalToBoolean(), and upgradeGlobalArray().
Constant* llvm::GlobalVariable::getInitializer | ( | ) | [inline] |
Definition at line 131 of file GlobalVariable.h.
References hasInitializer().
bool llvm::GlobalVariable::hasDefinitiveInitializer | ( | ) | const [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 96 of file GlobalVariable.h.
References hasInitializer(), isExternallyInitialized(), and llvm::GlobalValue::mayBeOverridden().
Referenced by FoldReinterpretLoadFromConstPtr(), llvm::getConstantStringInfo(), and llvm::ObjectSizeOffsetVisitor::visitGlobalVariable().
bool llvm::GlobalVariable::hasInitializer | ( | ) | const [inline] |
Definitions have initializers, declarations don't.
Definition at line 78 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::AMDGPUTargetLowering::LowerGlobalAddress(), llvm::AssemblyWriter::printGlobal(), and setInitializer().
bool llvm::GlobalVariable::hasUniqueInitializer | ( | ) | const [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 108 of file GlobalVariable.h.
References hasInitializer(), isExternallyInitialized(), and llvm::GlobalValue::isWeakForLinker().
Referenced by isSimpleEnoughPointerToCommit().
bool llvm::GlobalVariable::isConstant | ( | ) | const [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 144 of file GlobalVariable.h.
Referenced by AnalyzeLoadFromClobberingMemInst(), CleanupPointerRootUsers(), FoldReinterpretLoadFromConstPtr(), llvm::getConstantStringInfo(), llvm::TargetLoweringObjectFile::getKindForGlobal(), INITIALIZE_PASS(), isSuitableForBSS(), llvm::AssemblyWriter::printGlobal(), SRAGlobal(), and upgradeGlobalArray().
bool llvm::GlobalVariable::isExternallyInitialized | ( | ) | const [inline] |
Definition at line 147 of file GlobalVariable.h.
Referenced by hasDefinitiveInitializer(), hasUniqueInitializer(), and llvm::AssemblyWriter::printGlobal().
void* llvm::GlobalVariable::operator new | ( | size_t | s | ) | [inline] |
Reimplemented from llvm::User.
Definition at line 51 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 183 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 191 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 145 of file GlobalVariable.h.
Referenced by EvaluateStaticConstructor().
void llvm::GlobalVariable::setExternallyInitialized | ( | bool | Val | ) | [inline] |
Definition at line 150 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 211 of file Globals.cpp.
References llvm::SequentialType::getElementType(), llvm::GlobalValue::getType(), llvm::Value::getType(), hasInitializer(), and llvm::User::NumOperands.
Referenced by llvm::CloneModule(), and CommitValueTo().
friend class SymbolTableListTraits< GlobalVariable, Module > [friend] |
Definition at line 36 of file GlobalVariable.h.