LLVM API Documentation

Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes
llvm::GlobalValue Class Reference

#include <GlobalValue.h>

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

List of all members.

Public Types

enum  LinkageTypes {
  ExternalLinkage = 0, AvailableExternallyLinkage, LinkOnceAnyLinkage, LinkOnceODRLinkage,
  WeakAnyLinkage, WeakODRLinkage, AppendingLinkage, InternalLinkage,
  PrivateLinkage, ExternalWeakLinkage, CommonLinkage
}
 An enumeration for the kinds of linkage for global values. More...
enum  VisibilityTypes { DefaultVisibility = 0, HiddenVisibility, ProtectedVisibility }
 An enumeration for the kinds of visibility of global values. More...
enum  DLLStorageClassTypes { DefaultStorageClass = 0, DLLImportStorageClass = 1, DLLExportStorageClass = 2 }
 Storage classes of global values for PE targets. More...

Public Member Functions

 ~GlobalValue ()
unsigned getAlignment () const
void setAlignment (unsigned Align)
bool hasUnnamedAddr () const
void setUnnamedAddr (bool Val)
VisibilityTypes getVisibility () const
bool hasDefaultVisibility () const
bool hasHiddenVisibility () const
bool hasProtectedVisibility () const
void setVisibility (VisibilityTypes V)
DLLStorageClassTypes getDLLStorageClass () const
bool hasDLLImportStorageClass () const
bool hasDLLExportStorageClass () const
void setDLLStorageClass (DLLStorageClassTypes C)
bool hasSection () const
const std::string & getSection () const
void setSection (StringRef S)
bool use_empty_except_constants ()
 Determine if the usage of this global value is empty except for transitively dead constants.
PointerTypegetType () const
 getType - Global values are always pointers.
bool hasExternalLinkage () const
bool hasAvailableExternallyLinkage () const
bool hasLinkOnceLinkage () const
bool hasWeakLinkage () const
bool hasAppendingLinkage () const
bool hasInternalLinkage () const
bool hasPrivateLinkage () const
bool hasLocalLinkage () const
bool hasExternalWeakLinkage () const
bool hasCommonLinkage () const
void setLinkage (LinkageTypes LT)
LinkageTypes getLinkage () const
bool isDiscardableIfUnused () const
bool mayBeOverridden () const
bool isWeakForLinker () const
virtual void copyAttributesFrom (const GlobalValue *Src)
void destroyConstant () override
 Override from Constant class.
bool isDeclaration () const
virtual void removeFromParent ()=0
virtual void eraseFromParent ()=0
ModulegetParent ()
const ModulegetParent () const
const DataLayoutgetDataLayout () const
Materialization

Materialization is used to construct functions only as they're needed. This is useful to reduce memory usage in LLVM or parsing work done by the BitcodeReader to load the Module.

bool isMaterializable () const
bool isDematerializable () const
bool Materialize (std::string *ErrInfo=nullptr)
void Dematerialize ()

Static Public Member Functions

static LinkageTypes getLinkOnceLinkage (bool ODR)
static LinkageTypes getWeakLinkage (bool ODR)
static bool isExternalLinkage (LinkageTypes Linkage)
static bool isAvailableExternallyLinkage (LinkageTypes Linkage)
static bool isLinkOnceLinkage (LinkageTypes Linkage)
static bool isWeakLinkage (LinkageTypes Linkage)
static bool isAppendingLinkage (LinkageTypes Linkage)
static bool isInternalLinkage (LinkageTypes Linkage)
static bool isPrivateLinkage (LinkageTypes Linkage)
static bool isLocalLinkage (LinkageTypes Linkage)
static bool isExternalWeakLinkage (LinkageTypes Linkage)
static bool isCommonLinkage (LinkageTypes Linkage)
static bool isDiscardableIfUnused (LinkageTypes Linkage)
static bool mayBeOverridden (LinkageTypes Linkage)
static bool isWeakForLinker (LinkageTypes Linkage)
static StringRef getRealLinkageName (StringRef Name)
static bool classof (const Value *V)

Protected Member Functions

 GlobalValue (Type *ty, ValueTy vty, Use *Ops, unsigned NumOps, LinkageTypes linkage, const Twine &Name)

Protected Attributes

LinkageTypes Linkage: 5
unsigned Visibility: 2
unsigned Alignment: 16
unsigned UnnamedAddr: 1
unsigned DllStorageClass: 2
ModuleParent
std::string Section

Detailed Description

Definition at line 29 of file GlobalValue.h.


Member Enumeration Documentation

Storage classes of global values for PE targets.

Enumerator:
DefaultStorageClass 
DLLImportStorageClass 

Function to be imported from DLL.

DLLExportStorageClass 

Function to be accessible from DLL.

Definition at line 55 of file GlobalValue.h.

An enumeration for the kinds of linkage for global values.

Enumerator:
ExternalLinkage 

Externally visible function.

AvailableExternallyLinkage 

Available for inspection, not emission.

LinkOnceAnyLinkage 

Keep one copy of function when linking (inline)

LinkOnceODRLinkage 

Same, but only replaced by something equivalent.

WeakAnyLinkage 

Keep one copy of named function when linking (weak)

WeakODRLinkage 

Same, but only replaced by something equivalent.

AppendingLinkage 

Special purpose, only applies to global arrays.

InternalLinkage 

Rename collisions when linking (static functions).

PrivateLinkage 

Like Internal, but omit from symbol table.

ExternalWeakLinkage 

ExternalWeak linkage description.

CommonLinkage 

Tentative definitions.

Definition at line 33 of file GlobalValue.h.

An enumeration for the kinds of visibility of global values.

Enumerator:
DefaultVisibility 

The GV is visible.

HiddenVisibility 

The GV is hidden.

ProtectedVisibility 

The GV is protected.

Definition at line 48 of file GlobalValue.h.


Constructor & Destructor Documentation

llvm::GlobalValue::GlobalValue ( Type ty,
ValueTy  vty,
Use Ops,
unsigned  NumOps,
LinkageTypes  linkage,
const Twine Name 
) [inline, protected]

Definition at line 62 of file GlobalValue.h.

References llvm::Value::setName().

Definition at line 80 of file GlobalValue.h.

References llvm::Constant::removeDeadConstantUsers().


Member Function Documentation

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

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

Reimplemented in llvm::Function, and llvm::GlobalVariable.

Definition at line 55 of file Globals.cpp.

References getAlignment(), getDLLStorageClass(), getSection(), getVisibility(), hasUnnamedAddr(), setAlignment(), setDLLStorageClass(), setSection(), setUnnamedAddr(), and setVisibility().

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

Dematerialize - If this GlobalValue is read in, and if the GVMaterializer supports it, release the memory for the function, and set it up to be materialized lazily. If !isDematerializable(), this method is a noop.

Definition at line 39 of file Globals.cpp.

References llvm::Module::Dematerialize(), and getParent().

void GlobalValue::destroyConstant ( ) [override, virtual]

Override from Constant class.

Override destroyConstant to make sure it doesn't get called on GlobalValue's because they shouldn't be treated like other constants.

Reimplemented from llvm::Constant.

Definition at line 49 of file Globals.cpp.

References llvm_unreachable.

virtual void llvm::GlobalValue::eraseFromParent ( ) [pure virtual]

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

Implemented in llvm::Function, llvm::GlobalVariable, and llvm::GlobalAlias.

static LinkageTypes llvm::GlobalValue::getLinkOnceLinkage ( bool  ODR) [inline, static]

Definition at line 131 of file GlobalValue.h.

References LinkOnceAnyLinkage, and LinkOnceODRLinkage.

getParent - Get the module that this global value is contained inside of...

Definition at line 280 of file GlobalValue.h.

References Parent.

Referenced by changeToUnreachable(), CloneDebugInfoMetadata(), llvm::IRBuilderBase::CreateGlobalString(), llvm::IRBuilderBase::CreateLifetimeEnd(), llvm::IRBuilderBase::CreateLifetimeStart(), llvm::IRBuilderBase::CreateMemCpy(), llvm::IRBuilderBase::CreateMemMove(), llvm::IRBuilderBase::CreateMemSet(), Dematerialize(), llvm::EmitBinaryFloatFnCall(), llvm::EmitFPutC(), llvm::EmitFPutS(), llvm::AsmPrinter::EmitFunctionHeader(), llvm::EmitFWrite(), llvm::AsmPrinter::EmitGlobalVariable(), llvm::ARM64TargetLowering::emitLoadLinked(), llvm::ARMTargetLowering::emitLoadLinked(), llvm::EmitMemChr(), llvm::EmitMemCmp(), llvm::EmitMemCpyChk(), llvm::EmitPutChar(), llvm::EmitPutS(), llvm::ARM64TargetLowering::emitStoreConditional(), llvm::ARMTargetLowering::emitStoreConditional(), llvm::EmitStrChr(), llvm::EmitStrCpy(), llvm::EmitStrLen(), llvm::EmitStrNCmp(), llvm::EmitStrNCpy(), llvm::EmitStrNLen(), llvm::EmitUnaryFloatFnCall(), llvm::GlobalAlias::eraseFromParent(), llvm::GlobalVariable::eraseFromParent(), llvm::Function::eraseFromParent(), llvm::CodeExtractor::extractCodeRegion(), llvm::findAllNVVMAnnotation(), llvm::findOneNVVMAnnotation(), forceRenaming(), generateUnsignedDivisionCode(), llvm::CallSiteBase< Function, Value, User, Instruction, CallInst, InvokeInst, User::op_iterator >::getCaller(), getDataLayout(), llvm::GCModuleInfo::getFunctionInfo(), llvm::Trace::getModule(), getModuleFromVal(), llvm::CallGraph::getOrInsertFunction(), getParent(), llvm::MCJIT::getPointerToFunction(), llvm::SparcTargetLowering::getSRetArgSize(), llvm::GlobalVariable::GlobalVariable(), hasDebugInfo(), hasReturnsTwiceAttr(), INITIALIZE_PASS(), llvm::InlineFunction(), InstallGlobalCtors(), isDematerializable(), llvm::isImageReadOnly(), llvm::isImageReadWrite(), llvm::isImageWriteOnly(), llvm::SpecialCaseList::isIn(), llvm::DiagnosticInfoOptimizationRemark::isLocationAvailable(), isMaterializable(), llvm::isSampler(), llvm::lintFunction(), LLVMGetNextFunction(), LLVMGetNextGlobal(), LLVMGetPreviousFunction(), LLVMGetPreviousGlobal(), nvptx::LowerConstant(), lowerConstant(), llvm::LowerDbgDeclare(), llvm::IntrinsicLowering::LowerToByteSwap(), Materialize(), llvm::object::IRObjectFile::moveSymbolNext(), OptimizeGlobalAddressOfMalloc(), PerformHeapAllocSRoA(), llvm::Value::print(), llvm::AssemblyWriter::printFunction(), llvm::AssemblyWriter::printGlobal(), PrintOps(), ProcessUAddIdiom(), ProcessUGT_ADDCST_ADD(), ProcessUMulZExtIdiom(), promoteSingleBlockAlloca(), llvm::GlobalAlias::removeFromParent(), llvm::GlobalVariable::removeFromParent(), llvm::Function::removeFromParent(), ReplaceCallWith(), rewriteSingleStoreAlloca(), llvm::JIT::runFunction(), llvm::NVPTXLowerAggrCopies::runOnFunction(), llvm::StackProtector::runOnFunction(), setUsedInitializer(), SRAGlobal(), SwitchToLookupTable(), TryToShrinkGlobalToBoolean(), llvm::UpgradeIntrinsicCall(), UpgradeIntrinsicFunction1(), UpgradeSSE41Function(), usedInOneFunc(), llvm::InstCombiner::visitCallInst(), and llvm::InstCombiner::visitFPTrunc().

Definition at line 281 of file GlobalValue.h.

References Parent.

static StringRef llvm::GlobalValue::getRealLinkageName ( StringRef  Name) [inline, static]

getRealLinkageName - If special LLVM prefix that is used to inform the asm printer to not emit usual symbol prefix before the symbol name is used then return linkage name after skipping this special LLVM prefix.

Definition at line 229 of file GlobalValue.h.

References llvm::StringRef::empty(), and llvm::StringRef::substr().

Referenced by llvm::DwarfCompileUnit::createGlobalVariableDIE(), fixupSubprogramName(), and llvm::DwarfUnit::getOrCreateSubprogramDIE().

const std::string& llvm::GlobalValue::getSection ( ) const [inline]
static LinkageTypes llvm::GlobalValue::getWeakLinkage ( bool  ODR) [inline, static]

Definition at line 134 of file GlobalValue.h.

References WeakAnyLinkage, and WeakODRLinkage.

Definition at line 93 of file GlobalValue.h.

References DefaultVisibility, and Visibility.

Referenced by bindsLocally(), and llvm::ARM64Subtarget::ClassifyGlobalReference().

Definition at line 103 of file GlobalValue.h.

References DLLImportStorageClass, and DllStorageClass.

Definition at line 95 of file GlobalValue.h.

References ProtectedVisibility, and Visibility.

bool llvm::GlobalValue::hasSection ( ) const [inline]
static bool llvm::GlobalValue::isAppendingLinkage ( LinkageTypes  Linkage) [inline, static]

Definition at line 150 of file GlobalValue.h.

References AppendingLinkage.

Referenced by hasAppendingLinkage().

Definition at line 141 of file GlobalValue.h.

References AvailableExternallyLinkage.

Referenced by hasAvailableExternallyLinkage().

static bool llvm::GlobalValue::isCommonLinkage ( LinkageTypes  Linkage) [inline, static]

Definition at line 165 of file GlobalValue.h.

References CommonLinkage.

Referenced by hasCommonLinkage().

isDeclaration - Return true if the primary definition of this global value is outside of the current translation unit.

Definition at line 73 of file Globals.cpp.

References F().

Referenced by llvm::Interpreter::callFunction(), llvm::ARM64Subtarget::ClassifyGlobalReference(), cxxDtorIsEmpty(), llvm::AsmPrinter::doFinalization(), llvm::ExecutionEngine::emitGlobals(), llvm::AsmPrinter::EmitGlobalVariable(), llvm::MCJIT::findModuleForSymbol(), getCalledFunction(), llvm::GCModuleInfo::getFunctionInfo(), llvm::Inliner::getInlineThreshold(), llvm::TargetLoweringObjectFile::getKindForGlobal(), llvm::JIT::getOrEmitGlobalVariable(), llvm::JIT::getPointerToFunction(), llvm::MCJIT::getPointerToFunction(), llvm::object::IRObjectFile::getSymbolFlags(), llvm::TargetMachine::getTLSModel(), llvm::ARMSubtarget::GVIsIndirectSymbol(), llvm::GlobalVariable::hasInitializer(), llvm::PPCSubtarget::hasLazyResolverStub(), INITIALIZE_PASS(), llvm::InlineFunction(), isDeclaration(), llvm::BitcodeReader::isDematerializable(), llvm::isFreeCall(), llvm::HexagonTargetObjectFile::IsGlobalInSmallSection(), llvm::MipsTargetObjectFile::IsGlobalInSmallSection(), llvm::BitcodeReader::isMaterializable(), isNonGhostDeclaration(), llvm::TargetLowering::isOffsetFoldingLegal(), llvm::lintFunction(), llvm::AssemblyWriter::printFunction(), llvm::Inliner::removeDeadFunctions(), llvm::FPPassManager::runOnFunction(), llvm::MipsOs16::runOnModule(), llvm::Inliner::runOnSCC(), llvm::ExecutionEngine::runStaticConstructorsDestructors(), shouldInternalize(), llvm::verifyFunction(), and llvm::Interpreter::visitCallSite().

isDematerializable - Returns true if this function was loaded from a GVMaterializer that's still attached to its Module and that knows how to dematerialize the function.

Definition at line 33 of file Globals.cpp.

References getParent(), and llvm::Module::isDematerializable().

static bool llvm::GlobalValue::isDiscardableIfUnused ( LinkageTypes  Linkage) [inline, static]

isDiscardableIfUnused - Whether the definition of this global may be discarded if it is not used in its compilation unit.

Definition at line 171 of file GlobalValue.h.

References isLinkOnceLinkage(), and isLocalLinkage().

Referenced by makeVisible().

Definition at line 214 of file GlobalValue.h.

References Linkage.

static bool llvm::GlobalValue::isExternalLinkage ( LinkageTypes  Linkage) [inline, static]

Definition at line 138 of file GlobalValue.h.

References ExternalLinkage.

Referenced by hasExternalLinkage(), and llvm::GlobalAlias::isValidLinkage().

static bool llvm::GlobalValue::isExternalWeakLinkage ( LinkageTypes  Linkage) [inline, static]

Definition at line 162 of file GlobalValue.h.

References ExternalWeakLinkage.

Referenced by hasExternalWeakLinkage().

static bool llvm::GlobalValue::isInternalLinkage ( LinkageTypes  Linkage) [inline, static]

Definition at line 153 of file GlobalValue.h.

References InternalLinkage.

Referenced by hasInternalLinkage(), and isLocalLinkage().

static bool llvm::GlobalValue::isLinkOnceLinkage ( LinkageTypes  Linkage) [inline, static]
static bool llvm::GlobalValue::isLocalLinkage ( LinkageTypes  Linkage) [inline, static]
static bool llvm::GlobalValue::isPrivateLinkage ( LinkageTypes  Linkage) [inline, static]

Definition at line 156 of file GlobalValue.h.

References PrivateLinkage.

Referenced by hasPrivateLinkage(), and isLocalLinkage().

static bool llvm::GlobalValue::isWeakForLinker ( LinkageTypes  Linkage) [inline, static]

Definition at line 220 of file GlobalValue.h.

References isWeakForLinker(), and Linkage.

Referenced by llvm::GlobalVariable::hasUniqueInitializer(), and isWeakForLinker().

static bool llvm::GlobalValue::isWeakLinkage ( LinkageTypes  Linkage) [inline, static]

Definition at line 147 of file GlobalValue.h.

References WeakAnyLinkage, and WeakODRLinkage.

Referenced by hasWeakLinkage(), and llvm::GlobalAlias::isValidLinkage().

bool GlobalValue::Materialize ( std::string *  ErrInfo = nullptr)

Materialize - make sure this GlobalValue is fully read. If the module is corrupt, this returns true and fills in the optional string with information about the problem. If successful, this returns false.

Definition at line 36 of file Globals.cpp.

References getParent(), and llvm::Module::Materialize().

Referenced by llvm::JIT::getPointerToFunction(), llvm::BitcodeReader::materializeForwardReferencedFunctions(), and llvm::legacy::FunctionPassManager::run().

static bool llvm::GlobalValue::mayBeOverridden ( LinkageTypes  Linkage) [inline, static]

mayBeOverridden - Whether the definition of this global may be replaced by something non-equivalent at link time. For example, if a function has weak linkage then the code defining it may be replaced by different code.

Definition at line 178 of file GlobalValue.h.

References CommonLinkage, ExternalWeakLinkage, LinkOnceAnyLinkage, and WeakAnyLinkage.

Referenced by llvm::InlineCostAnalysis::getInlineCost(), and llvm::ObjectSizeOffsetVisitor::visitGlobalAlias().

Definition at line 218 of file GlobalValue.h.

References Linkage, and mayBeOverridden().

Referenced by llvm::GlobalVariable::hasDefinitiveInitializer(), and mayBeOverridden().

virtual void llvm::GlobalValue::removeFromParent ( ) [pure virtual]

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

Implemented in llvm::Function, llvm::GlobalVariable, and llvm::GlobalAlias.

Definition at line 63 of file Globals.cpp.

References Alignment, getAlignment(), and llvm::Log2_32().

Referenced by copyAttributesFrom(), copyGVAttributes(), and SRAGlobal().

Definition at line 109 of file GlobalValue.h.

References llvm::CallingConv::C, and DllStorageClass.

Referenced by copyAttributesFrom(), and UpgradeDLLImportExportLinkage().

Definition at line 211 of file GlobalValue.h.

References Linkage, and llvm::A64CC::LT.

Referenced by llvm::Function::deleteBody(), LLVMSetLinkage(), and makeVisible().

void llvm::GlobalValue::setUnnamedAddr ( bool  Val) [inline]

Definition at line 98 of file GlobalValue.h.

References Visibility.

Referenced by copyAttributesFrom(), and makeVisible().

Determine if the usage of this global value is empty except for transitively dead constants.

If the usage is empty (except transitively dead constants), then this global value can be safely deleted since the destructor will delete the dead constants as well.


Member Data Documentation

Definition at line 74 of file GlobalValue.h.

Referenced by getAlignment(), and setAlignment().

Definition at line 77 of file GlobalValue.h.

Referenced by getParent().

std::string llvm::GlobalValue::Section [protected]

Definition at line 78 of file GlobalValue.h.

Referenced by getSection(), hasSection(), and setSection().

Definition at line 75 of file GlobalValue.h.

Referenced by hasUnnamedAddr(), and setUnnamedAddr().


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