LLVM  mainline
Classes | Public Member Functions | Static Public Member Functions | Friends
llvm::Module Class Reference

A Module instance is used to store all the information related to an LLVM module. More...

#include <Module.h>

List of all members.

Classes

struct  ModuleFlagEntry

Public Member Functions

 Module (StringRef ModuleID, LLVMContext &C)
 The Module constructor.
 ~Module ()
 The module destructor. This will dropAllReferences.
const std::string & getModuleIdentifier () const
 Get the module identifier which is, essentially, the name of the module.
StringRef getName () const
 Get a short "name" for the module.
const std::string & getDataLayoutStr () const
 Get the data layout string for the module's target platform.
const DataLayoutgetDataLayout () const
 Get the data layout for the module's target platform.
const std::string & getTargetTriple () const
 Get the target triple which is a string describing the target host.
LLVMContextgetContext () const
 Get the global data context.
const std::string & getModuleInlineAsm () const
 Get any module-scope inline assembly blocks.
RandomNumberGeneratorcreateRNG (const Pass *P) const
 Get a RandomNumberGenerator salted for use with this module.
void setModuleIdentifier (StringRef ID)
 Set the module identifier.
void setDataLayout (StringRef Desc)
 Set the data layout.
void setDataLayout (const DataLayout &Other)
void setTargetTriple (StringRef T)
 Set the target triple.
void setModuleInlineAsm (StringRef Asm)
 Set the module-scope inline assembly blocks.
void appendModuleInlineAsm (StringRef Asm)
 Append to the module-scope inline assembly blocks.
GlobalValuegetNamedValue (StringRef Name) const
 Return the global value in the module with the specified name, of arbitrary type.
unsigned getMDKindID (StringRef Name) const
 Return a unique non-zero ID for the specified metadata kind.
void getMDKindNames (SmallVectorImpl< StringRef > &Result) const
 Populate client supplied SmallVector with the name for custom metadata IDs registered in this LLVMContext.
void getOperandBundleTags (SmallVectorImpl< StringRef > &Result) const
 Populate client supplied SmallVector with the bundle tags registered in this LLVMContext.
StructTypegetTypeByName (StringRef Name) const
 Return the type with the specified name, or null if there is none by that name.
std::vector< StructType * > getIdentifiedStructTypes () const
ConstantgetOrInsertFunction (StringRef Name, FunctionType *T, AttributeSet AttributeList)
 Look up the specified function in the module symbol table.
ConstantgetOrInsertFunction (StringRef Name, FunctionType *T)
ConstantgetOrInsertFunction (StringRef Name, AttributeSet AttributeList, Type *RetTy,...) LLVM_END_WITH_NULL
 Look up the specified function in the module symbol table.
ConstantgetOrInsertFunction (StringRef Name, Type *RetTy,...) LLVM_END_WITH_NULL
 Same as above, but without the attributes.
FunctiongetFunction (StringRef Name) const
 Look up the specified function in the module symbol table.
GlobalVariablegetGlobalVariable (StringRef Name) const
 Look up the specified global variable in the module symbol table.
GlobalVariablegetGlobalVariable (StringRef Name, bool AllowInternal) const
GlobalVariablegetGlobalVariable (StringRef Name, bool AllowInternal=false)
 getGlobalVariable - Look up the specified global variable in the module symbol table.
GlobalVariablegetNamedGlobal (StringRef Name)
 Return the global variable in the module with the specified name, of arbitrary type.
const GlobalVariablegetNamedGlobal (StringRef Name) const
ConstantgetOrInsertGlobal (StringRef Name, Type *Ty)
 Look up the specified global in the module symbol table.
GlobalAliasgetNamedAlias (StringRef Name) const
 Return the global alias in the module with the specified name, of arbitrary type.
NamedMDNodegetNamedMetadata (const Twine &Name) const
 Return the first NamedMDNode in the module with the specified name.
NamedMDNodegetOrInsertNamedMetadata (StringRef Name)
 Return the named MDNode in the module with the specified name.
void eraseNamedMetadata (NamedMDNode *NMD)
 Remove the given NamedMDNode from this module and delete it.
ComdatgetOrInsertComdat (StringRef Name)
 Return the Comdat in the module with the specified name.
void getModuleFlagsMetadata (SmallVectorImpl< ModuleFlagEntry > &Flags) const
 Returns the module flags in the provided vector.
MetadatagetModuleFlag (StringRef Key) const
 Return the corresponding value if Key appears in module flags, otherwise return null.
NamedMDNodegetModuleFlagsMetadata () const
 Returns the NamedMDNode in the module that represents module-level flags.
NamedMDNodegetOrInsertModuleFlagsMetadata ()
 Returns the NamedMDNode in the module that represents module-level flags.
void addModuleFlag (ModFlagBehavior Behavior, StringRef Key, Metadata *Val)
 Add a module-level flag to the module-level flags metadata.
void addModuleFlag (ModFlagBehavior Behavior, StringRef Key, Constant *Val)
void addModuleFlag (ModFlagBehavior Behavior, StringRef Key, uint32_t Val)
void addModuleFlag (MDNode *Node)
void setMaterializer (GVMaterializer *GVM)
 Sets the GVMaterializer to GVM.
GVMaterializergetMaterializer () const
 Retrieves the GVMaterializer, if any, for this Module.
bool isMaterialized () const
std::error_code materialize (GlobalValue *GV)
 Make sure the GlobalValue is fully read.
std::error_code materializeAll ()
 Make sure all GlobalValues in this Module are fully read and clear the Materializer.
std::error_code materializeMetadata ()
const GlobalListTypegetGlobalList () const
 Get the Module's list of global variables (constant).
GlobalListTypegetGlobalList ()
 Get the Module's list of global variables.
const FunctionListTypegetFunctionList () const
 Get the Module's list of functions (constant).
FunctionListTypegetFunctionList ()
 Get the Module's list of functions.
const AliasListTypegetAliasList () const
 Get the Module's list of aliases (constant).
AliasListTypegetAliasList ()
 Get the Module's list of aliases.
const NamedMDListTypegetNamedMDList () const
 Get the Module's list of named metadata (constant).
NamedMDListTypegetNamedMDList ()
 Get the Module's list of named metadata.
const ValueSymbolTablegetValueSymbolTable () const
 Get the symbol table of global variable and function identifiers.
ValueSymbolTablegetValueSymbolTable ()
 Get the Module's symbol table of global variable and function identifiers.
const ComdatSymTabTypegetComdatSymbolTable () const
 Get the Module's symbol table for COMDATs (constant).
ComdatSymTabTypegetComdatSymbolTable ()
 Get the Module's symbol table for COMDATs.
global_iterator global_begin ()
const_global_iterator global_begin () const
global_iterator global_end ()
const_global_iterator global_end () const
bool global_empty () const
iterator_range< global_iteratorglobals ()
iterator_range
< const_global_iterator
globals () const
iterator begin ()
const_iterator begin () const
iterator end ()
const_iterator end () const
reverse_iterator rbegin ()
const_reverse_iterator rbegin () const
reverse_iterator rend ()
const_reverse_iterator rend () const
size_t size () const
bool empty () const
iterator_range< iteratorfunctions ()
iterator_range< const_iteratorfunctions () const
alias_iterator alias_begin ()
const_alias_iterator alias_begin () const
alias_iterator alias_end ()
const_alias_iterator alias_end () const
size_t alias_size () const
bool alias_empty () const
iterator_range< alias_iteratoraliases ()
iterator_range
< const_alias_iterator
aliases () const
named_metadata_iterator named_metadata_begin ()
const_named_metadata_iterator named_metadata_begin () const
named_metadata_iterator named_metadata_end ()
const_named_metadata_iterator named_metadata_end () const
size_t named_metadata_size () const
bool named_metadata_empty () const
iterator_range
< named_metadata_iterator
named_metadata ()
iterator_range
< const_named_metadata_iterator
named_metadata () const
void dropTriviallyDeadConstantArrays ()
 Destroy ConstantArrays in LLVMContext if they are not used.
void print (raw_ostream &OS, AssemblyAnnotationWriter *AAW, bool ShouldPreserveUseListOrder=false, bool IsForDebug=false) const
 Print the module to an output stream with an optional AssemblyAnnotationWriter.
void dump () const
 Dump the module to stderr (for debugging).
void dropAllReferences ()
 This function causes all the subinstructions to "let go" of all references that they are maintaining.
unsigned getDwarfVersion () const
 Returns the Dwarf Version by checking module flags.
unsigned getCodeViewFlag () const
 Returns the CodeView Version by checking module flags.
PICLevel::Level getPICLevel () const
 Returns the PIC level (small or large model)
void setPICLevel (PICLevel::Level PL)
 Set the PIC level (small or large model)
Utility functions for querying and setting PGO counts
void setMaximumFunctionCount (uint64_t)
 Set maximum function count in PGO mode.
Optional< uint64_t > getMaximumFunctionCount ()
 Returns maximum function count in PGO mode.

Static Public Member Functions

static GlobalListType Module::* getSublistAccess (GlobalVariable *)
static FunctionListType Module::* getSublistAccess (Function *)
static AliasListType Module::* getSublistAccess (GlobalAlias *)
static NamedMDListType Module::* getSublistAccess (NamedMDNode *)

Friends

class Constant

Types And Enumerations

enum  ModFlagBehavior {
  Error = 1, Warning = 2, Require = 3, Override = 4,
  Append = 5, AppendUnique = 6, ModFlagBehaviorFirstVal = Error, ModFlagBehaviorLastVal = AppendUnique
}
 This enumeration defines the supported behaviors of module flags. More...
typedef SymbolTableList
< GlobalVariable
GlobalListType
 The type for the list of global variables.
typedef SymbolTableList< FunctionFunctionListType
 The type for the list of functions.
typedef SymbolTableList
< GlobalAlias
AliasListType
 The type for the list of aliases.
typedef ilist< NamedMDNodeNamedMDListType
 The type for the list of named metadata.
typedef StringMap< ComdatComdatSymTabType
 The type of the comdat "symbol" table.
typedef GlobalListType::iterator global_iterator
 The Global Variable iterator.
typedef
GlobalListType::const_iterator 
const_global_iterator
 The Global Variable constant iterator.
typedef FunctionListType::iterator iterator
 The Function iterators.
typedef
FunctionListType::const_iterator 
const_iterator
 The Function constant iterator.
typedef
FunctionListType::reverse_iterator 
reverse_iterator
 The Function reverse iterator.
typedef
FunctionListType::const_reverse_iterator 
const_reverse_iterator
 The Function constant reverse iterator.
typedef AliasListType::iterator alias_iterator
 The Global Alias iterators.
typedef
AliasListType::const_iterator 
const_alias_iterator
 The Global Alias constant iterator.
typedef NamedMDListType::iterator named_metadata_iterator
 The named metadata iterators.
typedef
NamedMDListType::const_iterator 
const_named_metadata_iterator
 The named metadata constant iterators.
static bool isValidModFlagBehavior (Metadata *MD, ModFlagBehavior &MFB)
 Checks if Metadata represents a valid ModFlagBehavior, and stores the converted result in MFB.

Detailed Description

A Module instance is used to store all the information related to an LLVM module.

Modules are the top level container of all other LLVM Intermediate Representation (IR) objects. Each module directly contains a list of globals variables, a list of functions, a list of libraries (or other modules) this module depends on, a symbol table, and various data about the target's characteristics.

A module maintains a GlobalValRefMap object that is used to hold all constant references to global variables in the module. When a global variable is destroyed, it should have no entries in the GlobalValueRefMap. The main container class for the LLVM Intermediate Representation.

Definition at line 68 of file Module.h.


Member Typedef Documentation

The Global Alias iterators.

Definition at line 99 of file Module.h.

The type for the list of aliases.

Definition at line 77 of file Module.h.

The type of the comdat "symbol" table.

Definition at line 81 of file Module.h.

The Global Alias constant iterator.

Definition at line 101 of file Module.h.

The Global Variable constant iterator.

Definition at line 86 of file Module.h.

The Function constant iterator.

Definition at line 91 of file Module.h.

The named metadata constant iterators.

Definition at line 106 of file Module.h.

The Function constant reverse iterator.

Definition at line 96 of file Module.h.

The type for the list of functions.

Definition at line 75 of file Module.h.

The Global Variable iterator.

Definition at line 84 of file Module.h.

The type for the list of global variables.

Definition at line 73 of file Module.h.

The Function iterators.

Definition at line 89 of file Module.h.

The named metadata iterators.

Definition at line 104 of file Module.h.

The type for the list of named metadata.

Definition at line 79 of file Module.h.

The Function reverse iterator.

Definition at line 94 of file Module.h.


Member Enumeration Documentation

This enumeration defines the supported behaviors of module flags.

Enumerator:
Error 

Emits an error if two values disagree, otherwise the resulting value is that of the operands.

Warning 

Emits a warning if two values disagree.

The result value will be the operand for the flag from the first module being linked.

Require 

Adds a requirement that another module flag be present and have a specified value after linking is performed.

The value must be a metadata pair, where the first element of the pair is the ID of the module flag to be restricted, and the second element of the pair is the value the module flag should be restricted to. This behavior can be used to restrict the allowable results (via triggering of an error) of linking IDs with the **Override** behavior.

Override 

Uses the specified value, regardless of the behavior or value of the other module.

If both modules specify **Override**, but the values differ, an error will be emitted.

Append 

Appends the two values, which are required to be metadata nodes.

AppendUnique 

Appends the two values, which are required to be metadata nodes.

However, duplicate entries in the second list are dropped during the append operation.

ModFlagBehaviorFirstVal 
ModFlagBehaviorLastVal 

Definition at line 109 of file Module.h.


Constructor & Destructor Documentation

Module::Module ( StringRef  ModuleID,
LLVMContext C 
) [explicit]

The Module constructor.

Note that there is no default constructor. You must provide a name for the module upon construction.

Definition at line 49 of file Module.cpp.

The module destructor. This will dropAllReferences.

Definition at line 56 of file Module.cpp.

References llvm::iplist< NodeTy, Traits >::clear(), and dropAllReferences().


Member Function Documentation

void Module::addModuleFlag ( ModFlagBehavior  Behavior,
StringRef  Key,
Metadata Val 
)

Add a module-level flag to the module-level flags metadata.

addModuleFlag - Add a module-level flag to the module-level flags metadata.

It will create the module-level flags named metadata if it doesn't already exist.

Definition at line 343 of file Module.cpp.

References llvm::NamedMDNode::addOperand(), llvm::ConstantInt::get(), llvm::ConstantAsMetadata::get(), llvm::MDString::get(), llvm::MDNode::get(), llvm::Type::getInt32Ty(), getOrInsertModuleFlagsMetadata(), and llvm::Int32Ty.

Referenced by addModuleFlag(), setMaximumFunctionCount(), and setPICLevel().

void Module::addModuleFlag ( ModFlagBehavior  Behavior,
StringRef  Key,
Constant Val 
)

Definition at line 351 of file Module.cpp.

References addModuleFlag(), and llvm::ConstantAsMetadata::get().

void Module::addModuleFlag ( ModFlagBehavior  Behavior,
StringRef  Key,
uint32_t  Val 
)
void Module::addModuleFlag ( MDNode Node)

Definition at line 507 of file Module.h.

Referenced by llvm::CloneModule(), findPartitions(), llvm::TypeFinder::run(), and skipEmpty().

Definition at line 508 of file Module.h.

bool llvm::Module::alias_empty ( ) const [inline]

Definition at line 512 of file Module.h.

Definition at line 509 of file Module.h.

Referenced by llvm::CloneModule(), findPartitions(), llvm::TypeFinder::run(), and skipEmpty().

Definition at line 510 of file Module.h.

size_t llvm::Module::alias_size ( ) const [inline]

Definition at line 511 of file Module.h.

Referenced by llvm::NVPTXAsmPrinter::doInitialization().

Definition at line 514 of file Module.h.

Referenced by dropAllReferences(), orderModule(), and WritePerModuleFunctionSummary().

Definition at line 517 of file Module.h.

References llvm::iplist< NodeTy, Traits >::begin().

Append to the module-scope inline assembly blocks.

A trailing newline is added if the input doesn't have one.

Definition at line 253 of file Module.h.

const_iterator llvm::Module::begin ( ) const [inline]

Definition at line 488 of file Module.h.

Get a RandomNumberGenerator salted for use with this module.

The RNG can be seeded via -rng-seed=<uint64> and is salted with the ModuleID and the provided pass salt. The returned RNG should not be shared across threads or passes.

A unique RNG per pass ensures a reproducible random stream even when other randomness consuming passes are added or removed. In addition, the random stream will be reproducible across LLVM versions when the pass does not change.

Definition at line 67 of file Module.cpp.

References llvm::sys::path::filename(), getModuleIdentifier(), and llvm::Pass::getPassName().

This function causes all the subinstructions to "let go" of all references that they are maintaining.

This allows one to 'delete' a whole class at a time, even though there may be circular references... first all references are dropped, and all use counts go to zero. Then everything is delete'd for real. Note that no operations are valid on an object that has "dropped all references", except operator delete.

Definition at line 432 of file Module.cpp.

References aliases(), llvm::Function::dropAllReferences(), F, and globals().

Referenced by ~Module().

Destroy ConstantArrays in LLVMContext if they are not used.

ConstantArrays constructed during linking can cause quadratic memory explosion. Releasing all unused constants can cause a 20% LTO compile-time slowdown for a large application.

NOTE: Constants are currently owned by LLVMContext. This can then only be called where all uses of the LLVMContext are understood.

Definition at line 184 of file LLVMContextImpl.cpp.

References llvm::LLVMContextImpl::dropTriviallyDeadConstantArrays(), and llvm::LLVMContext::pImpl.

Referenced by llvm::IRMover::move().

Dump the module to stderr (for debugging).

Definition at line 3436 of file AsmWriter.cpp.

References llvm::dbgs(), and print().

bool llvm::Module::empty ( ) const [inline]

Definition at line 496 of file Module.h.

const_iterator llvm::Module::end ( ) const [inline]

Definition at line 490 of file Module.h.

Remove the given NamedMDNode from this module and delete it.

eraseNamedMetadata - Remove the given NamedMDNode from this module and delete it.

Definition at line 278 of file Module.cpp.

References llvm::iplist< NodeTy, Traits >::erase(), llvm::ilist_node< NodeTy >::getIterator(), and llvm::NamedMDNode::getName().

Referenced by llvm::NamedMDNode::eraseFromParent().

Definition at line 501 of file Module.h.

References llvm::iplist< NodeTy, Traits >::begin().

Get the Module's list of aliases (constant).

Definition at line 448 of file Module.h.

Referenced by llvm::GlobalAlias::eraseFromParent(), and llvm::GlobalAlias::removeFromParent().

Get the Module's list of aliases.

Definition at line 450 of file Module.h.

Returns the CodeView Version by checking module flags.

Returns zero if not present in module.

Definition at line 450 of file Module.cpp.

References getModuleFlag().

Referenced by llvm::AsmPrinter::doInitialization().

Get the Module's symbol table for COMDATs (constant).

Definition at line 466 of file Module.h.

Referenced by rewriteComdat().

Get the Module's symbol table for COMDATs.

Definition at line 468 of file Module.h.

Get the global data context.

Returns:
LLVMContext - a container for LLVM's global information

Definition at line 213 of file Module.h.

Referenced by llvm::LTOCodeGenerator::addModule(), llvm::IntrinsicLowering::AddPrototypes(), appendToGlobalArray(), assureFPCallStub(), llvm::CloneModule(), createFPFnStub(), createFree(), CreateGCRelocates(), llvm::createPGOFuncNameVar(), createPrivateGlobalForSourceLoc(), createPrivateGlobalForString(), createPrivateNonConstGlobalForString(), llvm::createSanitizerCtorAndInitFunctions(), llvm::emitFPutC(), llvm::emitFPutS(), llvm::emitFWrite(), EmitGCCInlineAsmStr(), llvm::AArch64TargetLowering::emitLoadLinked(), llvm::ARMTargetLowering::emitLoadLinked(), llvm::emitMemChr(), llvm::emitMemCmp(), llvm::emitMemCpyChk(), EmitMSInlineAsmStr(), llvm::emitPutS(), llvm::HexagonTargetLowering::emitStoreConditional(), llvm::AArch64TargetLowering::emitStoreConditional(), llvm::ARMTargetLowering::emitStoreConditional(), llvm::emitStrChr(), llvm::emitStrCpy(), llvm::emitStrLen(), llvm::emitStrNCmp(), llvm::emitStrNCpy(), EnsureFPIntrinsicsExist(), llvm::SanitizerStatReport::finish(), fixupFPReturnAndCall(), llvm::objcarc::ARCMDKindCache::get(), llvm::Intrinsic::getDeclaration(), getOrInsertValueProfilingCall(), llvm::TargetLoweringBase::getSafeStackPointerLocation(), getTypeByName(), InsertSafepointPoll(), insertUseHolderAfter(), LLVMLinkModules(), llvm::legacy::PassManagerImpl::run(), llvm::SanitizerStatReport::SanitizerStatReport(), SwitchToLookupTable(), and llvm::UpgradeDebugInfo().

Get the data layout for the module's target platform.

Definition at line 375 of file Module.cpp.

Referenced by llvm::AliasSetTracker::add(), AddAlignmentAssumptions(), llvm::OrcCBindingsStack::addIRModule(), llvm::IVUsers::AddUsersImpl(), AllCallersPassInValidPointerForArgument(), AnalyzeLoadFromClobberingStore(), llvm::GlobalsAAResult::analyzeModule(), llvm::AAResults::callCapturesBefore(), llvm::objcarc::CanAlterRefCount(), canSinkOrHoistInst(), llvm::objcarc::CanUse(), checkStringCopyLibFuncSignature(), llvm::CloneModule(), combineInstructionsOverFunction(), ComputeLegalValueVTs(), llvm::ConvertDebugDeclareToDebugValue(), llvm::SanitizerStatReport::create(), llvm::createLegacyPMBasicAAResult(), llvm::objcarc::ObjCARCAAWrapperPass::doInitialization(), llvm::AsmPrinter::EmitAlignment(), EmitCamlGlobal(), llvm::AsmPrinter::EmitGlobalVariable(), llvm::TargetLoweringObjectFileCOFF::emitLinkerFlagsForGlobal(), llvm::AsmPrinter::EmitSpecialLLVMGlobal(), llvm::LazyValueInfo::eraseBlock(), llvm::FindAvailableLoadedValue(), FindLoopCounter(), findPHIToPartitionLoops(), llvm::MCJIT::generateCodeForModule(), llvm::MemoryLocation::get(), llvm::LazyValueInfo::getConstant(), llvm::LazyValueInfo::getConstantOnEdge(), llvm::AsmPrinter::getDataLayout(), llvm::MachineFunction::getDataLayout(), llvm::ScalarEvolution::getDataLayout(), llvm::DemandedBits::getDemandedBits(), llvm::getGEPInductionOperand(), llvm::TargetLoweringObjectFileMachO::getIndirectSymViaGOTPCRel(), llvm::LoopAccessAnalysis::getInfo(), llvm::TargetLoweringObjectFile::getKindForGlobal(), llvm::MemoryDependenceAnalysis::getLoadLoadClobberFullWidthSize(), GetLoadValueForLoad(), llvm::ExecutionEngine::getMangledName(), llvm::Mangler::getNameWithPrefix(), llvm::LazyValueInfo::getPredicateAt(), llvm::LazyValueInfo::getPredicateOnEdge(), llvm::NVPTXTargetLowering::getPrototype(), llvm::TargetLoweringObjectFile::getSectionForJumpTable(), llvm::MemoryDependenceAnalysis::getSimplePointerDependencyFrom(), llvm::TargetLoweringObjectFile::getSymbolWithGlobalValueBase(), llvm::MipsTargetMachine::getTargetIRAnalysis(), llvm::AMDGPUTargetMachine::getTargetIRAnalysis(), llvm::TargetMachine::getTargetIRAnalysis(), llvm::AArch64TargetLowering::getTgtMemIntrinsic(), llvm::ARMTargetLowering::getTgtMemIntrinsic(), llvm::NVPTXTargetLowering::getTgtMemIntrinsic(), llvm::SSAUpdater::GetValueInMiddleOfBlock(), HandleByValArgument(), HandleByValArgumentInit(), llvm::hoistRegion(), llvm::DataLayout::init(), llvm::MIRParserImpl::initializeConstantPool(), InlineCallIfPossible(), llvm::InlineFunction(), llvm::HexagonTargetObjectFile::IsGlobalInSmallSection(), llvm::MipsTargetObjectFile::IsGlobalInSmallSectionImpl(), llvm::InductionDescriptor::isInductionPHI(), isLoadLoadClobberIfExtendedToFullWidth(), llvm::AArch64TargetLowering::isProfitableToHoist(), llvm::isSafeToLoadUnconditionally(), llvm::isSafeToSpeculativelyExecute(), IsSmallObject(), llvm::isStridedPtr(), llvm::AArch64TargetLowering::lowerInterleavedLoad(), llvm::ARMTargetLowering::lowerInterleavedLoad(), llvm::AArch64TargetLowering::lowerInterleavedStore(), llvm::ARMTargetLowering::lowerInterleavedStore(), llvm::AliasSetTracker::remove(), replaceAndRecursivelySimplifyImpl(), llvm::returnTypeIsEligibleForTailCall(), rotateLoop(), llvm::objcarc::ObjCARCAA::run(), llvm::BasicAA::run(), llvm::LazyValueInfo::runOnFunction(), llvm::BasicAAWrapperPass::runOnFunction(), selectELFSectionForGlobal(), llvm::XCoreTargetObjectFile::SelectSectionForGlobal(), llvm::TargetLoweringObjectFileMachO::SelectSectionForGlobal(), llvm::FunctionLoweringInfo::set(), llvm::SimplifyCFG(), llvm::SimplifyInstructionsInBlock(), simplifyOneLoop(), llvm::LazyValueInfo::threadEdge(), llvm::UnrollLoop(), llvm::UnrollRuntimeLoopProlog(), llvm::LoopVersioning::versionLoop(), and visitIVCast().

const std::string& llvm::Module::getDataLayoutStr ( ) const [inline]

Get the data layout string for the module's target platform.

This is equivalent to getDataLayout()->getStringRepresentation().

Definition at line 200 of file Module.h.

Referenced by WriteModuleInfo().

Returns the Dwarf Version by checking module flags.

Definition at line 443 of file Module.cpp.

References getModuleFlag().

Referenced by llvm::AsmPrinter::doInitialization(), and llvm::DwarfDebug::DwarfDebug().

Get the Module's list of functions (constant).

Definition at line 441 of file Module.h.

Referenced by llvm::Function::eraseFromParent(), llvm::Function::removeFromParent(), and llvm::CallGraph::removeFunctionFromModule().

Get the Module's list of functions.

Definition at line 443 of file Module.h.

Get the Module's list of global variables.

Definition at line 436 of file Module.h.

Look up the specified global variable in the module symbol table.

If it does not exist, return null. If AllowInternal is set to true, this function will return types that have InternalLinkage. By default, these types are not returned.

Definition at line 326 of file Module.h.

Referenced by llvm::collectUsedGlobalVariables(), llvm::MCJIT::findModuleForSymbol(), getNamedGlobal(), and StripSymbolNames().

GlobalVariable* llvm::Module::getGlobalVariable ( StringRef  Name,
bool  AllowInternal 
) const [inline]

Definition at line 330 of file Module.h.

getGlobalVariable - Look up the specified global variable in the module symbol table.

If it does not exist, return null. The type argument should be the underlying type of the global, i.e., it should not have the top-level PointerType, which represents the address of the global. If AllowLocal is set to true, this function will return types that have an local. By default, these types are not returned.

Definition at line 206 of file Module.cpp.

References getNamedValue().

std::vector< StructType * > Module::getIdentifiedStructTypes ( ) const

Retrieves the GVMaterializer, if any, for this Module.

Definition at line 417 of file Module.h.

Referenced by llvm::canBeOmittedFromSymbolTable().

Returns maximum function count in PGO mode.

Definition at line 481 of file Module.cpp.

References getModuleFlag(), and llvm::None.

Return a unique non-zero ID for the specified metadata kind.

getMDKindID - Return a unique non-zero ID for the specified metadata kind.

This ID is uniqued across modules in the current LLVMContext.

Definition at line 94 of file Module.cpp.

References llvm::LLVMContext::getMDKindID().

Referenced by llvm::UpgradeIntrinsicCall().

void Module::getMDKindNames ( SmallVectorImpl< StringRef > &  Result) const

Populate client supplied SmallVector with the name for custom metadata IDs registered in this LLVMContext.

getMDKindNames - Populate client supplied SmallVector with the name for custom metadata IDs registered in this LLVMContext.

ID #0 is not used, so it is filled in as an empty string.

Definition at line 101 of file Module.cpp.

References llvm::LLVMContext::getMDKindNames().

Referenced by WriteModuleMetadataStore().

Return the corresponding value if Key appears in module flags, otherwise return null.

Definition at line 316 of file Module.cpp.

References getModuleFlagsMetadata().

Referenced by getCodeViewFlag(), llvm::getDebugMetadataVersionFromModule(), getDwarfVersion(), getMaximumFunctionCount(), and getPICLevel().

Returns the module flags in the provided vector.

getModuleFlagsMetadata - Returns the module flags in the provided vector.

Definition at line 296 of file Module.cpp.

References getModuleFlagsMetadata(), isValidModFlagBehavior(), llvm::NamedMDNode::operands(), and llvm::SmallVectorTemplateBase< T, isPodLike< T >::value >::push_back().

Returns the NamedMDNode in the module that represents module-level flags.

getModuleFlagsMetadata - Returns the NamedMDNode in the module that represents module-level flags.

This method returns null if there are no module-level flags.

Definition at line 329 of file Module.cpp.

References getNamedMetadata().

Referenced by getModuleFlag(), and getModuleFlagsMetadata().

const std::string& llvm::Module::getModuleIdentifier ( ) const [inline]
const std::string& llvm::Module::getModuleInlineAsm ( ) const [inline]

Get any module-scope inline assembly blocks.

Returns:
a string containing the module-scope inline assembly blocks.

Definition at line 217 of file Module.h.

Referenced by llvm::CloneModule(), llvm::AsmPrinter::doInitialization(), llvm::NVPTXAsmPrinter::doInitialization(), llvm::ARMAsmPrinter::EmitStartOfAsmFile(), and WriteModuleInfo().

StringRef llvm::Module::getName ( ) const [inline]

Get a short "name" for the module.

This is useful for debugging or logging. It is essentially a convenience wrapper around getModuleIdentifier().

Definition at line 196 of file Module.h.

Referenced by llvm::getPGOFuncName().

Return the global alias in the module with the specified name, of arbitrary type.

This method returns null if a global with the specified name is not found.

Definition at line 249 of file Module.cpp.

References getNamedValue().

Return the global variable in the module with the specified name, of arbitrary type.

This method returns null if a global with the specified name is not found.

Definition at line 339 of file Module.h.

References getGlobalVariable().

Referenced by appendToGlobalArray(), llvm::orc::getConstructors(), llvm::orc::getDestructors(), llvm::TargetLowering::LowerToTLSEmulatedModel(), and llvm::ExecutionEngine::runStaticConstructorsDestructors().

Definition at line 342 of file Module.h.

Get the Module's list of named metadata (constant).

Definition at line 455 of file Module.h.

Get the Module's list of named metadata.

Definition at line 457 of file Module.h.

Return the first NamedMDNode in the module with the specified name.

getNamedMetadata - Return the first NamedMDNode in the module with the specified name.

This method returns null if a NamedMDNode with the specified name is not found.

Definition at line 256 of file Module.cpp.

References lookup(), and llvm::Twine::toStringRef().

Referenced by llvm::DwarfDebug::beginModule(), cacheAnnotationFromMD(), llvm::CodeViewDebug::CodeViewDebug(), getModuleFlagsMetadata(), and llvm::DebugInfoFinder::processModule().

Return the global value in the module with the specified name, of arbitrary type.

getNamedValue - Return the first global value in the module with the specified name, of arbitrary type.

This method returns null if a global with the specified name is not found.

Definition at line 88 of file Module.cpp.

References getValueSymbolTable(), and llvm::ValueSymbolTable::lookup().

Referenced by findExternalCalls(), forceRenaming(), getComdatGVForCOFF(), getFunction(), getGlobalVariable(), getNamedAlias(), getOrInsertFunction(), getOrInsertGlobal(), and llvm::objcarc::ModuleHasARC().

Populate client supplied SmallVector with the bundle tags registered in this LLVMContext.

The bundle tags are ordered by increasing bundle IDs.

See also:
LLVMContext::getOperandBundleTagID

Definition at line 105 of file Module.cpp.

References llvm::LLVMContext::getOperandBundleTags().

Referenced by WriteOperandBundleTags().

Return the Comdat in the module with the specified name.

It is created if it didn't already exist.

Definition at line 457 of file Module.cpp.

References llvm::StringMap< ValueTy, AllocatorTy >::insert().

Referenced by getOrCreateProfileComdat(), and rewriteComdat().

Look up the specified function in the module symbol table.

Four possibilities: 1. If it does not exist, add a prototype for the function and return it. 2. If it exists, and has a local linkage, the existing function is renamed and a new one is inserted. 3. Otherwise, if the existing function has the correct prototype, return the existing function. 4. Finally, the function exists but has the wrong prototype: return the function with a constantexpr cast to the right prototype.

Definition at line 118 of file Module.cpp.

References llvm::Function::Create(), llvm::GlobalValue::ExternalLinkage, F, llvm::ConstantExpr::getBitCast(), getNamedValue(), llvm::GlobalValue::getType(), llvm::PointerType::getUnqual(), llvm::Function::isIntrinsic(), llvm::iplist< NodeTy, Traits >::push_back(), and llvm::Function::setAttributes().

Referenced by llvm::SanitizerStatReport::create(), createFree(), createMalloc(), llvm::createSanitizerCtorAndInitFunctions(), llvm::emitBinaryFloatFnCall(), llvm::emitFPutC(), llvm::emitFPutS(), llvm::emitFWrite(), llvm::emitMemChr(), llvm::emitMemCmp(), llvm::emitMemCpyChk(), llvm::emitPutChar(), llvm::emitPutS(), llvm::emitStrChr(), llvm::emitStrCpy(), llvm::emitStrLen(), llvm::emitStrNCmp(), llvm::emitStrNCpy(), llvm::emitUnaryFloatFnCall(), EnsureFunctionExists(), llvm::SanitizerStatReport::finish(), fixupFPReturnAndCall(), llvm::Intrinsic::getDeclaration(), getOrInsertFunction(), getOrInsertValueProfilingCall(), llvm::TargetLoweringBase::getSafeStackPointerLocation(), insertSinCosCall(), insertUseHolderAfter(), and ReplaceCallWith().

Definition at line 141 of file Module.cpp.

References getOrInsertFunction().

Constant * Module::getOrInsertFunction ( StringRef  Name,
AttributeSet  AttributeList,
Type RetTy,
  ... 
)

Look up the specified function in the module symbol table.

If it does not exist, add a prototype for the function and return it. This function guarantees to return a constant of pointer to the specified function type or a ConstantExpr BitCast of that type if the named function has a different type. This version of the method takes a null terminated list of function arguments, which makes it easier for clients to use.

Definition at line 151 of file Module.cpp.

References llvm::FunctionType::get(), and getOrInsertFunction().

Constant * Module::getOrInsertFunction ( StringRef  Name,
Type RetTy,
  ... 
)

Same as above, but without the attributes.

Definition at line 170 of file Module.cpp.

References llvm::FunctionType::get(), and getOrInsertFunction().

Look up the specified global in the module symbol table.

getOrInsertGlobal - Look up the specified global in the module symbol table.

1. If it does not exist, add a declaration of the global and return it. 2. Else, the global exists but has the wrong type: return the function with a constantexpr cast to the right type. 3. Finally, if the existing global is the correct declaration, return the existing global.

Definition at line 220 of file Module.cpp.

References llvm::GlobalValue::ExternalLinkage, llvm::PointerType::get(), llvm::ConstantExpr::getBitCast(), getNamedValue(), llvm::Type::getPointerAddressSpace(), and llvm::GlobalValue::getType().

Referenced by CreatePrologue().

Returns the NamedMDNode in the module that represents module-level flags.

getOrInsertModuleFlagsMetadata - Returns the NamedMDNode in the module that represents module-level flags.

If module-level flags aren't found, it creates the named metadata that contains them.

Definition at line 336 of file Module.cpp.

References getOrInsertNamedMetadata().

Referenced by addModuleFlag().

Return the named MDNode in the module with the specified name.

getOrInsertNamedMetadata - Return the first named MDNode in the module with the specified name.

This method returns a new NamedMDNode if a NamedMDNode with the specified name is not found.

Definition at line 265 of file Module.cpp.

References Name, and llvm::ilist< NodeTy >::push_back().

Referenced by llvm::DIBuilder::createCompileUnit(), and getOrInsertModuleFlagsMetadata().

Returns the PIC level (small or large model)

Definition at line 463 of file Module.cpp.

References llvm::Default, and getModuleFlag().

static GlobalListType Module::* llvm::Module::getSublistAccess ( GlobalVariable ) [inline, static]

Definition at line 437 of file Module.h.

static FunctionListType Module::* llvm::Module::getSublistAccess ( Function ) [inline, static]

Definition at line 444 of file Module.h.

static AliasListType Module::* llvm::Module::getSublistAccess ( GlobalAlias ) [inline, static]

Definition at line 451 of file Module.h.

static NamedMDListType Module::* llvm::Module::getSublistAccess ( NamedMDNode ) [inline, static]

Definition at line 458 of file Module.h.

const std::string& llvm::Module::getTargetTriple ( ) const [inline]

Get the target triple which is a string describing the target host.

Returns:
a string containing the target triple.

Definition at line 209 of file Module.h.

Referenced by llvm::GlobalValue::canIncreaseAlignment(), llvm::CloneModule(), codegen(), getOrCreateProfileComdat(), llvm::LTOModule::getTargetTriple(), insertSinCosCall(), llvm::TargetLibraryAnalysis::run(), llvm::WriteBitcodeToFile(), and WriteModuleInfo().

Return the type with the specified name, or null if there is none by that name.

getTypeByName - Return the type with the specified name, or null if there is none by that name.

Definition at line 568 of file Type.cpp.

References getContext(), llvm::StringMap< ValueTy, AllocatorTy >::lookup(), llvm::LLVMContextImpl::NamedStructTypes, and llvm::LLVMContext::pImpl.

Get the symbol table of global variable and function identifiers.

Definition at line 462 of file Module.h.

Referenced by getNamedValue(), WriteModule(), and WritePerModuleFunctionSummary().

Get the Module's symbol table of global variable and function identifiers.

Definition at line 464 of file Module.h.

Definition at line 473 of file Module.h.

bool llvm::Module::global_empty ( ) const [inline]

Definition at line 476 of file Module.h.

Definition at line 475 of file Module.h.

Definition at line 481 of file Module.h.

bool llvm::Module::isMaterialized ( ) const [inline]

Definition at line 418 of file Module.h.

Referenced by llvm::Value::assertModuleIsMaterialized().

Checks if Metadata represents a valid ModFlagBehavior, and stores the converted result in MFB.

Definition at line 283 of file Module.cpp.

References ModFlagBehaviorFirstVal, and ModFlagBehaviorLastVal.

Referenced by getModuleFlagsMetadata().

std::error_code Module::materialize ( GlobalValue GV)

Make sure the 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 387 of file Module.cpp.

Referenced by llvm::GlobalValue::materialize().

std::error_code Module::materializeAll ( )

Make sure all GlobalValues in this Module are fully read and clear the Materializer.

Definition at line 394 of file Module.cpp.

std::error_code Module::materializeMetadata ( )

Definition at line 401 of file Module.cpp.

Definition at line 536 of file Module.h.

Referenced by WriteModuleMetadata().

Definition at line 539 of file Module.h.

References llvm::iplist< NodeTy, Traits >::begin().

Definition at line 524 of file Module.h.

References llvm::iplist< NodeTy, Traits >::rend().

Definition at line 534 of file Module.h.

Referenced by WriteModuleMetadata().

Definition at line 528 of file Module.h.

Referenced by llvm::CloneModule(), llvm::TypeFinder::run(), and llvm::StripDebugInfo().

Definition at line 529 of file Module.h.

size_t llvm::Module::named_metadata_size ( ) const [inline]

Definition at line 533 of file Module.h.

void Module::print ( raw_ostream OS,
AssemblyAnnotationWriter AAW,
bool  ShouldPreserveUseListOrder = false,
bool  IsForDebug = false 
) const

Print the module to an output stream with an optional AssemblyAnnotationWriter.

If ShouldPreserveUseListOrder, then include uselistorder directives so that use-lists can be recreated when reading the assembly.

Definition at line 3218 of file AsmWriter.cpp.

Referenced by dump(), llvm::operator<<(), llvm::yaml::BlockScalarTraits< Module >::output(), and llvm::PrintModulePass::run().

Definition at line 491 of file Module.h.

Referenced by predictUseListOrder().

Definition at line 492 of file Module.h.

Definition at line 493 of file Module.h.

Referenced by predictUseListOrder().

Definition at line 494 of file Module.h.

Definition at line 373 of file Module.cpp.

References Other.

Sets the GVMaterializer to GVM.

This module must not yet have a Materializer. To reset the materializer for a module that already has one, call materializeAll first. Destroying this module will destroy its materializer without materializing any more GlobalValues. Without destroying the Module, there is no way to detach or destroy a materializer without materializing all the GVs it controls, to avoid leaving orphan unmaterialized GVs.

Definition at line 380 of file Module.cpp.

Referenced by getBitcodeModuleImpl().

void Module::setMaximumFunctionCount ( uint64_t  Count)

Set maximum function count in PGO mode.

Definition at line 477 of file Module.cpp.

References addModuleFlag(), and llvm::lltok::Error.

Set the module identifier.

Definition at line 233 of file Module.h.

Set the module-scope inline assembly blocks.

A trailing newline is added if the input doesn't have one.

Definition at line 244 of file Module.h.

Set the PIC level (small or large model)

Definition at line 473 of file Module.cpp.

References addModuleFlag(), and llvm::lltok::Error.

Set the target triple.

Definition at line 240 of file Module.h.

Referenced by llvm::LTOModule::setTargetTriple().

size_t llvm::Module::size ( ) const [inline]

Definition at line 495 of file Module.h.

Referenced by findPartitions().


Friends And Related Function Documentation

friend class Constant [friend]

Definition at line 176 of file Module.h.


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