LLVM API Documentation

llvm::GlobalVariable Class Reference

#include <GlobalVariable.h>

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

List of all members.

Public Member Functions

void * operator new (size_t s)
 GlobalVariable (LLVMContext &Context, const Type *Ty, bool isConstant, LinkageTypes Linkage, Constant *Initializer=0, const Twine &Name="", bool ThreadLocal=false, unsigned AddressSpace=0)
 GlobalVariable (Module &M, const Type *Ty, bool isConstant, LinkageTypes Linkage, Constant *Initializer, const Twine &Name, GlobalVariable *InsertBefore=0, bool ThreadLocal=false, unsigned AddressSpace=0)
 ~GlobalVariable ()
 DECLARE_TRANSPARENT_OPERAND_ACCESSORS (Value)
 Provide fast operand accessors.
virtual bool isDeclaration () const
bool hasInitializer () const
bool hasDefinitiveInitializer () const
Constant * getInitializer () const
Constant * getInitializer ()
void setInitializer (Constant *CPV)
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 copyAttributesFrom (const GlobalValue *Src)
virtual void removeFromParent ()
virtual void eraseFromParent ()
virtual void replaceUsesOfWithOnConstant (Value *From, Value *To, Use *U)

Static Public Member Functions

static bool classof (const GlobalVariable *)
static bool classof (const Value *V)

Friends

class SymbolTableListTraits< GlobalVariable, Module >


Detailed Description

Definition at line 35 of file GlobalVariable.h.


Constructor & Destructor Documentation

GlobalVariable::GlobalVariable ( LLVMContext &  Context,
const Type *  Ty,
bool  isConstant,
LinkageTypes  Linkage,
Constant *  Initializer = 0,
const Twine &  Name = "",
bool  ThreadLocal = false,
unsigned  AddressSpace = 0 
)

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

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

GlobalVariable::GlobalVariable ( Module &  M,
const Type *  Ty,
bool  isConstant,
LinkageTypes  Linkage,
Constant *  Initializer,
const Twine &  Name,
GlobalVariable *  InsertBefore = 0,
bool  ThreadLocal = false,
unsigned  AddressSpace = 0 
)

GlobalVariable ctor - This creates a global and inserts it before the specified other global.

Definition at line 115 of file Globals.cpp.

References llvm::LeakDetector::addGarbageObject(), llvm::Module::getGlobalList(), llvm::GlobalValue::getParent(), and llvm::Value::getType().

llvm::GlobalVariable::~GlobalVariable (  )  [inline]

Definition at line 65 of file GlobalVariable.h.

References llvm::User::NumOperands.


Member Function Documentation

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

Reimplemented from llvm::User.

Definition at line 48 of file GlobalVariable.h.

References operator new().

llvm::GlobalVariable::DECLARE_TRANSPARENT_OPERAND_ACCESSORS ( Value   ) 

Provide fast operand accessors.

virtual bool llvm::GlobalVariable::isDeclaration (  )  const [inline, virtual]

isDeclaration - Is this global variable lacking an initializer? If so, the global variable is defined in some other translation unit, and is thus only a declaration here.

Implements llvm::GlobalValue.

Definition at line 75 of file GlobalVariable.h.

References llvm::User::getNumOperands().

Referenced by llvm::JIT::getOrEmitGlobalVariable(), hasInitializer(), isSimpleEnoughPointerToCommit(), LinkGlobals(), llvm::X86IntelAsmPrinter::PrintGlobalVariable(), llvm::ExecutionEngine::runStaticConstructorsDestructors(), and llvm::PIC16TargetObjectFile::SelectSectionForGlobal().

bool llvm::GlobalVariable::hasInitializer (  )  const [inline]

bool llvm::GlobalVariable::hasDefinitiveInitializer (  )  const [inline]

hasDefinitiveInitializer - Whether the global variable has an initializer, and this is the initializer that will be used in the final executable.

Definition at line 85 of file GlobalVariable.h.

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

Referenced by ComputeLoadResult(), and llvm::GetConstantStringInfo().

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

References hasInitializer().

Referenced by llvm::MachineModuleInfo::AnalyzeModule(), CommitValueTo(), ComputeLoadResult(), llvm::AsmPrinter::EmitComments(), llvm::ExecutionEngine::EmitGlobalVariable(), llvm::AsmPrinter::EmitSpecialLLVMGlobal(), FindStaticTors(), findUsedValues(), GetAddressedElementFromGlobal(), llvm::GetConstantStringInfo(), llvm::DIDescriptor::getDescriptorField(), llvm::DbgStopPointInst::getDirectory(), llvm::DbgStopPointInst::getFileName(), llvm::ProgramInfo::getFunction(), llvm::DIDescriptor::getGlobalVariableField(), llvm::TargetLoweringObjectFile::getKindForGlobal(), llvm::DIArray::getNumElements(), llvm::ProgramInfo::getSourceFile(), llvm::DIDescriptor::getStringField(), GetStringLengthH(), llvm::DIDescriptor::getUInt64Field(), InstallGlobalCtors(), isSimpleEnoughPointerToCommit(), isSuitableForBSS(), LinkAppendingVars(), LinkGlobalInits(), OptimizeOnceStoredGlobal(), ParseGlobalCtors(), llvm::X86IntelAsmPrinter::PrintGlobalVariable(), llvm::X86ATTAsmPrinter::PrintGlobalVariable(), llvm::MSILWriter::printVariableDefinition(), llvm::ExecutionEngine::runStaticConstructorsDestructors(), llvm::PIC16TargetObjectFile::SelectSectionForGlobal(), llvm::SourceFileInfo::SourceFileInfo(), llvm::SourceFunctionInfo::SourceFunctionInfo(), and SRAGlobal().

Constant* llvm::GlobalVariable::getInitializer (  )  [inline]

Definition at line 100 of file GlobalVariable.h.

References hasInitializer().

void llvm::GlobalVariable::setInitializer ( Constant *  CPV  )  [inline]

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

Referenced by llvm::GetConstantStringInfo(), llvm::TargetLoweringObjectFile::getKindForGlobal(), llvm::JIT::getMemoryForGV(), GetStringLengthH(), InstallGlobalCtors(), isSuitableForBSS(), LinkAppendingVars(), LinkGlobals(), llvm::DebugInfoFinder::processModule(), and SRAGlobal().

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

Definition at line 122 of file GlobalVariable.h.

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

bool llvm::GlobalVariable::isThreadLocal (  )  const [inline]

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

Definition at line 126 of file GlobalVariable.h.

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

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

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

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

References llvm::GlobalValue::copyAttributesFrom(), isThreadLocal(), and setThreadLocal().

void GlobalVariable::removeFromParent (  )  [virtual]

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

Implements llvm::GlobalValue.

Definition at line 147 of file Globals.cpp.

References llvm::Module::getGlobalList(), and llvm::GlobalValue::getParent().

void GlobalVariable::eraseFromParent (  )  [virtual]

eraseFromParent - This method unlinks 'this' from the containing module and deletes it.

Implements llvm::GlobalValue.

Definition at line 151 of file Globals.cpp.

References llvm::Module::getGlobalList(), and llvm::GlobalValue::getParent().

Referenced by InstallGlobalCtors(), OptimizeAwayTrappingUsesOfLoads(), OptimizeGlobalAddressOfMalloc(), PerformHeapAllocSRoA(), and llvm::DIDerivedType::replaceAllUsesWith().

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

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

Reimplemented from llvm::Constant.

Definition at line 155 of file Globals.cpp.

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

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

Definition at line 147 of file GlobalVariable.h.

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

Reimplemented from llvm::GlobalValue.

Definition at line 148 of file GlobalVariable.h.

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


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: