14#ifndef LLVM_IR_MODULE_H
15#define LLVM_IR_MODULE_H
161 static bool isValidModFlagBehavior(
Metadata *MD, ModFlagBehavior &MFB);
178 GlobalListType GlobalList;
179 FunctionListType FunctionList;
180 AliasListType AliasList;
181 IFuncListType IFuncList;
182 NamedMDListType NamedMDList;
183 std::string GlobalScopeAsm;
184 std::unique_ptr<ValueSymbolTable> ValSymTab;
185 ComdatSymTabType ComdatSymTab;
186 std::unique_ptr<MemoryBuffer>
189 std::unique_ptr<GVMaterializer>
191 std::string ModuleID;
192 std::string SourceFileName;
198 NamedMDSymTabType NamedMDSymTab;
204 UniquedIntrinsicNames;
225 for (
auto &
F : *
this) {
226 F.convertToNewDbgValues();
232 for (
auto &
F : *
this) {
233 F.convertFromNewDbgValues();
257 unsigned getInstructionCount()
const;
274 return DL.getStringRepresentation();
300 std::unique_ptr<RandomNumberGenerator> createRNG(
const StringRef Name)
const;
305 return getContext().getDiagHandlerPtr()->isAnalysisRemarkEnabled(
329 GlobalScopeAsm = std::string(Asm);
330 if (!GlobalScopeAsm.empty() && GlobalScopeAsm.back() !=
'\n')
331 GlobalScopeAsm +=
'\n';
337 GlobalScopeAsm += Asm;
338 if (!GlobalScopeAsm.empty() && GlobalScopeAsm.back() !=
'\n')
339 GlobalScopeAsm +=
'\n';
352 unsigned getNumNamedValues()
const;
356 unsigned getMDKindID(
StringRef Name)
const;
367 std::vector<StructType *> getIdentifiedStructTypes()
const;
389 AttributeList AttributeList);
395 template <
typename... ArgsTy>
397 AttributeList AttributeList,
Type *RetTy,
406 template <
typename... ArgsTy>
413 template <
typename... ArgsTy>
437 bool AllowInternal =
false) {
450 static_cast<const Module *
>(
this)->getNamedGlobal(Name));
574 GlobalList.insert(Where, GV);
585 const GlobalListType &getGlobalList()
const {
return GlobalList; }
587 GlobalListType &getGlobalList() {
return GlobalList; }
590 return &Module::GlobalList;
600 return &Module::FunctionList;
627 NamedMDList.push_back(
MDNode);
634 const AliasListType &getAliasList()
const {
return AliasList; }
636 AliasListType &getAliasList() {
return AliasList; }
639 return &Module::AliasList;
644 const IFuncListType &getIFuncList()
const {
return IFuncList; }
646 IFuncListType &getIFuncList() {
return IFuncList; }
649 return &Module::IFuncList;
654 const NamedMDListType &getNamedMDList()
const {
return NamedMDList; }
656 NamedMDListType &getNamedMDList() {
return NamedMDList; }
658 static NamedMDListType
Module::*getSublistAccess(NamedMDNode*) {
659 return &Module::NamedMDList;
703 size_t size()
const {
return FunctionList.size(); }
704 bool empty()
const {
return FunctionList.empty(); }
778 return NamedMDList.begin();
783 return NamedMDList.end();
811 : CUs(CUs), Idx(Idx) {
868 bool ShouldPreserveUseListOrder =
false,
869 bool IsForDebug =
false)
const;
880 void dropAllReferences();
888 unsigned getNumberRegisterParameters()
const;
891 unsigned getDwarfVersion()
const;
894 bool isDwarf64()
const;
898 unsigned getCodeViewFlag()
const;
938 std::optional<uint64_t> getLargeDataThreshold()
const;
941 void setLargeDataThreshold(
uint64_t Threshold);
952 Metadata *getProfileSummary(
bool IsCS)
const;
956 bool getSemanticInterposition()
const;
959 void setSemanticInterposition(
bool);
962 bool getRtLibUseGOT()
const;
965 void setRtLibUseGOT();
969 bool getDirectAccessExternalData()
const;
970 void setDirectAccessExternalData(
bool Value);
982 StringRef getStackProtectorGuard()
const;
983 void setStackProtectorGuard(
StringRef Kind);
988 StringRef getStackProtectorGuardReg()
const;
992 StringRef getStackProtectorGuardSymbol()
const;
993 void setStackProtectorGuardSymbol(
StringRef Symbol);
996 int getStackProtectorGuardOffset()
const;
997 void setStackProtectorGuardOffset(
int Offset);
1000 unsigned getOverrideStackAlignment()
const;
1001 void setOverrideStackAlignment(
unsigned Align);
1003 unsigned getMaxTLSAlignment()
const;
1018 void setOwnedMemoryBuffer(std::unique_ptr<MemoryBuffer> MB);
1028 StringRef getDarwinTargetVariantTriple()
const;
1032 void setDarwinTargetVariantTriple(
StringRef T);
1059 M.print(O,
nullptr);
1070 return reinterpret_cast<Module*
>(MP);
This file defines the StringMap class.
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
static void print(raw_ostream &Out, object::Archive::Kind Kind, T Val)
This file contains the simple types necessary to represent the attributes associated with functions a...
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
#define DEFINE_SIMPLE_CONVERSION_FUNCTIONS(ty, ref)
This file contains the declaration of the GlobalIFunc class, which represents a single indirect funct...
Machine Check Debug Module
static Constant * getOrInsertGlobal(Module &M, StringRef Name, Type *Ty)
static CodeModel::Model getCodeModel(const PPCSubtarget &S, const TargetMachine &TM, const MachineOperand &MO)
static Function * getFunction(FunctionType *Ty, const Twine &Name, Module *M)
static GlobalVariable * getGlobalVariable(Module &M, Type *Ty, WebAssemblyTargetMachine &TM, const char *Name)
This is an important base class in LLVM.
A parsed version of the target data layout string in and methods for querying it.
Lightweight error class with error context and mandatory checking.
A handy container for a FunctionType+Callee-pointer pair, which can be passed around as a single enti...
Class to represent function types.
static LLVM_ABI FunctionType * get(Type *Result, ArrayRef< Type * > Params, bool isVarArg)
This static method is the primary way of constructing a FunctionType.
This is an important class for using LLVM in a threaded context.
This interface provides simple read-only access to a block of memory, and provides simple methods for...
Class to hold module path string table and global value map, and encapsulate methods for operating on...
An iterator for DICompileUnits that skips those marked NoDebug.
debug_compile_units_iterator & operator++()
bool operator==(const debug_compile_units_iterator &I) const
debug_compile_units_iterator operator++(int)
std::input_iterator_tag iterator_category
std::ptrdiff_t difference_type
DICompileUnit * value_type
debug_compile_units_iterator(NamedMDNode *CUs, unsigned Idx)
bool operator!=(const debug_compile_units_iterator &I) const
A Module instance is used to store all the information related to an LLVM module.
const Triple & getTargetTriple() const
Get the target triple which is a string describing the target host.
StringMap< Comdat > ComdatSymTabType
The type of the comdat "symbol" table.
global_iterator global_begin()
void removeIFunc(GlobalIFunc *IFunc)
Detach IFunc from the list but don't delete it.
const_global_iterator global_begin() const
const_iterator begin() const
NamedMDNode * getNamedMetadata(StringRef Name) const
Return the first NamedMDNode in the module with the specified name.
ifunc_iterator ifunc_begin()
void eraseNamedMDNode(NamedMDNode *MDNode)
Remove MDNode from the list and delete it.
const std::string & getModuleInlineAsm() const
Get any module-scope inline assembly blocks.
ModFlagBehavior
This enumeration defines the supported behaviors of module flags.
@ AppendUnique
Appends the two values, which are required to be metadata nodes.
@ Override
Uses the specified value, regardless of the behavior or value of the other module.
@ Warning
Emits a warning if two values disagree.
@ Error
Emits an error if two values disagree, otherwise the resulting value is that of the operands.
@ ModFlagBehaviorFirstVal
@ Min
Takes the min of the two values, which are required to be integers.
@ Append
Appends the two values, which are required to be metadata nodes.
@ Max
Takes the max of the two values, which are required to be integers.
@ Require
Adds a requirement that another module flag be present and have a specified value after linking is pe...
LLVMContext & getContext() const
Get the global data context.
void insertIFunc(GlobalIFunc *IFunc)
Insert IFunc at the end of the alias list and take ownership.
iterator_range< const_alias_iterator > aliases() const
void setModuleInlineAsm(StringRef Asm)
Set the module-scope inline assembly blocks.
const ComdatSymTabType & getComdatSymbolTable() const
Get the Module's symbol table for COMDATs (constant).
global_iterator global_end()
GlobalVariable * getNamedGlobal(StringRef Name)
void setTargetTriple(Triple T)
Set the target triple.
NamedMDListType::iterator named_metadata_iterator
The named metadata iterators.
size_t alias_size() const
const_global_iterator global_end() const
bool global_empty() const
void convertToNewDbgValues()
FunctionCallee getOrInsertFunction(StringRef Name, AttributeList AttributeList, Type *RetTy, ArgsTy... Args)
Same as above, but takes a list of function arguments, which makes it easier for clients to use.
const_ifunc_iterator ifunc_end() const
void convertFromNewDbgValues()
iterator_range< ifunc_iterator > ifuncs()
bool named_metadata_empty() const
Module(StringRef ModuleID, LLVMContext &C)
The Module constructor.
ilist< NamedMDNode > NamedMDListType
The type for the list of named metadata.
SymbolTableList< Function > FunctionListType
The type for the list of functions.
void removeDebugIntrinsicDeclarations()
Used when printing this module in the new debug info format; removes all declarations of debug intrin...
ValueSymbolTable & getValueSymbolTable()
Get the Module's symbol table of global variable and function identifiers.
NamedMDListType::const_iterator const_named_metadata_iterator
The named metadata constant iterators.
const_named_metadata_iterator named_metadata_begin() const
size_t global_size() const
iterator_range< debug_compile_units_iterator > debug_compile_units() const
Return an iterator for all DICompileUnits listed in this Module's llvm.dbg.cu named metadata node and...
iterator_range< iterator > functions()
StringRef getName() const
Get a short "name" for the module.
GVMaterializer * getMaterializer() const
Retrieves the GVMaterializer, if any, for this Module.
const std::string & getSourceFileName() const
Get the module's original source file name.
IFuncListType::iterator ifunc_iterator
The Global IFunc iterators.
const_alias_iterator alias_end() const
void removeAlias(GlobalAlias *Alias)
Detach Alias from the list but don't delete it.
iterator_range< named_metadata_iterator > named_metadata()
named_metadata_iterator named_metadata_begin()
ifunc_iterator ifunc_end()
GlobalListType::const_iterator const_global_iterator
The Global Variable constant iterator.
iterator_range< alias_iterator > aliases()
void insertGlobalVariable(GlobalListType::iterator Where, GlobalVariable *GV)
Insert global variable GV into the global variable list before Where and take ownership.
alias_iterator alias_end()
const_alias_iterator alias_begin() const
const_reverse_iterator rbegin() const
alias_iterator alias_begin()
FunctionListType::iterator iterator
The Function iterators.
GlobalVariable * getGlobalVariable(StringRef Name, bool AllowInternal=false)
void eraseIFunc(GlobalIFunc *IFunc)
Remove IFunc from the list and delete it.
bool shouldEmitInstrCountChangedRemark()
Return true if size-info optimization remark is enabled, false otherwise.
StringMap< NamedMDNode * > NamedMDSymTabType
The type for mapping names to named metadata.
GlobalListType::iterator global_iterator
The Global Variable iterator.
FunctionListType::const_reverse_iterator const_reverse_iterator
The Function constant reverse iterator.
FunctionCallee getOrInsertFunction(StringRef Name, AttributeList AttributeList, FunctionType *Invalid, ArgsTy... Args)=delete
iterator_range< global_iterator > globals()
const FunctionListType & getFunctionList() const
Get the Module's list of functions (constant).
const_reverse_iterator rend() const
iterator_range< const_named_metadata_iterator > named_metadata() const
concat_iterator< GlobalObject, iterator, global_iterator > global_object_iterator
IFuncListType::const_iterator const_ifunc_iterator
The Global IFunc constant iterator.
size_t ifunc_size() const
SymbolTableList< GlobalVariable > GlobalListType
The type for the list of global variables.
FunctionListType & getFunctionList()
Get the Module's list of functions.
void eraseAlias(GlobalAlias *Alias)
Remove Alias from the list and delete it.
const std::string & getModuleIdentifier() const
Get the module identifier which is, essentially, the name of the module.
void eraseGlobalVariable(GlobalVariable *GV)
Remove global variable GV from the list and delete it.
reverse_iterator rbegin()
FunctionCallee getOrInsertFunction(StringRef Name, Type *RetTy, ArgsTy... Args)
Same as above, but without the attributes.
void insertNamedMDNode(NamedMDNode *MDNode)
Insert MDNode at the end of the alias list and take ownership.
const_named_metadata_iterator named_metadata_end() const
void removeNamedMDNode(NamedMDNode *MDNode)
Detach MDNode from the list but don't delete it.
AliasListType::iterator alias_iterator
The Global Alias iterators.
GlobalVariable * getGlobalVariable(StringRef Name) const
Look up the specified global variable in the module symbol table.
void insertGlobalVariable(GlobalVariable *GV)
Insert global variable GV at the end of the global variable list and take ownership.
const ValueSymbolTable & getValueSymbolTable() const
Get the symbol table of global variable and function identifiers.
size_t named_metadata_size() const
iterator_range< global_object_iterator > global_objects()
named_metadata_iterator named_metadata_end()
bool isMaterialized() const
const GlobalVariable * getNamedGlobal(StringRef Name) const
Return the global variable in the module with the specified name, of arbitrary type.
AliasListType::const_iterator const_alias_iterator
The Global Alias constant iterator.
FunctionCallee getOrInsertFunction(StringRef Name, FunctionType *T, AttributeList AttributeList)
Look up the specified function in the module symbol table.
ComdatSymTabType & getComdatSymbolTable()
Get the Module's symbol table for COMDATs.
FunctionListType::reverse_iterator reverse_iterator
The Function reverse iterator.
const DataLayout & getDataLayout() const
Get the data layout for the module's target platform.
iterator_range< const_iterator > functions() const
concat_iterator< GlobalValue, iterator, global_iterator, alias_iterator, ifunc_iterator > global_value_iterator
NamedMDNode * getModuleFlagsMetadata() const
Returns the NamedMDNode in the module that represents module-level flags.
iterator_range< const_global_iterator > globals() const
void setModuleIdentifier(StringRef ID)
Set the module identifier.
iterator_range< const_ifunc_iterator > ifuncs() const
SymbolTableList< GlobalAlias > AliasListType
The type for the list of aliases.
const_iterator end() const
void setSourceFileName(StringRef Name)
Set the module's original source file name.
SymbolTableList< GlobalIFunc > IFuncListType
The type for the list of ifuncs.
const_ifunc_iterator ifunc_begin() const
concat_iterator< const GlobalObject, const_iterator, const_global_iterator > const_global_object_iterator
const std::string & getDataLayoutStr() const
Get the data layout string for the module's target platform.
static FunctionListType Module::* getSublistAccess(Function *)
void appendModuleInlineAsm(StringRef Asm)
Append to the module-scope inline assembly blocks.
FunctionListType::const_iterator const_iterator
The Function constant iterator.
concat_iterator< const GlobalValue, const_iterator, const_global_iterator, const_alias_iterator, const_ifunc_iterator > const_global_value_iterator
void insertAlias(GlobalAlias *Alias)
Insert Alias at the end of the alias list and take ownership.
debug_compile_units_iterator debug_compile_units_begin() const
iterator_range< global_value_iterator > global_values()
void removeGlobalVariable(GlobalVariable *GV)
Detach global variable GV from the list but don't delete it.
debug_compile_units_iterator debug_compile_units_end() const
A random number generator.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
StringMap - This is an unconventional map that is specialized for handling keys that are "strings",...
StringRef - Represent a constant reference to a string, i.e.
Class to represent struct types.
List that automatically updates parent links and symbol tables.
Triple - Helper class for working with autoconf configuration names.
The instances of the Type class are immutable: once they are created, they are never changed.
This class provides a symbol table of name/value pairs.
LLVM Value Representation.
Represents a version number in the form major[.minor[.subminor[.build]]].
Iterator wrapper that concatenates sequences together.
An efficient, type-erasing, non-owning reference to a callable.
base_list_type::const_reverse_iterator const_reverse_iterator
base_list_type::reverse_iterator reverse_iterator
base_list_type::const_iterator const_iterator
base_list_type::iterator iterator
A range adaptor for a pair of iterators.
This class implements an extremely fast bulk output stream that can only output to a stream.
struct LLVMOpaqueModule * LLVMModuleRef
The top-level container for all other LLVM Intermediate Representation (IR) objects.
struct LLVMOpaqueModuleProvider * LLVMModuleProviderRef
Interface used to provide a module to JIT or interpreter.
This provides a very simple, boring adaptor for a begin and end iterator into a range type.
This file contains the declaration of the Comdat class, which represents a single COMDAT in LLVM.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
@ C
The default llvm calling convention, compatible with C.
This is an optimization pass for GlobalISel generic memory operations.
void dump(const SparseBitVector< ElementSize > &LHS, raw_ostream &out)
APInt operator*(APInt a, uint64_t RHS)
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
iplist< T, Options... > ilist
FunctionAddr VTableAddr uintptr_t uintptr_t Version
LLVM_ATTRIBUTE_VISIBILITY_DEFAULT AnalysisKey InnerAnalysisManagerProxy< AnalysisManagerT, IRUnitT, ExtraArgTs... >::Key
Attribute unwrap(LLVMAttributeRef Attr)
raw_ostream & operator<<(raw_ostream &OS, const APFixedPoint &FX)
LLVM_ABI GlobalVariable * collectUsedGlobalVariables(const Module &M, SmallVectorImpl< GlobalValue * > &Vec, bool CompilerUsed)
Given "llvm.used" or "llvm.compiler.used" as a global name, collect the initializer elements of that ...
This struct is a compact representation of a valid (non-zero power of two) alignment.
ModuleFlagEntry(ModFlagBehavior B, MDString *K, Metadata *V)