LLVM 19.0.0git
Module.h
Go to the documentation of this file.
1//===- llvm/Module.h - C++ class to represent a VM module -------*- C++ -*-===//
2//
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
6//
7//===----------------------------------------------------------------------===//
8//
9/// @file
10/// Module.h This file contains the declarations for the Module class.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef LLVM_IR_MODULE_H
15#define LLVM_IR_MODULE_H
16
17#include "llvm-c/Types.h"
18#include "llvm/ADT/STLExtras.h"
19#include "llvm/ADT/StringMap.h"
20#include "llvm/ADT/StringRef.h"
22#include "llvm/IR/Attributes.h"
23#include "llvm/IR/Comdat.h"
24#include "llvm/IR/DataLayout.h"
25#include "llvm/IR/Function.h"
26#include "llvm/IR/GlobalAlias.h"
27#include "llvm/IR/GlobalIFunc.h"
29#include "llvm/IR/Metadata.h"
34#include <cstddef>
35#include <cstdint>
36#include <iterator>
37#include <memory>
38#include <optional>
39#include <string>
40#include <vector>
41
42namespace llvm {
43
44class Error;
45class FunctionType;
46class GVMaterializer;
47class LLVMContext;
48class MemoryBuffer;
49class ModuleSummaryIndex;
50class RandomNumberGenerator;
51class StructType;
52class VersionTuple;
53
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.
60///
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
67 /// @{
68public:
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.
83
84 /// The Global Variable iterator.
86 /// The Global Variable constant iterator.
88
89 /// The Function iterators.
91 /// The Function constant iterator
93
94 /// The Function reverse iterator.
96 /// The Function constant reverse iterator.
98
99 /// The Global Alias iterators.
101 /// The Global Alias constant iterator
103
104 /// The Global IFunc iterators.
106 /// The Global IFunc constant iterator
108
109 /// The named metadata iterators.
111 /// The named metadata constant iterators.
113
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.
118 Error = 1,
119
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.
122 Warning = 2,
123
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.
131 Require = 3,
132
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.
136 Override = 4,
137
138 /// Appends the two values, which are required to be metadata nodes.
139 Append = 5,
140
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.
144 AppendUnique = 6,
145
146 /// Takes the max of the two values, which are required to be integers.
147 Max = 7,
148
149 /// Takes the min of the two values, which are required to be integers.
150 Min = 8,
151
152 // Markers:
153 ModFlagBehaviorFirstVal = Error,
154 ModFlagBehaviorLastVal = Min
155 };
156
157 /// Checks if Metadata represents a valid ModFlagBehavior, and stores the
158 /// converted result in MFB.
159 static bool isValidModFlagBehavior(Metadata *MD, ModFlagBehavior &MFB);
160
161 /// Check if the given module flag metadata represents a valid module flag,
162 /// and store the flag behavior, the key string and the value metadata.
163 static bool isValidModuleFlag(const MDNode &ModFlag, ModFlagBehavior &MFB,
164 MDString *&Key, Metadata *&Val);
165
170
172 : Behavior(B), Key(K), Val(V) {}
173 };
174
175/// @}
176/// @name Member Variables
177/// @{
178private:
179 LLVMContext &Context; ///< The LLVMContext from which types and
180 ///< constants are allocated.
181 GlobalListType GlobalList; ///< The Global Variables in the module
182 FunctionListType FunctionList; ///< The Functions in the module
183 AliasListType AliasList; ///< The Aliases in the module
184 IFuncListType IFuncList; ///< The IFuncs in the module
185 NamedMDListType NamedMDList; ///< The named metadata in the module
186 std::string GlobalScopeAsm; ///< Inline Asm at global scope.
187 std::unique_ptr<ValueSymbolTable> ValSymTab; ///< Symbol table for values
188 ComdatSymTabType ComdatSymTab; ///< Symbol table for COMDATs
189 std::unique_ptr<MemoryBuffer>
190 OwnedMemoryBuffer; ///< Memory buffer directly owned by this
191 ///< module, for legacy clients only.
192 std::unique_ptr<GVMaterializer>
193 Materializer; ///< Used to materialize GlobalValues
194 std::string ModuleID; ///< Human readable identifier for the module
195 std::string SourceFileName; ///< Original source file name for module,
196 ///< recorded in bitcode.
197 std::string TargetTriple; ///< Platform target triple Module compiled on
198 ///< Format: (arch)(sub)-(vendor)-(sys0-(abi)
199 NamedMDSymTabType NamedMDSymTab; ///< NamedMDNode names.
200 DataLayout DL; ///< DataLayout associated with the module
202 CurrentIntrinsicIds; ///< Keep track of the current unique id count for
203 ///< the specified intrinsic basename.
205 UniquedIntrinsicNames; ///< Keep track of uniqued names of intrinsics
206 ///< based on unnamed types. The combination of
207 ///< ID and FunctionType maps to the extension that
208 ///< is used to make the intrinsic name unique.
209
210 friend class Constant;
211
212/// @}
213/// @name Constructors
214/// @{
215public:
216 /// Is this Module using intrinsics to record the position of debugging
217 /// information, or non-intrinsic records? See IsNewDbgInfoFormat in
218 /// \ref BasicBlock.
220
221 /// Used when printing this module in the new debug info format; removes all
222 /// declarations of debug intrinsics that are replaced by non-intrinsic
223 /// records in the new format.
224 void removeDebugIntrinsicDeclarations();
225
226 /// \see BasicBlock::convertToNewDbgValues.
228 for (auto &F : *this) {
229 F.convertToNewDbgValues();
230 }
231 IsNewDbgInfoFormat = true;
232 }
233
234 /// \see BasicBlock::convertFromNewDbgValues.
236 for (auto &F : *this) {
237 F.convertFromNewDbgValues();
238 }
239 IsNewDbgInfoFormat = false;
240 }
241
242 void setIsNewDbgInfoFormat(bool UseNewFormat) {
243 if (UseNewFormat && !IsNewDbgInfoFormat)
244 convertToNewDbgValues();
245 else if (!UseNewFormat && IsNewDbgInfoFormat)
246 convertFromNewDbgValues();
247 }
248 void setNewDbgInfoFormatFlag(bool NewFlag) {
249 for (auto &F : *this) {
250 F.setNewDbgInfoFormatFlag(NewFlag);
251 }
252 IsNewDbgInfoFormat = NewFlag;
253 }
254
255 /// The Module constructor. Note that there is no default constructor. You
256 /// must provide a name for the module upon construction.
257 explicit Module(StringRef ModuleID, LLVMContext& C);
258 /// The module destructor. This will dropAllReferences.
259 ~Module();
260
261/// @}
262/// @name Module Level Accessors
263/// @{
264
265 /// Get the module identifier which is, essentially, the name of the module.
266 /// @returns the module identifier as a string
267 const std::string &getModuleIdentifier() const { return ModuleID; }
268
269 /// Returns the number of non-debug IR instructions in the module.
270 /// This is equivalent to the sum of the IR instruction counts of each
271 /// function contained in the module.
272 unsigned getInstructionCount() const;
273
274 /// Get the module's original source file name. When compiling from
275 /// bitcode, this is taken from a bitcode record where it was recorded.
276 /// For other compiles it is the same as the ModuleID, which would
277 /// contain the source file name.
278 const std::string &getSourceFileName() const { return SourceFileName; }
279
280 /// Get a short "name" for the module.
281 ///
282 /// This is useful for debugging or logging. It is essentially a convenience
283 /// wrapper around getModuleIdentifier().
284 StringRef getName() const { return ModuleID; }
285
286 /// Get the data layout string for the module's target platform. This is
287 /// equivalent to getDataLayout()->getStringRepresentation().
288 const std::string &getDataLayoutStr() const {
289 return DL.getStringRepresentation();
290 }
291
292 /// Get the data layout for the module's target platform.
293 const DataLayout &getDataLayout() const { return DL; }
294
295 /// Get the target triple which is a string describing the target host.
296 /// @returns a string containing the target triple.
297 const std::string &getTargetTriple() const { return TargetTriple; }
298
299 /// Get the global data context.
300 /// @returns LLVMContext - a container for LLVM's global information
301 LLVMContext &getContext() const { return Context; }
302
303 /// Get any module-scope inline assembly blocks.
304 /// @returns a string containing the module-scope inline assembly blocks.
305 const std::string &getModuleInlineAsm() const { return GlobalScopeAsm; }
306
307 /// Get a RandomNumberGenerator salted for use with this module. The
308 /// RNG can be seeded via -rng-seed=<uint64> and is salted with the
309 /// ModuleID and the provided pass salt. The returned RNG should not
310 /// be shared across threads or passes.
311 ///
312 /// A unique RNG per pass ensures a reproducible random stream even
313 /// when other randomness consuming passes are added or removed. In
314 /// addition, the random stream will be reproducible across LLVM
315 /// versions when the pass does not change.
316 std::unique_ptr<RandomNumberGenerator> createRNG(const StringRef Name) const;
317
318 /// Return true if size-info optimization remark is enabled, false
319 /// otherwise.
321 return getContext().getDiagHandlerPtr()->isAnalysisRemarkEnabled(
322 "size-info");
323 }
324
325 /// @}
326 /// @name Module Level Mutators
327 /// @{
328
329 /// Set the module identifier.
330 void setModuleIdentifier(StringRef ID) { ModuleID = std::string(ID); }
331
332 /// Set the module's original source file name.
333 void setSourceFileName(StringRef Name) { SourceFileName = std::string(Name); }
334
335 /// Set the data layout
336 void setDataLayout(StringRef Desc);
337 void setDataLayout(const DataLayout &Other);
338
339 /// Set the target triple.
340 void setTargetTriple(StringRef T) { TargetTriple = std::string(T); }
341
342 /// Set the module-scope inline assembly blocks.
343 /// A trailing newline is added if the input doesn't have one.
345 GlobalScopeAsm = std::string(Asm);
346 if (!GlobalScopeAsm.empty() && GlobalScopeAsm.back() != '\n')
347 GlobalScopeAsm += '\n';
348 }
349
350 /// Append to the module-scope inline assembly blocks.
351 /// A trailing newline is added if the input doesn't have one.
353 GlobalScopeAsm += Asm;
354 if (!GlobalScopeAsm.empty() && GlobalScopeAsm.back() != '\n')
355 GlobalScopeAsm += '\n';
356 }
357
358/// @}
359/// @name Generic Value Accessors
360/// @{
361
362 /// Return the global value in the module with the specified name, of
363 /// arbitrary type. This method returns null if a global with the specified
364 /// name is not found.
365 GlobalValue *getNamedValue(StringRef Name) const;
366
367 /// Return the number of global values in the module.
368 unsigned getNumNamedValues() const;
369
370 /// Return a unique non-zero ID for the specified metadata kind. This ID is
371 /// uniqued across modules in the current LLVMContext.
372 unsigned getMDKindID(StringRef Name) const;
373
374 /// Populate client supplied SmallVector with the name for custom metadata IDs
375 /// registered in this LLVMContext.
376 void getMDKindNames(SmallVectorImpl<StringRef> &Result) const;
377
378 /// Populate client supplied SmallVector with the bundle tags registered in
379 /// this LLVMContext. The bundle tags are ordered by increasing bundle IDs.
380 /// \see LLVMContext::getOperandBundleTagID
381 void getOperandBundleTags(SmallVectorImpl<StringRef> &Result) const;
382
383 std::vector<StructType *> getIdentifiedStructTypes() const;
384
385 /// Return a unique name for an intrinsic whose mangling is based on an
386 /// unnamed type. The Proto represents the function prototype.
387 std::string getUniqueIntrinsicName(StringRef BaseName, Intrinsic::ID Id,
388 const FunctionType *Proto);
389
390/// @}
391/// @name Function Accessors
392/// @{
393
394 /// Look up the specified function in the module symbol table. If it does not
395 /// exist, add a prototype for the function and return it. Otherwise, return
396 /// the existing function.
397 ///
398 /// In all cases, the returned value is a FunctionCallee wrapper around the
399 /// 'FunctionType *T' passed in, as well as the 'Value*' of the Function. The
400 /// function type of the function may differ from the function type stored in
401 /// FunctionCallee if it was previously created with a different type.
402 ///
403 /// Note: For library calls getOrInsertLibFunc() should be used instead.
404 FunctionCallee getOrInsertFunction(StringRef Name, FunctionType *T,
406
407 FunctionCallee getOrInsertFunction(StringRef Name, FunctionType *T);
408
409 /// Same as above, but takes a list of function arguments, which makes it
410 /// easier for clients to use.
411 template <typename... ArgsTy>
414 ArgsTy... Args) {
415 SmallVector<Type*, sizeof...(ArgsTy)> ArgTys{Args...};
416 return getOrInsertFunction(Name,
417 FunctionType::get(RetTy, ArgTys, false),
419 }
420
421 /// Same as above, but without the attributes.
422 template <typename... ArgsTy>
424 ArgsTy... Args) {
425 return getOrInsertFunction(Name, AttributeList{}, RetTy, Args...);
426 }
427
428 // Avoid an incorrect ordering that'd otherwise compile incorrectly.
429 template <typename... ArgsTy>
432 FunctionType *Invalid, ArgsTy... Args) = delete;
433
434 /// Look up the specified function in the module symbol table. If it does not
435 /// exist, return null.
437
438/// @}
439/// @name Global Variable Accessors
440/// @{
441
442 /// Look up the specified global variable in the module symbol table. If it
443 /// does not exist, return null. If AllowInternal is set to true, this
444 /// function will return types that have InternalLinkage. By default, these
445 /// types are not returned.
447 return getGlobalVariable(Name, false);
448 }
449
450 GlobalVariable *getGlobalVariable(StringRef Name, bool AllowInternal) const;
451
453 bool AllowInternal = false) {
454 return static_cast<const Module *>(this)->getGlobalVariable(Name,
455 AllowInternal);
456 }
457
458 /// Return the global variable in the module with the specified name, of
459 /// arbitrary type. This method returns null if a global with the specified
460 /// name is not found.
462 return getGlobalVariable(Name, true);
463 }
465 return const_cast<GlobalVariable *>(
466 static_cast<const Module *>(this)->getNamedGlobal(Name));
467 }
468
469 /// Look up the specified global in the module symbol table.
470 /// If it does not exist, invoke a callback to create a declaration of the
471 /// global and return it. The global is constantexpr casted to the expected
472 /// type if necessary.
473 Constant *
475 function_ref<GlobalVariable *()> CreateGlobalCallback);
476
477 /// Look up the specified global in the module symbol table. If required, this
478 /// overload constructs the global variable using its constructor's defaults.
480
481/// @}
482/// @name Global Alias Accessors
483/// @{
484
485 /// Return the global alias in the module with the specified name, of
486 /// arbitrary type. This method returns null if a global with the specified
487 /// name is not found.
488 GlobalAlias *getNamedAlias(StringRef Name) const;
489
490/// @}
491/// @name Global IFunc Accessors
492/// @{
493
494 /// Return the global ifunc in the module with the specified name, of
495 /// arbitrary type. This method returns null if a global with the specified
496 /// name is not found.
497 GlobalIFunc *getNamedIFunc(StringRef Name) const;
498
499/// @}
500/// @name Named Metadata Accessors
501/// @{
502
503 /// Return the first NamedMDNode in the module with the specified name. This
504 /// method returns null if a NamedMDNode with the specified name is not found.
505 NamedMDNode *getNamedMetadata(const Twine &Name) const;
506
507 /// Return the named MDNode in the module with the specified name. This method
508 /// returns a new NamedMDNode if a NamedMDNode with the specified name is not
509 /// found.
510 NamedMDNode *getOrInsertNamedMetadata(StringRef Name);
511
512 /// Remove the given NamedMDNode from this module and delete it.
513 void eraseNamedMetadata(NamedMDNode *NMD);
514
515/// @}
516/// @name Comdat Accessors
517/// @{
518
519 /// Return the Comdat in the module with the specified name. It is created
520 /// if it didn't already exist.
521 Comdat *getOrInsertComdat(StringRef Name);
522
523/// @}
524/// @name Module Flags Accessors
525/// @{
526
527 /// Returns the module flags in the provided vector.
528 void getModuleFlagsMetadata(SmallVectorImpl<ModuleFlagEntry> &Flags) const;
529
530 /// Return the corresponding value if Key appears in module flags, otherwise
531 /// return null.
532 Metadata *getModuleFlag(StringRef Key) const;
533
534 /// Returns the NamedMDNode in the module that represents module-level flags.
535 /// This method returns null if there are no module-level flags.
536 NamedMDNode *getModuleFlagsMetadata() const;
537
538 /// Returns the NamedMDNode in the module that represents module-level flags.
539 /// If module-level flags aren't found, it creates the named metadata that
540 /// contains them.
541 NamedMDNode *getOrInsertModuleFlagsMetadata();
542
543 /// Add a module-level flag to the module-level flags metadata. It will create
544 /// the module-level flags named metadata if it doesn't already exist.
545 void addModuleFlag(ModFlagBehavior Behavior, StringRef Key, Metadata *Val);
546 void addModuleFlag(ModFlagBehavior Behavior, StringRef Key, Constant *Val);
547 void addModuleFlag(ModFlagBehavior Behavior, StringRef Key, uint32_t Val);
548 void addModuleFlag(MDNode *Node);
549 /// Like addModuleFlag but replaces the old module flag if it already exists.
550 void setModuleFlag(ModFlagBehavior Behavior, StringRef Key, Metadata *Val);
551 void setModuleFlag(ModFlagBehavior Behavior, StringRef Key, Constant *Val);
552 void setModuleFlag(ModFlagBehavior Behavior, StringRef Key, uint32_t Val);
553
554 /// @}
555 /// @name Materialization
556 /// @{
557
558 /// Sets the GVMaterializer to GVM. This module must not yet have a
559 /// Materializer. To reset the materializer for a module that already has one,
560 /// call materializeAll first. Destroying this module will destroy
561 /// its materializer without materializing any more GlobalValues. Without
562 /// destroying the Module, there is no way to detach or destroy a materializer
563 /// without materializing all the GVs it controls, to avoid leaving orphan
564 /// unmaterialized GVs.
565 void setMaterializer(GVMaterializer *GVM);
566 /// Retrieves the GVMaterializer, if any, for this Module.
567 GVMaterializer *getMaterializer() const { return Materializer.get(); }
568 bool isMaterialized() const { return !getMaterializer(); }
569
570 /// Make sure the GlobalValue is fully read.
571 llvm::Error materialize(GlobalValue *GV);
572
573 /// Make sure all GlobalValues in this Module are fully read and clear the
574 /// Materializer.
575 llvm::Error materializeAll();
576
577 llvm::Error materializeMetadata();
578
579 /// Detach global variable \p GV from the list but don't delete it.
580 void removeGlobalVariable(GlobalVariable *GV) { GlobalList.remove(GV); }
581 /// Remove global variable \p GV from the list and delete it.
582 void eraseGlobalVariable(GlobalVariable *GV) { GlobalList.erase(GV); }
583 /// Insert global variable \p GV at the end of the global variable list and
584 /// take ownership.
586 insertGlobalVariable(GlobalList.end(), GV);
587 }
588 /// Insert global variable \p GV into the global variable list before \p
589 /// Where and take ownership.
591 GlobalList.insert(Where, GV);
592 }
593 // Use global_size() to get the total number of global variables.
594 // Use globals() to get the range of all global variables.
595
596private:
597/// @}
598/// @name Direct access to the globals list, functions list, and symbol table
599/// @{
600
601 /// Get the Module's list of global variables (constant).
602 const GlobalListType &getGlobalList() const { return GlobalList; }
603 /// Get the Module's list of global variables.
604 GlobalListType &getGlobalList() { return GlobalList; }
605
606 static GlobalListType Module::*getSublistAccess(GlobalVariable*) {
607 return &Module::GlobalList;
608 }
610
611public:
612 /// Get the Module's list of functions (constant).
613 const FunctionListType &getFunctionList() const { return FunctionList; }
614 /// Get the Module's list of functions.
615 FunctionListType &getFunctionList() { return FunctionList; }
617 return &Module::FunctionList;
618 }
619
620 /// Detach \p Alias from the list but don't delete it.
621 void removeAlias(GlobalAlias *Alias) { AliasList.remove(Alias); }
622 /// Remove \p Alias from the list and delete it.
623 void eraseAlias(GlobalAlias *Alias) { AliasList.erase(Alias); }
624 /// Insert \p Alias at the end of the alias list and take ownership.
625 void insertAlias(GlobalAlias *Alias) { AliasList.insert(AliasList.end(), Alias); }
626 // Use alias_size() to get the size of AliasList.
627 // Use aliases() to get a range of all Alias objects in AliasList.
628
629 /// Detach \p IFunc from the list but don't delete it.
630 void removeIFunc(GlobalIFunc *IFunc) { IFuncList.remove(IFunc); }
631 /// Remove \p IFunc from the list and delete it.
632 void eraseIFunc(GlobalIFunc *IFunc) { IFuncList.erase(IFunc); }
633 /// Insert \p IFunc at the end of the alias list and take ownership.
634 void insertIFunc(GlobalIFunc *IFunc) { IFuncList.push_back(IFunc); }
635 // Use ifunc_size() to get the number of functions in IFuncList.
636 // Use ifuncs() to get the range of all IFuncs.
637
638 /// Detach \p MDNode from the list but don't delete it.
639 void removeNamedMDNode(NamedMDNode *MDNode) { NamedMDList.remove(MDNode); }
640 /// Remove \p MDNode from the list and delete it.
641 void eraseNamedMDNode(NamedMDNode *MDNode) { NamedMDList.erase(MDNode); }
642 /// Insert \p MDNode at the end of the alias list and take ownership.
644 NamedMDList.push_back(MDNode);
645 }
646 // Use named_metadata_size() to get the size of the named meatadata list.
647 // Use named_metadata() to get the range of all named metadata.
648
649private: // Please use functions like insertAlias(), removeAlias() etc.
650 /// Get the Module's list of aliases (constant).
651 const AliasListType &getAliasList() const { return AliasList; }
652 /// Get the Module's list of aliases.
653 AliasListType &getAliasList() { return AliasList; }
654
655 static AliasListType Module::*getSublistAccess(GlobalAlias*) {
656 return &Module::AliasList;
657 }
659
660 /// Get the Module's list of ifuncs (constant).
661 const IFuncListType &getIFuncList() const { return IFuncList; }
662 /// Get the Module's list of ifuncs.
663 IFuncListType &getIFuncList() { return IFuncList; }
664
665 static IFuncListType Module::*getSublistAccess(GlobalIFunc*) {
666 return &Module::IFuncList;
667 }
669
670 /// Get the Module's list of named metadata (constant).
671 const NamedMDListType &getNamedMDList() const { return NamedMDList; }
672 /// Get the Module's list of named metadata.
673 NamedMDListType &getNamedMDList() { return NamedMDList; }
674
675 static NamedMDListType Module::*getSublistAccess(NamedMDNode*) {
676 return &Module::NamedMDList;
677 }
678
679public:
680 /// Get the symbol table of global variable and function identifiers
681 const ValueSymbolTable &getValueSymbolTable() const { return *ValSymTab; }
682 /// Get the Module's symbol table of global variable and function identifiers.
683 ValueSymbolTable &getValueSymbolTable() { return *ValSymTab; }
684
685 /// Get the Module's symbol table for COMDATs (constant).
686 const ComdatSymTabType &getComdatSymbolTable() const { return ComdatSymTab; }
687 /// Get the Module's symbol table for COMDATs.
688 ComdatSymTabType &getComdatSymbolTable() { return ComdatSymTab; }
689
690/// @}
691/// @name Global Variable Iteration
692/// @{
693
694 global_iterator global_begin() { return GlobalList.begin(); }
695 const_global_iterator global_begin() const { return GlobalList.begin(); }
696 global_iterator global_end () { return GlobalList.end(); }
697 const_global_iterator global_end () const { return GlobalList.end(); }
698 size_t global_size () const { return GlobalList.size(); }
699 bool global_empty() const { return GlobalList.empty(); }
700
702 return make_range(global_begin(), global_end());
703 }
705 return make_range(global_begin(), global_end());
706 }
707
708/// @}
709/// @name Function Iteration
710/// @{
711
712 iterator begin() { return FunctionList.begin(); }
713 const_iterator begin() const { return FunctionList.begin(); }
714 iterator end () { return FunctionList.end(); }
715 const_iterator end () const { return FunctionList.end(); }
716 reverse_iterator rbegin() { return FunctionList.rbegin(); }
717 const_reverse_iterator rbegin() const{ return FunctionList.rbegin(); }
718 reverse_iterator rend() { return FunctionList.rend(); }
719 const_reverse_iterator rend() const { return FunctionList.rend(); }
720 size_t size() const { return FunctionList.size(); }
721 bool empty() const { return FunctionList.empty(); }
722
724 return make_range(begin(), end());
725 }
727 return make_range(begin(), end());
728 }
729
730/// @}
731/// @name Alias Iteration
732/// @{
733
734 alias_iterator alias_begin() { return AliasList.begin(); }
735 const_alias_iterator alias_begin() const { return AliasList.begin(); }
736 alias_iterator alias_end () { return AliasList.end(); }
737 const_alias_iterator alias_end () const { return AliasList.end(); }
738 size_t alias_size () const { return AliasList.size(); }
739 bool alias_empty() const { return AliasList.empty(); }
740
742 return make_range(alias_begin(), alias_end());
743 }
745 return make_range(alias_begin(), alias_end());
746 }
747
748/// @}
749/// @name IFunc Iteration
750/// @{
751
752 ifunc_iterator ifunc_begin() { return IFuncList.begin(); }
753 const_ifunc_iterator ifunc_begin() const { return IFuncList.begin(); }
754 ifunc_iterator ifunc_end () { return IFuncList.end(); }
755 const_ifunc_iterator ifunc_end () const { return IFuncList.end(); }
756 size_t ifunc_size () const { return IFuncList.size(); }
757 bool ifunc_empty() const { return IFuncList.empty(); }
758
760 return make_range(ifunc_begin(), ifunc_end());
761 }
763 return make_range(ifunc_begin(), ifunc_end());
764 }
765
766 /// @}
767 /// @name Convenience iterators
768 /// @{
769
775
778
785
788
789 /// @}
790 /// @name Named Metadata Iteration
791 /// @{
792
793 named_metadata_iterator named_metadata_begin() { return NamedMDList.begin(); }
795 return NamedMDList.begin();
796 }
797
798 named_metadata_iterator named_metadata_end() { return NamedMDList.end(); }
800 return NamedMDList.end();
801 }
802
803 size_t named_metadata_size() const { return NamedMDList.size(); }
804 bool named_metadata_empty() const { return NamedMDList.empty(); }
805
807 return make_range(named_metadata_begin(), named_metadata_end());
808 }
810 return make_range(named_metadata_begin(), named_metadata_end());
811 }
812
813 /// An iterator for DICompileUnits that skips those marked NoDebug.
815 NamedMDNode *CUs;
816 unsigned Idx;
817
818 void SkipNoDebugCUs();
819
820 public:
821 using iterator_category = std::input_iterator_tag;
823 using difference_type = std::ptrdiff_t;
826
828 : CUs(CUs), Idx(Idx) {
829 SkipNoDebugCUs();
830 }
831
833 ++Idx;
834 SkipNoDebugCUs();
835 return *this;
836 }
837
840 ++Idx;
841 return T;
842 }
843
845 return Idx == I.Idx;
846 }
847
849 return Idx != I.Idx;
850 }
851
852 DICompileUnit *operator*() const;
853 DICompileUnit *operator->() const;
854 };
855
857 auto *CUs = getNamedMetadata("llvm.dbg.cu");
858 return debug_compile_units_iterator(CUs, 0);
859 }
860
862 auto *CUs = getNamedMetadata("llvm.dbg.cu");
863 return debug_compile_units_iterator(CUs, CUs ? CUs->getNumOperands() : 0);
864 }
865
866 /// Return an iterator for all DICompileUnits listed in this Module's
867 /// llvm.dbg.cu named metadata node and aren't explicitly marked as
868 /// NoDebug.
870 auto *CUs = getNamedMetadata("llvm.dbg.cu");
871 return make_range(
873 debug_compile_units_iterator(CUs, CUs ? CUs->getNumOperands() : 0));
874 }
875/// @}
876
877 /// Destroy ConstantArrays in LLVMContext if they are not used.
878 /// ConstantArrays constructed during linking can cause quadratic memory
879 /// explosion. Releasing all unused constants can cause a 20% LTO compile-time
880 /// slowdown for a large application.
881 ///
882 /// NOTE: Constants are currently owned by LLVMContext. This can then only
883 /// be called where all uses of the LLVMContext are understood.
884 void dropTriviallyDeadConstantArrays();
885
886/// @name Utility functions for printing and dumping Module objects
887/// @{
888
889 /// Print the module to an output stream with an optional
890 /// AssemblyAnnotationWriter. If \c ShouldPreserveUseListOrder, then include
891 /// uselistorder directives so that use-lists can be recreated when reading
892 /// the assembly.
894 bool ShouldPreserveUseListOrder = false,
895 bool IsForDebug = false) const;
896
897 /// Dump the module to stderr (for debugging).
898 void dump() const;
899
900 /// This function causes all the subinstructions to "let go" of all references
901 /// that they are maintaining. This allows one to 'delete' a whole class at
902 /// a time, even though there may be circular references... first all
903 /// references are dropped, and all use counts go to zero. Then everything
904 /// is delete'd for real. Note that no operations are valid on an object
905 /// that has "dropped all references", except operator delete.
906 void dropAllReferences();
907
908/// @}
909/// @name Utility functions for querying Debug information.
910/// @{
911
912 /// Returns the Number of Register ParametersDwarf Version by checking
913 /// module flags.
914 unsigned getNumberRegisterParameters() const;
915
916 /// Returns the Dwarf Version by checking module flags.
917 unsigned getDwarfVersion() const;
918
919 /// Returns the DWARF format by checking module flags.
920 bool isDwarf64() const;
921
922 /// Returns the CodeView Version by checking module flags.
923 /// Returns zero if not present in module.
924 unsigned getCodeViewFlag() const;
925
926/// @}
927/// @name Utility functions for querying and setting PIC level
928/// @{
929
930 /// Returns the PIC level (small or large model)
931 PICLevel::Level getPICLevel() const;
932
933 /// Set the PIC level (small or large model)
934 void setPICLevel(PICLevel::Level PL);
935/// @}
936
937/// @}
938/// @name Utility functions for querying and setting PIE level
939/// @{
940
941 /// Returns the PIE level (small or large model)
942 PIELevel::Level getPIELevel() const;
943
944 /// Set the PIE level (small or large model)
945 void setPIELevel(PIELevel::Level PL);
946/// @}
947
948 /// @}
949 /// @name Utility function for querying and setting code model
950 /// @{
951
952 /// Returns the code model (tiny, small, kernel, medium or large model)
953 std::optional<CodeModel::Model> getCodeModel() const;
954
955 /// Set the code model (tiny, small, kernel, medium or large)
956 void setCodeModel(CodeModel::Model CL);
957 /// @}
958
959 /// @}
960 /// @name Utility function for querying and setting the large data threshold
961 /// @{
962
963 /// Returns the code model (tiny, small, kernel, medium or large model)
964 std::optional<uint64_t> getLargeDataThreshold() const;
965
966 /// Set the code model (tiny, small, kernel, medium or large)
967 void setLargeDataThreshold(uint64_t Threshold);
968 /// @}
969
970 /// @name Utility functions for querying and setting PGO summary
971 /// @{
972
973 /// Attach profile summary metadata to this module.
974 void setProfileSummary(Metadata *M, ProfileSummary::Kind Kind);
975
976 /// Returns profile summary metadata. When IsCS is true, use the context
977 /// sensitive profile summary.
978 Metadata *getProfileSummary(bool IsCS) const;
979 /// @}
980
981 /// Returns whether semantic interposition is to be respected.
982 bool getSemanticInterposition() const;
983
984 /// Set whether semantic interposition is to be respected.
985 void setSemanticInterposition(bool);
986
987 /// Returns true if PLT should be avoided for RTLib calls.
988 bool getRtLibUseGOT() const;
989
990 /// Set that PLT should be avoid for RTLib calls.
991 void setRtLibUseGOT();
992
993 /// Get/set whether referencing global variables can use direct access
994 /// relocations on ELF targets.
995 bool getDirectAccessExternalData() const;
996 void setDirectAccessExternalData(bool Value);
997
998 /// Get/set whether synthesized functions should get the uwtable attribute.
999 UWTableKind getUwtable() const;
1000 void setUwtable(UWTableKind Kind);
1001
1002 /// Get/set whether synthesized functions should get the "frame-pointer"
1003 /// attribute.
1004 FramePointerKind getFramePointer() const;
1005 void setFramePointer(FramePointerKind Kind);
1006
1007 /// Get/set what kind of stack protector guard to use.
1008 StringRef getStackProtectorGuard() const;
1009 void setStackProtectorGuard(StringRef Kind);
1010
1011 /// Get/set which register to use as the stack protector guard register. The
1012 /// empty string is equivalent to "global". Other values may be "tls" or
1013 /// "sysreg".
1014 StringRef getStackProtectorGuardReg() const;
1015 void setStackProtectorGuardReg(StringRef Reg);
1016
1017 /// Get/set a symbol to use as the stack protector guard.
1018 StringRef getStackProtectorGuardSymbol() const;
1019 void setStackProtectorGuardSymbol(StringRef Symbol);
1020
1021 /// Get/set what offset from the stack protector to use.
1022 int getStackProtectorGuardOffset() const;
1023 void setStackProtectorGuardOffset(int Offset);
1024
1025 /// Get/set the stack alignment overridden from the default.
1026 unsigned getOverrideStackAlignment() const;
1027 void setOverrideStackAlignment(unsigned Align);
1028
1029 unsigned getMaxTLSAlignment() const;
1030
1031 /// @name Utility functions for querying and setting the build SDK version
1032 /// @{
1033
1034 /// Attach a build SDK version metadata to this module.
1035 void setSDKVersion(const VersionTuple &V);
1036
1037 /// Get the build SDK version metadata.
1038 ///
1039 /// An empty version is returned if no such metadata is attached.
1040 VersionTuple getSDKVersion() const;
1041 /// @}
1042
1043 /// Take ownership of the given memory buffer.
1044 void setOwnedMemoryBuffer(std::unique_ptr<MemoryBuffer> MB);
1045
1046 /// Set the partial sample profile ratio in the profile summary module flag,
1047 /// if applicable.
1048 void setPartialSampleProfileRatio(const ModuleSummaryIndex &Index);
1049
1050 /// Get the target variant triple which is a string describing a variant of
1051 /// the target host platform. For example, Mac Catalyst can be a variant
1052 /// target triple for a macOS target.
1053 /// @returns a string containing the target variant triple.
1054 StringRef getDarwinTargetVariantTriple() const;
1055
1056 /// Set the target variant triple which is a string describing a variant of
1057 /// the target host platform.
1058 void setDarwinTargetVariantTriple(StringRef T);
1059
1060 /// Get the target variant version build SDK version metadata.
1061 ///
1062 /// An empty version is returned if no such metadata is attached.
1063 VersionTuple getDarwinTargetVariantSDKVersion() const;
1064
1065 /// Set the target variant version build SDK version metadata.
1066 void setDarwinTargetVariantSDKVersion(VersionTuple Version);
1067};
1068
1069/// Given "llvm.used" or "llvm.compiler.used" as a global name, collect the
1070/// initializer elements of that global in a SmallVector and return the global
1071/// itself.
1072GlobalVariable *collectUsedGlobalVariables(const Module &M,
1073 SmallVectorImpl<GlobalValue *> &Vec,
1074 bool CompilerUsed);
1075
1076/// An raw_ostream inserter for modules.
1078 M.print(O, nullptr);
1079 return O;
1080}
1081
1082// Create wrappers for C Binding types (see CBindingWrapping.h).
1084
1085/* LLVMModuleProviderRef exists for historical reasons, but now just holds a
1086 * Module.
1087 */
1089 return reinterpret_cast<Module*>(MP);
1090}
1091
1092} // end namespace llvm
1093
1094#endif // LLVM_IR_MODULE_H
aarch64 promote const
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
This file defines the StringMap class.
always inline
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)
#define LLVM_EXTERNAL_VISIBILITY
Definition: Compiler.h:135
return RetTy
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::string Name
std::optional< std::vector< StOtherPiece > > Other
Definition: ELFYAML.cpp:1293
uint64_t Offset
Definition: ELF_riscv.cpp:478
static Function * getFunction(Constant *C)
Definition: Evaluator.cpp:236
This file contains the declaration of the GlobalIFunc class, which represents a single indirect funct...
#define F(x, y, z)
Definition: MD5.cpp:55
#define I(x, y, z)
Definition: MD5.cpp:58
Machine Check Debug Module
unsigned Reg
static Constant * getOrInsertGlobal(Module &M, StringRef Name, Type *Ty)
This file contains the declarations for metadata subclasses.
#define T
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.
raw_pwrite_stream & OS
static GlobalVariable * getGlobalVariable(Module &M, Type *Ty, WebAssemblyTargetMachine &TM, const char *Name)
This is an important base class in LLVM.
Definition: Constant.h:41
A parsed version of the target data layout string in and methods for querying it.
Definition: DataLayout.h:110
Lightweight error class with error context and mandatory checking.
Definition: Error.h:160
A handy container for a FunctionType+Callee-pointer pair, which can be passed around as a single enti...
Definition: DerivedTypes.h:168
Class to represent function types.
Definition: DerivedTypes.h:103
This is an important class for using LLVM in a threaded context.
Definition: LLVMContext.h:67
Metadata node.
Definition: Metadata.h:1067
A single uniqued string.
Definition: Metadata.h:720
Root of the metadata hierarchy.
Definition: Metadata.h:62
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.
Definition: Module.h:814
debug_compile_units_iterator & operator++()
Definition: Module.h:832
bool operator==(const debug_compile_units_iterator &I) const
Definition: Module.h:844
debug_compile_units_iterator operator++(int)
Definition: Module.h:838
std::input_iterator_tag iterator_category
Definition: Module.h:821
debug_compile_units_iterator(NamedMDNode *CUs, unsigned Idx)
Definition: Module.h:827
bool operator!=(const debug_compile_units_iterator &I) const
Definition: Module.h:848
A Module instance is used to store all the information related to an LLVM module.
Definition: Module.h:65
global_iterator global_begin()
Definition: Module.h:694
void removeIFunc(GlobalIFunc *IFunc)
Detach IFunc from the list but don't delete it.
Definition: Module.h:630
const_global_iterator global_begin() const
Definition: Module.h:695
const_iterator begin() const
Definition: Module.h:713
ifunc_iterator ifunc_begin()
Definition: Module.h:752
void eraseNamedMDNode(NamedMDNode *MDNode)
Remove MDNode from the list and delete it.
Definition: Module.h:641
const std::string & getModuleInlineAsm() const
Get any module-scope inline assembly blocks.
Definition: Module.h:305
ModFlagBehavior
This enumeration defines the supported behaviors of module flags.
Definition: Module.h:115
LLVMContext & getContext() const
Get the global data context.
Definition: Module.h:301
void insertIFunc(GlobalIFunc *IFunc)
Insert IFunc at the end of the alias list and take ownership.
Definition: Module.h:634
iterator_range< const_alias_iterator > aliases() const
Definition: Module.h:744
void setModuleInlineAsm(StringRef Asm)
Set the module-scope inline assembly blocks.
Definition: Module.h:344
const ComdatSymTabType & getComdatSymbolTable() const
Get the Module's symbol table for COMDATs (constant).
Definition: Module.h:686
bool IsNewDbgInfoFormat
Is this Module using intrinsics to record the position of debugging information, or non-intrinsic rec...
Definition: Module.h:219
global_iterator global_end()
Definition: Module.h:696
GlobalVariable * getNamedGlobal(StringRef Name)
Definition: Module.h:464
NamedMDListType::iterator named_metadata_iterator
The named metadata iterators.
Definition: Module.h:110
size_t alias_size() const
Definition: Module.h:738
const_global_iterator global_end() const
Definition: Module.h:697
bool global_empty() const
Definition: Module.h:699
iterator begin()
Definition: Module.h:712
void convertToNewDbgValues()
Definition: Module.h:227
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.
Definition: Module.h:412
const_ifunc_iterator ifunc_end() const
Definition: Module.h:755
void convertFromNewDbgValues()
Definition: Module.h:235
iterator_range< ifunc_iterator > ifuncs()
Definition: Module.h:759
bool named_metadata_empty() const
Definition: Module.h:804
ValueSymbolTable & getValueSymbolTable()
Get the Module's symbol table of global variable and function identifiers.
Definition: Module.h:683
NamedMDListType::const_iterator const_named_metadata_iterator
The named metadata constant iterators.
Definition: Module.h:112
const_named_metadata_iterator named_metadata_begin() const
Definition: Module.h:794
size_t global_size() const
Definition: Module.h:698
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...
Definition: Module.h:869
iterator_range< iterator > functions()
Definition: Module.h:723
StringRef getName() const
Get a short "name" for the module.
Definition: Module.h:284
GVMaterializer * getMaterializer() const
Retrieves the GVMaterializer, if any, for this Module.
Definition: Module.h:567
const std::string & getSourceFileName() const
Get the module's original source file name.
Definition: Module.h:278
IFuncListType::iterator ifunc_iterator
The Global IFunc iterators.
Definition: Module.h:105
const_alias_iterator alias_end() const
Definition: Module.h:737
void removeAlias(GlobalAlias *Alias)
Detach Alias from the list but don't delete it.
Definition: Module.h:621
iterator_range< named_metadata_iterator > named_metadata()
Definition: Module.h:806
named_metadata_iterator named_metadata_begin()
Definition: Module.h:793
ifunc_iterator ifunc_end()
Definition: Module.h:754
GlobalListType::const_iterator const_global_iterator
The Global Variable constant iterator.
Definition: Module.h:87
iterator_range< alias_iterator > aliases()
Definition: Module.h:741
const std::string & getTargetTriple() const
Get the target triple which is a string describing the target host.
Definition: Module.h:297
void insertGlobalVariable(GlobalListType::iterator Where, GlobalVariable *GV)
Insert global variable GV into the global variable list before Where and take ownership.
Definition: Module.h:590
alias_iterator alias_end()
Definition: Module.h:736
const_alias_iterator alias_begin() const
Definition: Module.h:735
const_reverse_iterator rbegin() const
Definition: Module.h:717
alias_iterator alias_begin()
Definition: Module.h:734
reverse_iterator rend()
Definition: Module.h:718
FunctionListType::iterator iterator
The Function iterators.
Definition: Module.h:90
GlobalVariable * getGlobalVariable(StringRef Name, bool AllowInternal=false)
Definition: Module.h:452
void eraseIFunc(GlobalIFunc *IFunc)
Remove IFunc from the list and delete it.
Definition: Module.h:632
bool shouldEmitInstrCountChangedRemark()
Return true if size-info optimization remark is enabled, false otherwise.
Definition: Module.h:320
GlobalListType::iterator global_iterator
The Global Variable iterator.
Definition: Module.h:85
size_t size() const
Definition: Module.h:720
void setNewDbgInfoFormatFlag(bool NewFlag)
Definition: Module.h:248
FunctionListType::const_reverse_iterator const_reverse_iterator
The Function constant reverse iterator.
Definition: Module.h:97
bool alias_empty() const
Definition: Module.h:739
FunctionCallee getOrInsertFunction(StringRef Name, AttributeList AttributeList, FunctionType *Invalid, ArgsTy... Args)=delete
iterator_range< global_iterator > globals()
Definition: Module.h:701
const_reverse_iterator rend() const
Definition: Module.h:719
iterator_range< const_named_metadata_iterator > named_metadata() const
Definition: Module.h:809
IFuncListType::const_iterator const_ifunc_iterator
The Global IFunc constant iterator.
Definition: Module.h:107
size_t ifunc_size() const
Definition: Module.h:756
FunctionListType & getFunctionList()
Get the Module's list of functions.
Definition: Module.h:615
void eraseAlias(GlobalAlias *Alias)
Remove Alias from the list and delete it.
Definition: Module.h:623
const std::string & getModuleIdentifier() const
Get the module identifier which is, essentially, the name of the module.
Definition: Module.h:267
void eraseGlobalVariable(GlobalVariable *GV)
Remove global variable GV from the list and delete it.
Definition: Module.h:582
reverse_iterator rbegin()
Definition: Module.h:716
FunctionCallee getOrInsertFunction(StringRef Name, Type *RetTy, ArgsTy... Args)
Same as above, but without the attributes.
Definition: Module.h:423
void insertNamedMDNode(NamedMDNode *MDNode)
Insert MDNode at the end of the alias list and take ownership.
Definition: Module.h:643
const_named_metadata_iterator named_metadata_end() const
Definition: Module.h:799
bool empty() const
Definition: Module.h:721
void removeNamedMDNode(NamedMDNode *MDNode)
Detach MDNode from the list but don't delete it.
Definition: Module.h:639
AliasListType::iterator alias_iterator
The Global Alias iterators.
Definition: Module.h:100
iterator end()
Definition: Module.h:714
GlobalVariable * getGlobalVariable(StringRef Name) const
Look up the specified global variable in the module symbol table.
Definition: Module.h:446
void insertGlobalVariable(GlobalVariable *GV)
Insert global variable GV at the end of the global variable list and take ownership.
Definition: Module.h:585
const ValueSymbolTable & getValueSymbolTable() const
Get the symbol table of global variable and function identifiers.
Definition: Module.h:681
size_t named_metadata_size() const
Definition: Module.h:803
named_metadata_iterator named_metadata_end()
Definition: Module.h:798
bool isMaterialized() const
Definition: Module.h:568
const GlobalVariable * getNamedGlobal(StringRef Name) const
Return the global variable in the module with the specified name, of arbitrary type.
Definition: Module.h:461
AliasListType::const_iterator const_alias_iterator
The Global Alias constant iterator.
Definition: Module.h:102
ComdatSymTabType & getComdatSymbolTable()
Get the Module's symbol table for COMDATs.
Definition: Module.h:688
FunctionListType::reverse_iterator reverse_iterator
The Function reverse iterator.
Definition: Module.h:95
const DataLayout & getDataLayout() const
Get the data layout for the module's target platform.
Definition: Module.h:293
iterator_range< const_iterator > functions() const
Definition: Module.h:726
void setIsNewDbgInfoFormat(bool UseNewFormat)
Definition: Module.h:242
iterator_range< const_global_iterator > globals() const
Definition: Module.h:704
void setModuleIdentifier(StringRef ID)
Set the module identifier.
Definition: Module.h:330
iterator_range< const_ifunc_iterator > ifuncs() const
Definition: Module.h:762
const_iterator end() const
Definition: Module.h:715
void setSourceFileName(StringRef Name)
Set the module's original source file name.
Definition: Module.h:333
const_ifunc_iterator ifunc_begin() const
Definition: Module.h:753
const std::string & getDataLayoutStr() const
Get the data layout string for the module's target platform.
Definition: Module.h:288
static FunctionListType Module::* getSublistAccess(Function *)
Definition: Module.h:616
void appendModuleInlineAsm(StringRef Asm)
Append to the module-scope inline assembly blocks.
Definition: Module.h:352
FunctionListType::const_iterator const_iterator
The Function constant iterator.
Definition: Module.h:92
void insertAlias(GlobalAlias *Alias)
Insert Alias at the end of the alias list and take ownership.
Definition: Module.h:625
debug_compile_units_iterator debug_compile_units_begin() const
Definition: Module.h:856
void setTargetTriple(StringRef T)
Set the target triple.
Definition: Module.h:340
bool ifunc_empty() const
Definition: Module.h:757
void removeGlobalVariable(GlobalVariable *GV)
Detach global variable GV from the list but don't delete it.
Definition: Module.h:580
debug_compile_units_iterator debug_compile_units_end() const
Definition: Module.h:861
A tuple of MDNodes.
Definition: Metadata.h:1729
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Definition: SmallVector.h:586
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:1209
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:50
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition: Twine.h:81
The instances of the Type class are immutable: once they are created, they are never changed.
Definition: Type.h:45
This class provides a symbol table of name/value pairs.
LLVM Value Representation.
Definition: Value.h:74
Represents a version number in the form major[.minor[.subminor[.build]]].
Definition: VersionTuple.h:29
Iterator wrapper that concatenates sequences together.
Definition: STLExtras.h:1023
An efficient, type-erasing, non-owning reference to a callable.
base_list_type::const_reverse_iterator const_reverse_iterator
Definition: ilist.h:125
base_list_type::reverse_iterator reverse_iterator
Definition: ilist.h:123
base_list_type::const_iterator const_iterator
Definition: ilist.h:122
base_list_type::iterator iterator
Definition: ilist.h:121
An intrusive list with ownership and callbacks specified/controlled by ilist_traits,...
Definition: ilist.h:328
A range adaptor for a pair of iterators.
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:52
struct LLVMOpaqueModule * LLVMModuleRef
The top-level container for all other LLVM Intermediate Representation (IR) objects.
Definition: Types.h:61
struct LLVMOpaqueModuleProvider * LLVMModuleProviderRef
Interface used to provide a module to JIT or interpreter.
Definition: Types.h:124
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.
Definition: AddressRanges.h:18
void dump(const SparseBitVector< ElementSize > &LHS, raw_ostream &out)
FramePointerKind
Definition: CodeGen.h:90
APInt operator*(APInt a, uint64_t RHS)
Definition: APInt.h:2180
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
UWTableKind
Definition: CodeGen.h:120
Attribute unwrap(LLVMAttributeRef Attr)
Definition: Attributes.h:320
raw_ostream & operator<<(raw_ostream &OS, const APFixedPoint &FX)
Definition: APFixedPoint.h:293
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 ...
Definition: Module.cpp:854
This struct is a compact representation of a valid (non-zero power of two) alignment.
Definition: Alignment.h:39
Description of the encoding of one expression Op.
ModFlagBehavior Behavior
Definition: Module.h:167
ModuleFlagEntry(ModFlagBehavior B, MDString *K, Metadata *V)
Definition: Module.h:171