1//===- llvm/Module.h - C++ class to represent a VM module -------*- C++ -*-===// 3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4// See https://llvm.org/LICENSE.txt for license information. 5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 7//===----------------------------------------------------------------------===// 10/// Module.h This file contains the declarations for the Module class. 12//===----------------------------------------------------------------------===// 14#ifndef LLVM_IR_MODULE_H 15#define LLVM_IR_MODULE_H 49classModuleSummaryIndex;
50classRandomNumberGenerator;
54/// A Module instance is used to store all the information related to an 55/// LLVM module. Modules are the top level container of all other LLVM 56/// Intermediate Representation (IR) objects. Each module directly contains a 57/// list of globals variables, a list of functions, a list of libraries (or 58/// other modules) this module depends on, a symbol table, and various data 59/// about the target's characteristics. 61/// A module maintains a GlobalList object that is used to hold all 62/// constant references to global variables in the module. When a global 63/// variable is destroyed, it should have no entries in the GlobalList. 64/// The main container class for the LLVM Intermediate Representation. 66 /// @name Types And Enumerations 69 /// The type for the list of global variables. 71 /// The type for the list of functions. 73 /// The type for the list of aliases. 75 /// The type for the list of ifuncs. 77 /// The type for the list of named metadata. 79 /// The type of the comdat "symbol" table. 81 /// The type for mapping names to named metadata. 84 /// The Global Variable iterator. 86 /// The Global Variable constant iterator. 89 /// The Function iterators. 91 /// The Function constant iterator 94 /// The Function reverse iterator. 96 /// The Function constant reverse iterator. 99 /// The Global Alias iterators. 101 /// The Global Alias constant iterator 104 /// The Global IFunc iterators. 106 /// The Global IFunc constant iterator 109 /// The named metadata iterators. 111 /// The named metadata constant iterators. 114 /// This enumeration defines the supported behaviors of module flags. 116 /// Emits an error if two values disagree, otherwise the resulting value is 117 /// that of the operands. 120 /// Emits a warning if two values disagree. The result value will be the 121 /// operand for the flag from the first module being linked. 124 /// Adds a requirement that another module flag be present and have a 125 /// specified value after linking is performed. The value must be a metadata 126 /// pair, where the first element of the pair is the ID of the module flag 127 /// to be restricted, and the second element of the pair is the value the 128 /// module flag should be restricted to. This behavior can be used to 129 /// restrict the allowable results (via triggering of an error) of linking 130 /// IDs with the **Override** behavior. 133 /// Uses the specified value, regardless of the behavior or value of the 134 /// other module. If both modules specify **Override**, but the values 135 /// differ, an error will be emitted. 138 /// Appends the two values, which are required to be metadata nodes. 141 /// Appends the two values, which are required to be metadata 142 /// nodes. However, duplicate entries in the second list are dropped 143 /// during the append operation. 146 /// Takes the max of the two values, which are required to be integers. 149 /// Takes the min of the two values, which are required to be integers. 154 ModFlagBehaviorLastVal = Min
157 /// Checks if Metadata represents a valid ModFlagBehavior, and stores the 158 /// converted result in MFB. 159staticbool isValidModFlagBehavior(
Metadata *MD, ModFlagBehavior &MFB);
167 : Behavior(
B), Key(K), Val(V) {}
171/// @name Member Variables 174LLVMContext &Context;
///< The LLVMContext from which types and 175 ///< constants are allocated. 176 GlobalListType GlobalList;
///< The Global Variables in the module 177 FunctionListType FunctionList;
///< The Functions in the module 178 AliasListType AliasList;
///< The Aliases in the module 179 IFuncListType IFuncList;
///< The IFuncs in the module 180 NamedMDListType NamedMDList;
///< The named metadata in the module 181 std::string GlobalScopeAsm;
///< Inline Asm at global scope. 182 std::unique_ptr<ValueSymbolTable> ValSymTab;
///< Symbol table for values 183 ComdatSymTabType ComdatSymTab;
///< Symbol table for COMDATs 184 std::unique_ptr<MemoryBuffer>
185 OwnedMemoryBuffer;
///< Memory buffer directly owned by this 186 ///< module, for legacy clients only. 187 std::unique_ptr<GVMaterializer>
188 Materializer;
///< Used to materialize GlobalValues 189 std::string ModuleID;
///< Human readable identifier for the module 190 std::string SourceFileName;
///< Original source file name for module, 191 ///< recorded in bitcode. 192 std::string TargetTriple;
///< Platform target triple Module compiled on 193 ///< Format: (arch)(sub)-(vendor)-(sys0-(abi) 194 NamedMDSymTabType NamedMDSymTab;
///< NamedMDNode names. 197 CurrentIntrinsicIds;
///< Keep track of the current unique id count for 198 ///< the specified intrinsic basename. 200 UniquedIntrinsicNames;
///< Keep track of uniqued names of intrinsics 201 ///< based on unnamed types. The combination of 202 ///< ID and FunctionType maps to the extension that 203 ///< is used to make the intrinsic name unique. 205 /// llvm.module.flags metadata 211/// @name Constructors 214 /// Is this Module using intrinsics to record the position of debugging 215 /// information, or non-intrinsic records? See IsNewDbgInfoFormat in 219 /// Used when printing this module in the new debug info format; removes all 220 /// declarations of debug intrinsics that are replaced by non-intrinsic 221 /// records in the new format. 222void removeDebugIntrinsicDeclarations();
224 /// \see BasicBlock::convertToNewDbgValues. 226for (
auto &
F : *
this) {
227F.convertToNewDbgValues();
229 IsNewDbgInfoFormat =
true;
232 /// \see BasicBlock::convertFromNewDbgValues. 234for (
auto &
F : *
this) {
235F.convertFromNewDbgValues();
237 IsNewDbgInfoFormat =
false;
241if (UseNewFormat && !IsNewDbgInfoFormat)
242 convertToNewDbgValues();
243elseif (!UseNewFormat && IsNewDbgInfoFormat)
244 convertFromNewDbgValues();
247for (
auto &
F : *
this) {
248F.setNewDbgInfoFormatFlag(NewFlag);
250 IsNewDbgInfoFormat = NewFlag;
253 /// The Module constructor. Note that there is no default constructor. You 254 /// must provide a name for the module upon construction. 256 /// The module destructor. This will dropAllReferences. 263 /// @name Module Level Accessors 266 /// Get the module identifier which is, essentially, the name of the module. 267 /// @returns the module identifier as a string 270 /// Returns the number of non-debug IR instructions in the module. 271 /// This is equivalent to the sum of the IR instruction counts of each 272 /// function contained in the module. 273unsigned getInstructionCount()
const;
275 /// Get the module's original source file name. When compiling from 276 /// bitcode, this is taken from a bitcode record where it was recorded. 277 /// For other compiles it is the same as the ModuleID, which would 278 /// contain the source file name. 281 /// Get a short "name" for the module. 283 /// This is useful for debugging or logging. It is essentially a convenience 284 /// wrapper around getModuleIdentifier(). 287 /// Get the data layout string for the module's target platform. This is 288 /// equivalent to getDataLayout()->getStringRepresentation(). 290returnDL.getStringRepresentation();
293 /// Get the data layout for the module's target platform. 296 /// Get the target triple which is a string describing the target host. 297 /// @returns a string containing the target triple. 300 /// Get the global data context. 301 /// @returns LLVMContext - a container for LLVM's global information 304 /// Get any module-scope inline assembly blocks. 305 /// @returns a string containing the module-scope inline assembly blocks. 308 /// Get a RandomNumberGenerator salted for use with this module. The 309 /// RNG can be seeded via -rng-seed=<uint64> and is salted with the 310 /// ModuleID and the provided pass salt. The returned RNG should not 311 /// be shared across threads or passes. 313 /// A unique RNG per pass ensures a reproducible random stream even 314 /// when other randomness consuming passes are added or removed. In 315 /// addition, the random stream will be reproducible across LLVM 316 /// versions when the pass does not change. 317 std::unique_ptr<RandomNumberGenerator> createRNG(
constStringRefName)
const;
319 /// Return true if size-info optimization remark is enabled, false 322return getContext().getDiagHandlerPtr()->isAnalysisRemarkEnabled(
327 /// @name Module Level Mutators 330 /// Set the module identifier. 333 /// Set the module's original source file name. 336 /// Set the data layout 340 /// Set the target triple. 343 /// Set the module-scope inline assembly blocks. 344 /// A trailing newline is added if the input doesn't have one. 346 GlobalScopeAsm = std::string(Asm);
347if (!GlobalScopeAsm.empty() && GlobalScopeAsm.back() !=
'\n')
348 GlobalScopeAsm +=
'\n';
351 /// Append to the module-scope inline assembly blocks. 352 /// A trailing newline is added if the input doesn't have one. 354 GlobalScopeAsm += Asm;
355if (!GlobalScopeAsm.empty() && GlobalScopeAsm.back() !=
'\n')
356 GlobalScopeAsm +=
'\n';
360/// @name Generic Value Accessors 363 /// Return the global value in the module with the specified name, of 364 /// arbitrary type. This method returns null if a global with the specified 365 /// name is not found. 368 /// Return the number of global values in the module. 369unsigned getNumNamedValues()
const;
371 /// Return a unique non-zero ID for the specified metadata kind. This ID is 372 /// uniqued across modules in the current LLVMContext. 375 /// Populate client supplied SmallVector with the name for custom metadata IDs 376 /// registered in this LLVMContext. 379 /// Populate client supplied SmallVector with the bundle tags registered in 380 /// this LLVMContext. The bundle tags are ordered by increasing bundle IDs. 381 /// \see LLVMContext::getOperandBundleTagID 384 std::vector<StructType *> getIdentifiedStructTypes()
const;
386 /// Return a unique name for an intrinsic whose mangling is based on an 387 /// unnamed type. The Proto represents the function prototype. 392/// @name Function Accessors 395 /// Look up the specified function in the module symbol table. If it does not 396 /// exist, add a prototype for the function and return it. Otherwise, return 397 /// the existing function. 399 /// In all cases, the returned value is a FunctionCallee wrapper around the 400 /// 'FunctionType *T' passed in, as well as the 'Value*' of the Function. The 401 /// function type of the function may differ from the function type stored in 402 /// FunctionCallee if it was previously created with a different type. 404 /// Note: For library calls getOrInsertLibFunc() should be used instead. 410 /// Same as above, but takes a list of function arguments, which makes it 411 /// easier for clients to use. 412template <
typename... ArgsTy>
417return getOrInsertFunction(
Name,
418 FunctionType::get(
RetTy, ArgTys,
false),
422 /// Same as above, but without the attributes. 423template <
typename... ArgsTy>
429// Avoid an incorrect ordering that'd otherwise compile incorrectly. 430template <
typename... ArgsTy>
435 /// Look up the specified function in the module symbol table. If it does not 436 /// exist, return null. 440/// @name Global Variable Accessors 443 /// Look up the specified global variable in the module symbol table. If it 444 /// does not exist, return null. If AllowInternal is set to true, this 445 /// function will return types that have InternalLinkage. By default, these 446 /// types are not returned. 454bool AllowInternal =
false) {
459 /// Return the global variable in the module with the specified name, of 460 /// arbitrary type. This method returns null if a global with the specified 461 /// name is not found. 467static_cast<constModule *
>(
this)->getNamedGlobal(
Name));
470 /// Look up the specified global in the module symbol table. 471 /// If it does not exist, invoke a callback to create a declaration of the 472 /// global and return it. The global is constantexpr casted to the expected 473 /// type if necessary. 478 /// Look up the specified global in the module symbol table. If required, this 479 /// overload constructs the global variable using its constructor's defaults. 483/// @name Global Alias Accessors 486 /// Return the global alias in the module with the specified name, of 487 /// arbitrary type. This method returns null if a global with the specified 488 /// name is not found. 492/// @name Global IFunc Accessors 495 /// Return the global ifunc in the module with the specified name, of 496 /// arbitrary type. This method returns null if a global with the specified 497 /// name is not found. 501/// @name Named Metadata Accessors 504 /// Return the first NamedMDNode in the module with the specified name. This 505 /// method returns null if a NamedMDNode with the specified name is not found. 508 /// Return the named MDNode in the module with the specified name. This method 509 /// returns a new NamedMDNode if a NamedMDNode with the specified name is not 513 /// Remove the given NamedMDNode from this module and delete it. 517/// @name Comdat Accessors 520 /// Return the Comdat in the module with the specified name. It is created 521 /// if it didn't already exist. 525/// @name Module Flags Accessors 528 /// Returns the module flags in the provided vector. 531 /// Return the corresponding value if Key appears in module flags, otherwise 535 /// Returns the NamedMDNode in the module that represents module-level flags. 536 /// This method returns null if there are no module-level flags. 539 /// Returns the NamedMDNode in the module that represents module-level flags. 540 /// If module-level flags aren't found, it creates the named metadata that 544 /// Add a module-level flag to the module-level flags metadata. It will create 545 /// the module-level flags named metadata if it doesn't already exist. 550 /// Like addModuleFlag but replaces the old module flag if it already exists. 556 /// @name Materialization 559 /// Sets the GVMaterializer to GVM. This module must not yet have a 560 /// Materializer. To reset the materializer for a module that already has one, 561 /// call materializeAll first. Destroying this module will destroy 562 /// its materializer without materializing any more GlobalValues. Without 563 /// destroying the Module, there is no way to detach or destroy a materializer 564 /// without materializing all the GVs it controls, to avoid leaving orphan 565 /// unmaterialized GVs. 567 /// Retrieves the GVMaterializer, if any, for this Module. 571 /// Make sure the GlobalValue is fully read. 574 /// Make sure all GlobalValues in this Module are fully read and clear the 580 /// Detach global variable \p GV from the list but don't delete it. 582 /// Remove global variable \p GV from the list and delete it. 584 /// Insert global variable \p GV at the end of the global variable list and 587 insertGlobalVariable(GlobalList.end(), GV);
589 /// Insert global variable \p GV into the global variable list before \p 590 /// Where and take ownership. 592 GlobalList.insert(Where, GV);
594// Use global_size() to get the total number of global variables. 595// Use globals() to get the range of all global variables. 599/// @name Direct access to the globals list, functions list, and symbol table 602 /// Get the Module's list of global variables (constant). 603const GlobalListType &getGlobalList()
const{
return GlobalList; }
604 /// Get the Module's list of global variables. 605 GlobalListType &getGlobalList() {
return GlobalList; }
608return &Module::GlobalList;
613 /// Get the Module's list of functions (constant). 615 /// Get the Module's list of functions. 618return &Module::FunctionList;
621 /// Detach \p Alias from the list but don't delete it. 623 /// Remove \p Alias from the list and delete it. 625 /// Insert \p Alias at the end of the alias list and take ownership. 627// Use alias_size() to get the size of AliasList. 628// Use aliases() to get a range of all Alias objects in AliasList. 630 /// Detach \p IFunc from the list but don't delete it. 632 /// Remove \p IFunc from the list and delete it. 634 /// Insert \p IFunc at the end of the alias list and take ownership. 636// Use ifunc_size() to get the number of functions in IFuncList. 637// Use ifuncs() to get the range of all IFuncs. 639 /// Detach \p MDNode from the list but don't delete it. 641 /// Remove \p MDNode from the list and delete it. 643 /// Insert \p MDNode at the end of the alias list and take ownership. 645 NamedMDList.push_back(
MDNode);
647// Use named_metadata_size() to get the size of the named meatadata list. 648// Use named_metadata() to get the range of all named metadata. 650private:
// Please use functions like insertAlias(), removeAlias() etc. 651 /// Get the Module's list of aliases (constant). 652const AliasListType &getAliasList()
const{
return AliasList; }
653 /// Get the Module's list of aliases. 654 AliasListType &getAliasList() {
return AliasList; }
657return &Module::AliasList;
661 /// Get the Module's list of ifuncs (constant). 662const IFuncListType &getIFuncList()
const {
return IFuncList; }
663 /// Get the Module's list of ifuncs. 664 IFuncListType &getIFuncList() {
return IFuncList; }
667return &Module::IFuncList;
671 /// Get the Module's list of named metadata (constant). 672const NamedMDListType &getNamedMDList()
const {
return NamedMDList; }
673 /// Get the Module's list of named metadata. 674 NamedMDListType &getNamedMDList() {
return NamedMDList; }
676static NamedMDListType
Module::*getSublistAccess(NamedMDNode*) {
677return &Module::NamedMDList;
681 /// Get the symbol table of global variable and function identifiers 683 /// Get the Module's symbol table of global variable and function identifiers. 686 /// Get the Module's symbol table for COMDATs (constant). 688 /// Get the Module's symbol table for COMDATs. 692/// @name Global Variable Iteration 703returnmake_range(global_begin(), global_end());
706returnmake_range(global_begin(), global_end());
710/// @name Function Iteration 721size_tsize()
const{
return FunctionList.size(); }
722boolempty()
const{
return FunctionList.empty(); }
732/// @name Alias Iteration 750/// @name IFunc Iteration 768 /// @name Convenience iterators 791 /// @name Named Metadata Iteration 796return NamedMDList.begin();
801return NamedMDList.end();
808returnmake_range(named_metadata_begin(), named_metadata_end());
811returnmake_range(named_metadata_begin(), named_metadata_end());
814 /// An iterator for DICompileUnits that skips those marked NoDebug. 819void SkipNoDebugCUs();
858auto *CUs = getNamedMetadata(
"llvm.dbg.cu");
863auto *CUs = getNamedMetadata(
"llvm.dbg.cu");
867 /// Return an iterator for all DICompileUnits listed in this Module's 868 /// llvm.dbg.cu named metadata node and aren't explicitly marked as 871auto *CUs = getNamedMetadata(
"llvm.dbg.cu");
878 /// Destroy ConstantArrays in LLVMContext if they are not used. 879 /// ConstantArrays constructed during linking can cause quadratic memory 880 /// explosion. Releasing all unused constants can cause a 20% LTO compile-time 881 /// slowdown for a large application. 883 /// NOTE: Constants are currently owned by LLVMContext. This can then only 884 /// be called where all uses of the LLVMContext are understood. 885void dropTriviallyDeadConstantArrays();
887/// @name Utility functions for printing and dumping Module objects 890 /// Print the module to an output stream with an optional 891 /// AssemblyAnnotationWriter. If \c ShouldPreserveUseListOrder, then include 892 /// uselistorder directives so that use-lists can be recreated when reading 895bool ShouldPreserveUseListOrder =
false,
896bool IsForDebug =
false)
const;
898 /// Dump the module to stderr (for debugging). 901 /// This function causes all the subinstructions to "let go" of all references 902 /// that they are maintaining. This allows one to 'delete' a whole class at 903 /// a time, even though there may be circular references... first all 904 /// references are dropped, and all use counts go to zero. Then everything 905 /// is delete'd for real. Note that no operations are valid on an object 906 /// that has "dropped all references", except operator delete. 907void dropAllReferences();
910/// @name Utility functions for querying Debug information. 913 /// Returns the Number of Register ParametersDwarf Version by checking 915unsigned getNumberRegisterParameters()
const;
917 /// Returns the Dwarf Version by checking module flags. 918unsigned getDwarfVersion()
const;
920 /// Returns the DWARF format by checking module flags. 921bool isDwarf64()
const;
923 /// Returns the CodeView Version by checking module flags. 924 /// Returns zero if not present in module. 925unsigned getCodeViewFlag()
const;
928/// @name Utility functions for querying and setting PIC level 931 /// Returns the PIC level (small or large model) 934 /// Set the PIC level (small or large model) 939/// @name Utility functions for querying and setting PIE level 942 /// Returns the PIE level (small or large model) 945 /// Set the PIE level (small or large model) 950 /// @name Utility function for querying and setting code model 953 /// Returns the code model (tiny, small, kernel, medium or large model) 956 /// Set the code model (tiny, small, kernel, medium or large) 961 /// @name Utility function for querying and setting the large data threshold 964 /// Returns the code model (tiny, small, kernel, medium or large model) 965 std::optional<uint64_t> getLargeDataThreshold()
const;
967 /// Set the code model (tiny, small, kernel, medium or large) 968void setLargeDataThreshold(
uint64_t Threshold);
971 /// @name Utility functions for querying and setting PGO summary 974 /// Attach profile summary metadata to this module. 977 /// Returns profile summary metadata. When IsCS is true, use the context 978 /// sensitive profile summary. 979Metadata *getProfileSummary(
bool IsCS)
const;
982 /// Returns whether semantic interposition is to be respected. 983bool getSemanticInterposition()
const;
985 /// Set whether semantic interposition is to be respected. 986void setSemanticInterposition(
bool);
988 /// Returns true if PLT should be avoided for RTLib calls. 989bool getRtLibUseGOT()
const;
991 /// Set that PLT should be avoid for RTLib calls. 992void setRtLibUseGOT();
994 /// Get/set whether referencing global variables can use direct access 995 /// relocations on ELF targets. 996bool getDirectAccessExternalData()
const;
997void setDirectAccessExternalData(
boolValue);
999 /// Get/set whether synthesized functions should get the uwtable attribute. 1003 /// Get/set whether synthesized functions should get the "frame-pointer" 1008 /// Get/set what kind of stack protector guard to use. 1010void setStackProtectorGuard(
StringRef Kind);
1012 /// Get/set which register to use as the stack protector guard register. The 1013 /// empty string is equivalent to "global". Other values may be "tls" or 1015StringRef getStackProtectorGuardReg()
const;
1018 /// Get/set a symbol to use as the stack protector guard. 1019StringRef getStackProtectorGuardSymbol()
const;
1020void setStackProtectorGuardSymbol(
StringRef Symbol);
1022 /// Get/set what offset from the stack protector to use. 1023int getStackProtectorGuardOffset()
const;
1024void setStackProtectorGuardOffset(
intOffset);
1026 /// Get/set the stack alignment overridden from the default. 1027unsigned getOverrideStackAlignment()
const;
1028void setOverrideStackAlignment(
unsignedAlign);
1030unsigned getMaxTLSAlignment()
const;
1032 /// @name Utility functions for querying and setting the build SDK version 1035 /// Attach a build SDK version metadata to this module. 1038 /// Get the build SDK version metadata. 1040 /// An empty version is returned if no such metadata is attached. 1044 /// Take ownership of the given memory buffer. 1045void setOwnedMemoryBuffer(std::unique_ptr<MemoryBuffer> MB);
1047 /// Set the partial sample profile ratio in the profile summary module flag, 1051 /// Get the target variant triple which is a string describing a variant of 1052 /// the target host platform. For example, Mac Catalyst can be a variant 1053 /// target triple for a macOS target. 1054 /// @returns a string containing the target variant triple. 1055StringRef getDarwinTargetVariantTriple()
const;
1057 /// Set the target variant triple which is a string describing a variant of 1058 /// the target host platform. 1059void setDarwinTargetVariantTriple(
StringRefT);
1061 /// Get the target variant version build SDK version metadata. 1063 /// An empty version is returned if no such metadata is attached. 1066 /// Set the target variant version build SDK version metadata. 1067void setDarwinTargetVariantSDKVersion(
VersionTuple Version);
1070/// Given "llvm.used" or "llvm.compiler.used" as a global name, collect the 1071/// initializer elements of that global in a SmallVector and return the global 1074 SmallVectorImpl<GlobalValue *> &Vec,
1077/// An raw_ostream inserter for modules. 1083// Create wrappers for C Binding types (see CBindingWrapping.h). 1086/* LLVMModuleProviderRef exists for historical reasons, but now just holds a 1090returnreinterpret_cast<Module*
>(MP);
1093}
// end namespace llvm 1095#endif// LLVM_IR_MODULE_H 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")
static GCRegistry::Add< ShadowStackGC > C("shadow-stack", "Very portable GC for uncooperative code generators")
#define DEFINE_SIMPLE_CONVERSION_FUNCTIONS(ty, ref)
Returns the sub type a function will return at a given Idx Should correspond to the result type of an ExtractValue instruction executed with just that one unsigned Idx
std::optional< std::vector< StOtherPiece > > Other
static Function * getFunction(Constant *C)
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)
This file contains the declarations for metadata subclasses.
static CodeModel::Model getCodeModel(const PPCSubtarget &S, const TargetMachine &TM, const MachineOperand &MO)
This file contains some templates that are useful if you are working with the STL at all.
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.
This is an important class for using LLVM in a threaded context.
Root of the metadata hierarchy.
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
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.
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
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.
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).
bool IsNewDbgInfoFormat
Is this Module using intrinsics to record the position of debugging information, or non-intrinsic rec...
global_iterator global_end()
GlobalVariable * getNamedGlobal(StringRef Name)
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
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()
const std::string & getTargetTriple() const
Get the target triple which is a string describing the target host.
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.
GlobalListType::iterator global_iterator
The Global Variable iterator.
void setNewDbgInfoFormatFlag(bool NewFlag)
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_reverse_iterator rend() const
iterator_range< const_named_metadata_iterator > named_metadata() const
IFuncListType::const_iterator const_ifunc_iterator
The Global IFunc constant iterator.
size_t ifunc_size() const
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
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.
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
void setIsNewDbgInfoFormat(bool UseNewFormat)
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
const_iterator end() const
void setSourceFileName(StringRef Name)
Set the module's original source file name.
const_ifunc_iterator ifunc_begin() const
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.
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
void setTargetTriple(StringRef T)
Set the target triple.
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
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.
StringRef - Represent a constant reference to a string, i.e.
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
An intrusive list with ownership and callbacks specified/controlled by ilist_traits,...
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.
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.
Attribute unwrap(LLVMAttributeRef Attr)
raw_ostream & operator<<(raw_ostream &OS, const APFixedPoint &FX)
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.
Description of the encoding of one expression Op.
ModuleFlagEntry(ModFlagBehavior B, MDString *K, Metadata *V)