LLVM  9.0.0svn
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/Optional.h"
19 #include "llvm/ADT/STLExtras.h"
20 #include "llvm/ADT/StringMap.h"
21 #include "llvm/ADT/StringRef.h"
23 #include "llvm/IR/Attributes.h"
24 #include "llvm/IR/Comdat.h"
25 #include "llvm/IR/DataLayout.h"
26 #include "llvm/IR/Function.h"
27 #include "llvm/IR/GlobalAlias.h"
28 #include "llvm/IR/GlobalIFunc.h"
29 #include "llvm/IR/GlobalVariable.h"
30 #include "llvm/IR/Metadata.h"
33 #include "llvm/Support/CodeGen.h"
34 #include <cstddef>
35 #include <cstdint>
36 #include <iterator>
37 #include <memory>
38 #include <string>
39 #include <vector>
40 
41 namespace llvm {
42 
43 class Error;
44 class FunctionType;
45 class GVMaterializer;
46 class LLVMContext;
47 class MemoryBuffer;
48 class RandomNumberGenerator;
49 template <class PtrType> class SmallPtrSetImpl;
50 class StructType;
51 class VersionTuple;
52 
53 /// A Module instance is used to store all the information related to an
54 /// LLVM module. Modules are the top level container of all other LLVM
55 /// Intermediate Representation (IR) objects. Each module directly contains a
56 /// list of globals variables, a list of functions, a list of libraries (or
57 /// other modules) this module depends on, a symbol table, and various data
58 /// about the target's characteristics.
59 ///
60 /// A module maintains a GlobalValRefMap object that is used to hold all
61 /// constant references to global variables in the module. When a global
62 /// variable is destroyed, it should have no entries in the GlobalValueRefMap.
63 /// The main container class for the LLVM Intermediate Representation.
64 class Module {
65 /// @name Types And Enumerations
66 /// @{
67 public:
68  /// The type for the list of global variables.
70  /// The type for the list of functions.
72  /// The type for the list of aliases.
74  /// The type for the list of ifuncs.
76  /// The type for the list of named metadata.
78  /// The type of the comdat "symbol" table.
80 
81  /// The Global Variable iterator.
83  /// The Global Variable constant iterator.
85 
86  /// The Function iterators.
88  /// The Function constant iterator
90 
91  /// The Function reverse iterator.
93  /// The Function constant reverse iterator.
95 
96  /// The Global Alias iterators.
98  /// The Global Alias constant iterator
100 
101  /// The Global IFunc iterators.
103  /// The Global IFunc constant iterator
105 
106  /// The named metadata iterators.
108  /// The named metadata constant iterators.
110 
111  /// This enumeration defines the supported behaviors of module flags.
113  /// Emits an error if two values disagree, otherwise the resulting value is
114  /// that of the operands.
115  Error = 1,
116 
117  /// Emits a warning if two values disagree. The result value will be the
118  /// operand for the flag from the first module being linked.
119  Warning = 2,
120 
121  /// Adds a requirement that another module flag be present and have a
122  /// specified value after linking is performed. The value must be a metadata
123  /// pair, where the first element of the pair is the ID of the module flag
124  /// to be restricted, and the second element of the pair is the value the
125  /// module flag should be restricted to. This behavior can be used to
126  /// restrict the allowable results (via triggering of an error) of linking
127  /// IDs with the **Override** behavior.
128  Require = 3,
129 
130  /// Uses the specified value, regardless of the behavior or value of the
131  /// other module. If both modules specify **Override**, but the values
132  /// differ, an error will be emitted.
133  Override = 4,
134 
135  /// Appends the two values, which are required to be metadata nodes.
136  Append = 5,
137 
138  /// Appends the two values, which are required to be metadata
139  /// nodes. However, duplicate entries in the second list are dropped
140  /// during the append operation.
142 
143  /// Takes the max of the two values, which are required to be integers.
144  Max = 7,
145 
146  // Markers:
149  };
150 
151  /// Checks if Metadata represents a valid ModFlagBehavior, and stores the
152  /// converted result in MFB.
153  static bool isValidModFlagBehavior(Metadata *MD, ModFlagBehavior &MFB);
154 
159 
161  : Behavior(B), Key(K), Val(V) {}
162  };
163 
164 /// @}
165 /// @name Member Variables
166 /// @{
167 private:
168  LLVMContext &Context; ///< The LLVMContext from which types and
169  ///< constants are allocated.
170  GlobalListType GlobalList; ///< The Global Variables in the module
171  FunctionListType FunctionList; ///< The Functions in the module
172  AliasListType AliasList; ///< The Aliases in the module
173  IFuncListType IFuncList; ///< The IFuncs in the module
174  NamedMDListType NamedMDList; ///< The named metadata in the module
175  std::string GlobalScopeAsm; ///< Inline Asm at global scope.
176  ValueSymbolTable *ValSymTab; ///< Symbol table for values
177  ComdatSymTabType ComdatSymTab; ///< Symbol table for COMDATs
178  std::unique_ptr<MemoryBuffer>
179  OwnedMemoryBuffer; ///< Memory buffer directly owned by this
180  ///< module, for legacy clients only.
181  std::unique_ptr<GVMaterializer>
182  Materializer; ///< Used to materialize GlobalValues
183  std::string ModuleID; ///< Human readable identifier for the module
184  std::string SourceFileName; ///< Original source file name for module,
185  ///< recorded in bitcode.
186  std::string TargetTriple; ///< Platform target triple Module compiled on
187  ///< Format: (arch)(sub)-(vendor)-(sys0-(abi)
188  void *NamedMDSymTab; ///< NamedMDNode names.
189  DataLayout DL; ///< DataLayout associated with the module
190 
191  friend class Constant;
192 
193 /// @}
194 /// @name Constructors
195 /// @{
196 public:
197  /// The Module constructor. Note that there is no default constructor. You
198  /// must provide a name for the module upon construction.
199  explicit Module(StringRef ModuleID, LLVMContext& C);
200  /// The module destructor. This will dropAllReferences.
201  ~Module();
202 
203 /// @}
204 /// @name Module Level Accessors
205 /// @{
206 
207  /// Get the module identifier which is, essentially, the name of the module.
208  /// @returns the module identifier as a string
209  const std::string &getModuleIdentifier() const { return ModuleID; }
210 
211  /// Returns the number of non-debug IR instructions in the module.
212  /// This is equivalent to the sum of the IR instruction counts of each
213  /// function contained in the module.
214  unsigned getInstructionCount();
215 
216  /// Get the module's original source file name. When compiling from
217  /// bitcode, this is taken from a bitcode record where it was recorded.
218  /// For other compiles it is the same as the ModuleID, which would
219  /// contain the source file name.
220  const std::string &getSourceFileName() const { return SourceFileName; }
221 
222  /// Get a short "name" for the module.
223  ///
224  /// This is useful for debugging or logging. It is essentially a convenience
225  /// wrapper around getModuleIdentifier().
226  StringRef getName() const { return ModuleID; }
227 
228  /// Get the data layout string for the module's target platform. This is
229  /// equivalent to getDataLayout()->getStringRepresentation().
230  const std::string &getDataLayoutStr() const {
231  return DL.getStringRepresentation();
232  }
233 
234  /// Get the data layout for the module's target platform.
235  const DataLayout &getDataLayout() const;
236 
237  /// Get the target triple which is a string describing the target host.
238  /// @returns a string containing the target triple.
239  const std::string &getTargetTriple() const { return TargetTriple; }
240 
241  /// Get the global data context.
242  /// @returns LLVMContext - a container for LLVM's global information
243  LLVMContext &getContext() const { return Context; }
244 
245  /// Get any module-scope inline assembly blocks.
246  /// @returns a string containing the module-scope inline assembly blocks.
247  const std::string &getModuleInlineAsm() const { return GlobalScopeAsm; }
248 
249  /// Get a RandomNumberGenerator salted for use with this module. The
250  /// RNG can be seeded via -rng-seed=<uint64> and is salted with the
251  /// ModuleID and the provided pass salt. The returned RNG should not
252  /// be shared across threads or passes.
253  ///
254  /// A unique RNG per pass ensures a reproducible random stream even
255  /// when other randomness consuming passes are added or removed. In
256  /// addition, the random stream will be reproducible across LLVM
257  /// versions when the pass does not change.
258  std::unique_ptr<RandomNumberGenerator> createRNG(const Pass* P) const;
259 
260  /// Return true if size-info optimization remark is enabled, false
261  /// otherwise.
264  "size-info");
265  }
266 
267  /// @}
268  /// @name Module Level Mutators
269  /// @{
270 
271  /// Set the module identifier.
272  void setModuleIdentifier(StringRef ID) { ModuleID = ID; }
273 
274  /// Set the module's original source file name.
275  void setSourceFileName(StringRef Name) { SourceFileName = Name; }
276 
277  /// Set the data layout
278  void setDataLayout(StringRef Desc);
279  void setDataLayout(const DataLayout &Other);
280 
281  /// Set the target triple.
282  void setTargetTriple(StringRef T) { TargetTriple = T; }
283 
284  /// Set the module-scope inline assembly blocks.
285  /// A trailing newline is added if the input doesn't have one.
287  GlobalScopeAsm = Asm;
288  if (!GlobalScopeAsm.empty() && GlobalScopeAsm.back() != '\n')
289  GlobalScopeAsm += '\n';
290  }
291 
292  /// Append to the module-scope inline assembly blocks.
293  /// A trailing newline is added if the input doesn't have one.
295  GlobalScopeAsm += Asm;
296  if (!GlobalScopeAsm.empty() && GlobalScopeAsm.back() != '\n')
297  GlobalScopeAsm += '\n';
298  }
299 
300 /// @}
301 /// @name Generic Value Accessors
302 /// @{
303 
304  /// Return the global value in the module with the specified name, of
305  /// arbitrary type. This method returns null if a global with the specified
306  /// name is not found.
308 
309  /// Return a unique non-zero ID for the specified metadata kind. This ID is
310  /// uniqued across modules in the current LLVMContext.
311  unsigned getMDKindID(StringRef Name) const;
312 
313  /// Populate client supplied SmallVector with the name for custom metadata IDs
314  /// registered in this LLVMContext.
315  void getMDKindNames(SmallVectorImpl<StringRef> &Result) const;
316 
317  /// Populate client supplied SmallVector with the bundle tags registered in
318  /// this LLVMContext. The bundle tags are ordered by increasing bundle IDs.
319  /// \see LLVMContext::getOperandBundleTagID
321 
322  /// Return the type with the specified name, or null if there is none by that
323  /// name.
324  StructType *getTypeByName(StringRef Name) const;
325 
326  std::vector<StructType *> getIdentifiedStructTypes() const;
327 
328 /// @}
329 /// @name Function Accessors
330 /// @{
331 
332  /// Look up the specified function in the module symbol table. Four
333  /// possibilities:
334  /// 1. If it does not exist, add a prototype for the function and return it.
335  /// 2. Otherwise, if the existing function has the correct prototype, return
336  /// the existing function.
337  /// 3. Finally, the function exists but has the wrong prototype: return the
338  /// function with a constantexpr cast to the right prototype.
339  ///
340  /// In all cases, the returned value is a FunctionCallee wrapper around the
341  /// 'FunctionType *T' passed in, as well as a 'Value*' either of the Function or
342  /// the bitcast to the function.
345 
347 
348  /// Look up the specified function in the module symbol table. If it does not
349  /// exist, add a prototype for the function and return it. This function
350  /// guarantees to return a constant of pointer to the specified function type
351  /// or a ConstantExpr BitCast of that type if the named function has a
352  /// different type. This version of the method takes a list of
353  /// function arguments, which makes it easier for clients to use.
354  template <typename... ArgsTy>
356  AttributeList AttributeList, Type *RetTy,
357  ArgsTy... Args) {
358  SmallVector<Type*, sizeof...(ArgsTy)> ArgTys{Args...};
359  return getOrInsertFunction(Name,
360  FunctionType::get(RetTy, ArgTys, false),
361  AttributeList);
362  }
363 
364  /// Same as above, but without the attributes.
365  template <typename... ArgsTy>
367  ArgsTy... Args) {
368  return getOrInsertFunction(Name, AttributeList{}, RetTy, Args...);
369  }
370 
371  // Avoid an incorrect ordering that'd otherwise compile incorrectly.
372  template <typename... ArgsTy>
374  getOrInsertFunction(StringRef Name, AttributeList AttributeList,
375  FunctionType *Invalid, ArgsTy... Args) = delete;
376 
377  /// Look up the specified function in the module symbol table. If it does not
378  /// exist, return null.
379  Function *getFunction(StringRef Name) const;
380 
381 /// @}
382 /// @name Global Variable Accessors
383 /// @{
384 
385  /// Look up the specified global variable in the module symbol table. If it
386  /// does not exist, return null. If AllowInternal is set to true, this
387  /// function will return types that have InternalLinkage. By default, these
388  /// types are not returned.
390  return getGlobalVariable(Name, false);
391  }
392 
393  GlobalVariable *getGlobalVariable(StringRef Name, bool AllowInternal) const;
394 
396  bool AllowInternal = false) {
397  return static_cast<const Module *>(this)->getGlobalVariable(Name,
398  AllowInternal);
399  }
400 
401  /// Return the global variable in the module with the specified name, of
402  /// arbitrary type. This method returns null if a global with the specified
403  /// name is not found.
405  return getGlobalVariable(Name, true);
406  }
408  return const_cast<GlobalVariable *>(
409  static_cast<const Module *>(this)->getNamedGlobal(Name));
410  }
411 
412  /// Look up the specified global in the module symbol table.
413  /// If it does not exist, invoke a callback to create a declaration of the
414  /// global and return it. The global is constantexpr casted to the expected
415  /// type if necessary.
416  Constant *
417  getOrInsertGlobal(StringRef Name, Type *Ty,
418  function_ref<GlobalVariable *()> CreateGlobalCallback);
419 
420  /// Look up the specified global in the module symbol table. If required, this
421  /// overload constructs the global variable using its constructor's defaults.
423 
424 /// @}
425 /// @name Global Alias Accessors
426 /// @{
427 
428  /// Return the global alias in the module with the specified name, of
429  /// arbitrary type. This method returns null if a global with the specified
430  /// name is not found.
431  GlobalAlias *getNamedAlias(StringRef Name) const;
432 
433 /// @}
434 /// @name Global IFunc Accessors
435 /// @{
436 
437  /// Return the global ifunc in the module with the specified name, of
438  /// arbitrary type. This method returns null if a global with the specified
439  /// name is not found.
440  GlobalIFunc *getNamedIFunc(StringRef Name) const;
441 
442 /// @}
443 /// @name Named Metadata Accessors
444 /// @{
445 
446  /// Return the first NamedMDNode in the module with the specified name. This
447  /// method returns null if a NamedMDNode with the specified name is not found.
448  NamedMDNode *getNamedMetadata(const Twine &Name) const;
449 
450  /// Return the named MDNode in the module with the specified name. This method
451  /// returns a new NamedMDNode if a NamedMDNode with the specified name is not
452  /// found.
454 
455  /// Remove the given NamedMDNode from this module and delete it.
456  void eraseNamedMetadata(NamedMDNode *NMD);
457 
458 /// @}
459 /// @name Comdat Accessors
460 /// @{
461 
462  /// Return the Comdat in the module with the specified name. It is created
463  /// if it didn't already exist.
465 
466 /// @}
467 /// @name Module Flags Accessors
468 /// @{
469 
470  /// Returns the module flags in the provided vector.
472 
473  /// Return the corresponding value if Key appears in module flags, otherwise
474  /// return null.
476 
477  /// Returns the NamedMDNode in the module that represents module-level flags.
478  /// This method returns null if there are no module-level flags.
480 
481  /// Returns the NamedMDNode in the module that represents module-level flags.
482  /// If module-level flags aren't found, it creates the named metadata that
483  /// contains them.
485 
486  /// Add a module-level flag to the module-level flags metadata. It will create
487  /// the module-level flags named metadata if it doesn't already exist.
489  void addModuleFlag(ModFlagBehavior Behavior, StringRef Key, Constant *Val);
490  void addModuleFlag(ModFlagBehavior Behavior, StringRef Key, uint32_t Val);
491  void addModuleFlag(MDNode *Node);
492 
493 /// @}
494 /// @name Materialization
495 /// @{
496 
497  /// Sets the GVMaterializer to GVM. This module must not yet have a
498  /// Materializer. To reset the materializer for a module that already has one,
499  /// call materializeAll first. Destroying this module will destroy
500  /// its materializer without materializing any more GlobalValues. Without
501  /// destroying the Module, there is no way to detach or destroy a materializer
502  /// without materializing all the GVs it controls, to avoid leaving orphan
503  /// unmaterialized GVs.
504  void setMaterializer(GVMaterializer *GVM);
505  /// Retrieves the GVMaterializer, if any, for this Module.
506  GVMaterializer *getMaterializer() const { return Materializer.get(); }
507  bool isMaterialized() const { return !getMaterializer(); }
508 
509  /// Make sure the GlobalValue is fully read.
511 
512  /// Make sure all GlobalValues in this Module are fully read and clear the
513  /// Materializer.
515 
517 
518 /// @}
519 /// @name Direct access to the globals list, functions list, and symbol table
520 /// @{
521 
522  /// Get the Module's list of global variables (constant).
523  const GlobalListType &getGlobalList() const { return GlobalList; }
524  /// Get the Module's list of global variables.
525  GlobalListType &getGlobalList() { return GlobalList; }
526 
528  return &Module::GlobalList;
529  }
530 
531  /// Get the Module's list of functions (constant).
532  const FunctionListType &getFunctionList() const { return FunctionList; }
533  /// Get the Module's list of functions.
534  FunctionListType &getFunctionList() { return FunctionList; }
536  return &Module::FunctionList;
537  }
538 
539  /// Get the Module's list of aliases (constant).
540  const AliasListType &getAliasList() const { return AliasList; }
541  /// Get the Module's list of aliases.
542  AliasListType &getAliasList() { return AliasList; }
543 
545  return &Module::AliasList;
546  }
547 
548  /// Get the Module's list of ifuncs (constant).
549  const IFuncListType &getIFuncList() const { return IFuncList; }
550  /// Get the Module's list of ifuncs.
551  IFuncListType &getIFuncList() { return IFuncList; }
552 
554  return &Module::IFuncList;
555  }
556 
557  /// Get the Module's list of named metadata (constant).
558  const NamedMDListType &getNamedMDList() const { return NamedMDList; }
559  /// Get the Module's list of named metadata.
560  NamedMDListType &getNamedMDList() { return NamedMDList; }
561 
563  return &Module::NamedMDList;
564  }
565 
566  /// Get the symbol table of global variable and function identifiers
567  const ValueSymbolTable &getValueSymbolTable() const { return *ValSymTab; }
568  /// Get the Module's symbol table of global variable and function identifiers.
569  ValueSymbolTable &getValueSymbolTable() { return *ValSymTab; }
570 
571  /// Get the Module's symbol table for COMDATs (constant).
572  const ComdatSymTabType &getComdatSymbolTable() const { return ComdatSymTab; }
573  /// Get the Module's symbol table for COMDATs.
574  ComdatSymTabType &getComdatSymbolTable() { return ComdatSymTab; }
575 
576 /// @}
577 /// @name Global Variable Iteration
578 /// @{
579 
580  global_iterator global_begin() { return GlobalList.begin(); }
581  const_global_iterator global_begin() const { return GlobalList.begin(); }
582  global_iterator global_end () { return GlobalList.end(); }
583  const_global_iterator global_end () const { return GlobalList.end(); }
584  bool global_empty() const { return GlobalList.empty(); }
585 
587  return make_range(global_begin(), global_end());
588  }
590  return make_range(global_begin(), global_end());
591  }
592 
593 /// @}
594 /// @name Function Iteration
595 /// @{
596 
597  iterator begin() { return FunctionList.begin(); }
598  const_iterator begin() const { return FunctionList.begin(); }
599  iterator end () { return FunctionList.end(); }
600  const_iterator end () const { return FunctionList.end(); }
601  reverse_iterator rbegin() { return FunctionList.rbegin(); }
602  const_reverse_iterator rbegin() const{ return FunctionList.rbegin(); }
603  reverse_iterator rend() { return FunctionList.rend(); }
604  const_reverse_iterator rend() const { return FunctionList.rend(); }
605  size_t size() const { return FunctionList.size(); }
606  bool empty() const { return FunctionList.empty(); }
607 
609  return make_range(begin(), end());
610  }
612  return make_range(begin(), end());
613  }
614 
615 /// @}
616 /// @name Alias Iteration
617 /// @{
618 
619  alias_iterator alias_begin() { return AliasList.begin(); }
620  const_alias_iterator alias_begin() const { return AliasList.begin(); }
621  alias_iterator alias_end () { return AliasList.end(); }
622  const_alias_iterator alias_end () const { return AliasList.end(); }
623  size_t alias_size () const { return AliasList.size(); }
624  bool alias_empty() const { return AliasList.empty(); }
625 
627  return make_range(alias_begin(), alias_end());
628  }
630  return make_range(alias_begin(), alias_end());
631  }
632 
633 /// @}
634 /// @name IFunc Iteration
635 /// @{
636 
637  ifunc_iterator ifunc_begin() { return IFuncList.begin(); }
638  const_ifunc_iterator ifunc_begin() const { return IFuncList.begin(); }
639  ifunc_iterator ifunc_end () { return IFuncList.end(); }
640  const_ifunc_iterator ifunc_end () const { return IFuncList.end(); }
641  size_t ifunc_size () const { return IFuncList.size(); }
642  bool ifunc_empty() const { return IFuncList.empty(); }
643 
645  return make_range(ifunc_begin(), ifunc_end());
646  }
648  return make_range(ifunc_begin(), ifunc_end());
649  }
650 
651  /// @}
652  /// @name Convenience iterators
653  /// @{
654 
655  using global_object_iterator =
660 
662  return concat<GlobalObject>(functions(), globals());
663  }
665  return concat<const GlobalObject>(functions(), globals());
666  }
667 
669  return global_objects().begin();
670  }
672 
674  return global_objects().begin();
675  }
677  return global_objects().end();
678  }
679 
680  using global_value_iterator =
686 
688  return concat<GlobalValue>(functions(), globals(), aliases(), ifuncs());
689  }
691  return concat<const GlobalValue>(functions(), globals(), aliases(),
692  ifuncs());
693  }
694 
697 
699  return global_values().begin();
700  }
702  return global_values().end();
703  }
704 
705  /// @}
706  /// @name Named Metadata Iteration
707  /// @{
708 
709  named_metadata_iterator named_metadata_begin() { return NamedMDList.begin(); }
711  return NamedMDList.begin();
712  }
713 
714  named_metadata_iterator named_metadata_end() { return NamedMDList.end(); }
716  return NamedMDList.end();
717  }
718 
719  size_t named_metadata_size() const { return NamedMDList.size(); }
720  bool named_metadata_empty() const { return NamedMDList.empty(); }
721 
724  }
727  }
728 
729  /// An iterator for DICompileUnits that skips those marked NoDebug.
731  : public std::iterator<std::input_iterator_tag, DICompileUnit *> {
732  NamedMDNode *CUs;
733  unsigned Idx;
734 
735  void SkipNoDebugCUs();
736 
737  public:
738  explicit debug_compile_units_iterator(NamedMDNode *CUs, unsigned Idx)
739  : CUs(CUs), Idx(Idx) {
740  SkipNoDebugCUs();
741  }
742 
744  ++Idx;
745  SkipNoDebugCUs();
746  return *this;
747  }
748 
751  ++Idx;
752  return T;
753  }
754 
756  return Idx == I.Idx;
757  }
758 
760  return Idx != I.Idx;
761  }
762 
763  DICompileUnit *operator*() const;
764  DICompileUnit *operator->() const;
765  };
766 
768  auto *CUs = getNamedMetadata("llvm.dbg.cu");
769  return debug_compile_units_iterator(CUs, 0);
770  }
771 
773  auto *CUs = getNamedMetadata("llvm.dbg.cu");
774  return debug_compile_units_iterator(CUs, CUs ? CUs->getNumOperands() : 0);
775  }
776 
777  /// Return an iterator for all DICompileUnits listed in this Module's
778  /// llvm.dbg.cu named metadata node and aren't explicitly marked as
779  /// NoDebug.
781  auto *CUs = getNamedMetadata("llvm.dbg.cu");
782  return make_range(
784  debug_compile_units_iterator(CUs, CUs ? CUs->getNumOperands() : 0));
785  }
786 /// @}
787 
788  /// Destroy ConstantArrays in LLVMContext if they are not used.
789  /// ConstantArrays constructed during linking can cause quadratic memory
790  /// explosion. Releasing all unused constants can cause a 20% LTO compile-time
791  /// slowdown for a large application.
792  ///
793  /// NOTE: Constants are currently owned by LLVMContext. This can then only
794  /// be called where all uses of the LLVMContext are understood.
796 
797 /// @name Utility functions for printing and dumping Module objects
798 /// @{
799 
800  /// Print the module to an output stream with an optional
801  /// AssemblyAnnotationWriter. If \c ShouldPreserveUseListOrder, then include
802  /// uselistorder directives so that use-lists can be recreated when reading
803  /// the assembly.
805  bool ShouldPreserveUseListOrder = false,
806  bool IsForDebug = false) const;
807 
808  /// Dump the module to stderr (for debugging).
809  void dump() const;
810 
811  /// This function causes all the subinstructions to "let go" of all references
812  /// that they are maintaining. This allows one to 'delete' a whole class at
813  /// a time, even though there may be circular references... first all
814  /// references are dropped, and all use counts go to zero. Then everything
815  /// is delete'd for real. Note that no operations are valid on an object
816  /// that has "dropped all references", except operator delete.
817  void dropAllReferences();
818 
819 /// @}
820 /// @name Utility functions for querying Debug information.
821 /// @{
822 
823  /// Returns the Number of Register ParametersDwarf Version by checking
824  /// module flags.
825  unsigned getNumberRegisterParameters() const;
826 
827  /// Returns the Dwarf Version by checking module flags.
828  unsigned getDwarfVersion() const;
829 
830  /// Returns the CodeView Version by checking module flags.
831  /// Returns zero if not present in module.
832  unsigned getCodeViewFlag() const;
833 
834 /// @}
835 /// @name Utility functions for querying and setting PIC level
836 /// @{
837 
838  /// Returns the PIC level (small or large model)
840 
841  /// Set the PIC level (small or large model)
843 /// @}
844 
845 /// @}
846 /// @name Utility functions for querying and setting PIE level
847 /// @{
848 
849  /// Returns the PIE level (small or large model)
851 
852  /// Set the PIE level (small or large model)
853  void setPIELevel(PIELevel::Level PL);
854 /// @}
855 
856  /// @}
857  /// @name Utility function for querying and setting code model
858  /// @{
859 
860  /// Returns the code model (tiny, small, kernel, medium or large model)
862 
863  /// Set the code model (tiny, small, kernel, medium or large)
865  /// @}
866 
867  /// @name Utility functions for querying and setting PGO summary
868  /// @{
869 
870  /// Attach profile summary metadata to this module.
871  void setProfileSummary(Metadata *M);
872 
873  /// Returns profile summary metadata
875  /// @}
876 
877  /// Returns true if PLT should be avoided for RTLib calls.
878  bool getRtLibUseGOT() const;
879 
880  /// Set that PLT should be avoid for RTLib calls.
881  void setRtLibUseGOT();
882 
883  /// @name Utility functions for querying and setting the build SDK version
884  /// @{
885 
886  /// Attach a build SDK version metadata to this module.
887  void setSDKVersion(const VersionTuple &V);
888 
889  /// Get the build SDK version metadata.
890  ///
891  /// An empty version is returned if no such metadata is attached.
892  VersionTuple getSDKVersion() const;
893  /// @}
894 
895  /// Take ownership of the given memory buffer.
896  void setOwnedMemoryBuffer(std::unique_ptr<MemoryBuffer> MB);
897 };
898 
899 /// Given "llvm.used" or "llvm.compiler.used" as a global name, collect
900 /// the initializer elements of that global in Set and return the global itself.
903  bool CompilerUsed);
904 
905 /// An raw_ostream inserter for modules.
907  M.print(O, nullptr);
908  return O;
909 }
910 
911 // Create wrappers for C Binding types (see CBindingWrapping.h).
913 
914 /* LLVMModuleProviderRef exists for historical reasons, but now just holds a
915  * Module.
916  */
918  return reinterpret_cast<Module*>(MP);
919 }
920 
921 } // end namespace llvm
922 
923 #endif // LLVM_IR_MODULE_H
Pass interface - Implemented by all &#39;passes&#39;.
Definition: Pass.h:80
uint64_t CallInst * C
debug_compile_units_iterator debug_compile_units_end() const
Definition: Module.h:772
const_alias_iterator alias_end() const
Definition: Module.h:622
A parsed version of the target data layout string in and methods for querying it. ...
Definition: DataLayout.h:110
const std::string & getTargetTriple() const
Get the target triple which is a string describing the target host.
Definition: Module.h:239
This class provides a symbol table of name/value pairs.
const_named_metadata_iterator named_metadata_begin() const
Definition: Module.h:710
llvm::Error materializeAll()
Make sure all GlobalValues in this Module are fully read and clear the Materializer.
Definition: Module.cpp:401
LLVMContext & Context
ValueSymbolTable & getValueSymbolTable()
Get the Module&#39;s symbol table of global variable and function identifiers.
Definition: Module.h:569
const_reverse_iterator rend() const
Definition: Module.h:604
Takes the max of the two values, which are required to be integers.
Definition: Module.h:144
This class represents lattice values for constants.
Definition: AllocatorList.h:23
struct LLVMOpaqueModule * LLVMModuleRef
The top-level container for all other LLVM Intermediate Representation (IR) objects.
Definition: Types.h:62
NamedMDNode * getModuleFlagsMetadata() const
Returns the NamedMDNode in the module that represents module-level flags.
Definition: Module.cpp:323
A Module instance is used to store all the information related to an LLVM module. ...
Definition: Module.h:64
amdgpu Simplify well known AMD library false FunctionCallee Value const Twine & Name
void setModuleIdentifier(StringRef ID)
Set the module identifier.
Definition: Module.h:272
A handy container for a FunctionType+Callee-pointer pair, which can be passed around as a single enti...
Definition: DerivedTypes.h:164
const ValueSymbolTable & getValueSymbolTable() const
Get the symbol table of global variable and function identifiers.
Definition: Module.h:567
This provides a very simple, boring adaptor for a begin and end iterator into a range type...
void setMaterializer(GVMaterializer *GVM)
Sets the GVMaterializer to GVM.
Definition: Module.cpp:387
const std::string & getStringRepresentation() const
Returns the string representation of the DataLayout.
Definition: DataLayout.h:228
size_t named_metadata_size() const
Definition: Module.h:719
debug_compile_units_iterator operator++(int)
Definition: Module.h:749
named_metadata_iterator named_metadata_end()
Definition: Module.h:714
This file contains the declarations for metadata subclasses.
FunctionListType::iterator iterator
The Function iterators.
Definition: Module.h:87
An efficient, type-erasing, non-owning reference to a callable.
Definition: STLExtras.h:116
const GlobalVariable * getNamedGlobal(StringRef Name) const
Return the global variable in the module with the specified name, of arbitrary type.
Definition: Module.h:404
ifunc_iterator ifunc_end()
Definition: Module.h:639
This file contains the declaration of the Comdat class, which represents a single COMDAT in LLVM...
iterator_range< const_iterator > functions() const
Definition: Module.h:611
bool global_empty() const
Definition: Module.h:584
NamedMDNode * getOrInsertNamedMetadata(StringRef Name)
Return the named MDNode in the module with the specified name.
Definition: Module.cpp:259
const_iterator begin() const
Definition: Module.h:598
void setDataLayout(StringRef Desc)
Set the data layout.
Definition: Module.cpp:363
global_object_iterator global_object_begin()
Definition: Module.h:668
debug_compile_units_iterator & operator++()
Definition: Module.h:743
const_reverse_iterator rbegin() const
Definition: Module.h:602
const std::string & getDataLayoutStr() const
Get the data layout string for the module&#39;s target platform.
Definition: Module.h:230
Optional< CodeModel::Model > getCodeModel() const
Returns the code model (tiny, small, kernel, medium or large model)
Definition: Module.cpp:516
GlobalVariable * getGlobalVariable(StringRef Name) const
Look up the specified global variable in the module symbol table.
Definition: Module.h:389
const_global_iterator global_end() const
Definition: Module.h:583
Metadata node.
Definition: Metadata.h:863
StringRef getName() const
Get a short "name" for the module.
Definition: Module.h:226
AliasListType::iterator alias_iterator
The Global Alias iterators.
Definition: Module.h:97
const GlobalListType & getGlobalList() const
Get the Module&#39;s list of global variables (constant).
Definition: Module.h:523
iterator_range< const_ifunc_iterator > ifuncs() const
Definition: Module.h:647
const_ifunc_iterator ifunc_begin() const
Definition: Module.h:638
A templated base class for SmallPtrSet which provides the typesafe interface that is common across al...
Definition: SmallPtrSet.h:343
Adds a requirement that another module flag be present and have a specified value after linking is pe...
Definition: Module.h:128
const AliasListType & getAliasList() const
Get the Module&#39;s list of aliases (constant).
Definition: Module.h:540
iterator_range< global_object_iterator > global_objects()
Definition: Module.h:661
ComdatSymTabType & getComdatSymbolTable()
Get the Module&#39;s symbol table for COMDATs.
Definition: Module.h:574
ModFlagBehavior Behavior
Definition: Module.h:156
Appends the two values, which are required to be metadata nodes.
Definition: Module.h:136
GlobalAlias * getNamedAlias(StringRef Name) const
Return the global alias in the module with the specified name, of arbitrary type. ...
Definition: Module.cpp:239
A tuple of MDNodes.
Definition: Metadata.h:1325
iterator_range< const_global_iterator > globals() const
Definition: Module.h:589
#define DEFINE_SIMPLE_CONVERSION_FUNCTIONS(ty, ref)
const DataLayout & getDataLayout() const
Get the data layout for the module&#39;s target platform.
Definition: Module.cpp:369
global_value_iterator global_value_end()
Definition: Module.h:696
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition: Twine.h:80
Attribute unwrap(LLVMAttributeRef Attr)
Definition: Attributes.h:194
void eraseNamedMetadata(NamedMDNode *NMD)
Remove the given NamedMDNode from this module and delete it.
Definition: Module.cpp:272
const ComdatSymTabType & getComdatSymbolTable() const
Get the Module&#39;s symbol table for COMDATs (constant).
Definition: Module.h:572
Class to represent struct types.
Definition: DerivedTypes.h:232
LLVMContext & getContext() const
Get the global data context.
Definition: Module.h:243
unsigned getInstructionCount()
Returns the number of non-debug IR instructions in the module.
Definition: Module.cpp:475
This file contains the simple types necessary to represent the attributes associated with functions a...
void setModuleInlineAsm(StringRef Asm)
Set the module-scope inline assembly blocks.
Definition: Module.h:286
Metadata * getProfileSummary()
Returns profile summary metadata.
Definition: Module.cpp:538
ELFYAML::ELF_STO Other
Definition: ELFYAML.cpp:810
APInt operator*(APInt a, uint64_t RHS)
Definition: APInt.h:2090
global_iterator global_begin()
Definition: Module.h:580
Class to represent function types.
Definition: DerivedTypes.h:102
reverse_iterator rend()
Definition: Module.h:603
void setRtLibUseGOT()
Set that PLT should be avoid for RTLib calls.
Definition: Module.cpp:551
NamedMDListType & getNamedMDList()
Get the Module&#39;s list of named metadata.
Definition: Module.h:560
const_iterator end() const
Definition: Module.h:600
bool empty() const
Definition: Module.h:606
bool operator==(const debug_compile_units_iterator &I) const
Definition: Module.h:755
#define T
NamedMDNode * getNamedMetadata(const Twine &Name) const
Return the first NamedMDNode in the module with the specified name.
Definition: Module.cpp:250
GlobalValue * getNamedValue(StringRef Name) const
Return the global value in the module with the specified name, of arbitrary type. ...
Definition: Module.cpp:113
debug_compile_units_iterator debug_compile_units_begin() const
Definition: Module.h:767
global_object_iterator global_object_end()
Definition: Module.h:671
iterator_range< const_alias_iterator > aliases() const
Definition: Module.h:629
void dropAllReferences()
This function causes all the subinstructions to "let go" of all references that they are maintaining...
Definition: Module.cpp:439
const_alias_iterator alias_begin() const
Definition: Module.h:620
IFuncListType & getIFuncList()
Get the Module&#39;s list of ifuncs.
Definition: Module.h:551
const std::string & getSourceFileName() const
Get the module&#39;s original source file name.
Definition: Module.h:220
unsigned getCodeViewFlag() const
Returns the CodeView Version by checking module flags.
Definition: Module.cpp:468
static AliasListType Module::* getSublistAccess(GlobalAlias *)
Definition: Module.h:544
bool alias_empty() const
Definition: Module.h:624
void getOperandBundleTags(SmallVectorImpl< StringRef > &Result) const
Populate client supplied SmallVector with the bundle tags registered in this LLVMContext.
Definition: Module.cpp:130
static IFuncListType Module::* getSublistAccess(GlobalIFunc *)
Definition: Module.h:553
#define P(N)
Module(StringRef ModuleID, LLVMContext &C)
The Module constructor.
Definition: Module.cpp:73
Emits an error if two values disagree, otherwise the resulting value is that of the operands...
Definition: Module.h:115
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
iterator_range< iterator > functions()
Definition: Module.h:608
alias_iterator alias_end()
Definition: Module.h:621
PIELevel::Level getPIELevel() const
Returns the PIE level (small or large model)
Definition: Module.cpp:502
const FunctionListType & getFunctionList() const
Get the Module&#39;s list of functions (constant).
Definition: Module.h:532
The instances of the Type class are immutable: once they are created, they are never changed...
Definition: Type.h:45
AliasListType & getAliasList()
Get the Module&#39;s list of aliases.
Definition: Module.h:542
iterator_range< const_global_object_iterator > global_objects() const
Definition: Module.h:664
This is an important class for using LLVM in a threaded context.
Definition: LLVMContext.h:68
Metadata * getModuleFlag(StringRef Key) const
Return the corresponding value if Key appears in module flags, otherwise return null.
Definition: Module.cpp:310
bool shouldEmitInstrCountChangedRemark()
Return true if size-info optimization remark is enabled, false otherwise.
Definition: Module.h:262
This is an important base class in LLVM.
Definition: Constant.h:41
ifunc_iterator ifunc_begin()
Definition: Module.h:637
iterator_range< const_global_value_iterator > global_values() const
Definition: Module.h:690
void dump() const
Dump the module to stderr (for debugging).
Definition: AsmWriter.cpp:4350
FunctionCallee getOrInsertFunction(StringRef Name, Type *RetTy, ArgsTy... Args)
Same as above, but without the attributes.
Definition: Module.h:366
static GlobalListType Module::* getSublistAccess(GlobalVariable *)
Definition: Module.h:527
amdgpu inline
ModFlagBehavior
This enumeration defines the supported behaviors of module flags.
Definition: Module.h:112
size_t alias_size() const
Definition: Module.h:623
iterator_range< named_metadata_iterator > named_metadata()
Definition: Module.h:722
static FunctionListType Module::* getSublistAccess(Function *)
Definition: Module.h:535
void addModuleFlag(ModFlagBehavior Behavior, StringRef Key, Metadata *Val)
Add a module-level flag to the module-level flags metadata.
Definition: Module.cpp:337
void setCodeModel(CodeModel::Model CL)
Set the code model (tiny, small, kernel, medium or large)
Definition: Module.cpp:526
AliasListType::const_iterator const_alias_iterator
The Global Alias constant iterator.
Definition: Module.h:99
static FunctionType * get(Type *Result, ArrayRef< Type *> Params, bool isVarArg)
This static method is the primary way of constructing a FunctionType.
Definition: Type.cpp:296
const_global_value_iterator global_value_end() const
Definition: Module.h:701
An iterator for DICompileUnits that skips those marked NoDebug.
Definition: Module.h:730
struct LLVMOpaqueModuleProvider * LLVMModuleProviderRef
Interface used to provide a module to JIT or interpreter.
Definition: Types.h:125
Comdat * getOrInsertComdat(StringRef Name)
Return the Comdat in the module with the specified name.
Definition: Module.cpp:482
const NamedMDListType & getNamedMDList() const
Get the Module&#39;s list of named metadata (constant).
Definition: Module.h:558
const std::string & getModuleIdentifier() const
Get the module identifier which is, essentially, the name of the module.
Definition: Module.h:209
unsigned getDwarfVersion() const
Returns the Dwarf Version by checking module flags.
Definition: Module.cpp:461
An intrusive list with ownership and callbacks specified/controlled by ilist_traits, only with API safe for polymorphic types.
Definition: ilist.h:388
const_global_value_iterator global_value_begin() const
Definition: Module.h:698
const IFuncListType & getIFuncList() const
Get the Module&#39;s list of ifuncs (constant).
Definition: Module.h:549
std::vector< StructType * > getIdentifiedStructTypes() const
Definition: Module.cpp:418
reverse_iterator rbegin()
Definition: Module.h:601
void print(raw_ostream &OS, AssemblyAnnotationWriter *AAW, bool ShouldPreserveUseListOrder=false, bool IsForDebug=false) const
Print the module to an output stream with an optional AssemblyAnnotationWriter.
Definition: AsmWriter.cpp:4109
global_iterator global_end()
Definition: Module.h:582
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
GlobalVariable * collectUsedGlobalVariables(const Module &M, SmallPtrSetImpl< GlobalValue *> &Set, bool CompilerUsed)
Given "llvm.used" or "llvm.compiler.used" as a global name, collect the initializer elements of that ...
Definition: Module.cpp:594
Iterator for intrusive lists based on ilist_node.
ModuleFlagEntry(ModFlagBehavior B, MDString *K, Metadata *V)
Definition: Module.h:160
GlobalListType & getGlobalList()
Get the Module&#39;s list of global variables.
Definition: Module.h:525
void dropTriviallyDeadConstantArrays()
Destroy ConstantArrays in LLVMContext if they are not used.
This is a &#39;vector&#39; (really, a variable-sized array), optimized for the case when the array is small...
Definition: SmallVector.h:839
static bool isValidModFlagBehavior(Metadata *MD, ModFlagBehavior &MFB)
Checks if Metadata represents a valid ModFlagBehavior, and stores the converted result in MFB...
Definition: Module.cpp:277
GlobalVariable * getNamedGlobal(StringRef Name)
Definition: Module.h:407
NamedMDNode * getOrInsertModuleFlagsMetadata()
Returns the NamedMDNode in the module that represents module-level flags.
Definition: Module.cpp:330
alias_iterator alias_begin()
Definition: Module.h:619
const_ifunc_iterator ifunc_end() const
Definition: Module.h:640
FunctionCallee getOrInsertFunction(StringRef Name, FunctionType *T, AttributeList AttributeList)
Look up the specified function in the module symbol table.
Definition: Module.cpp:143
size_t ifunc_size() const
Definition: Module.h:641
static NamedMDListType Module::* getSublistAccess(NamedMDNode *)
Definition: Module.h:562
Uses the specified value, regardless of the behavior or value of the other module.
Definition: Module.h:133
Function * getFunction(StringRef Name) const
Look up the specified function in the module symbol table.
Definition: Module.cpp:174
A range adaptor for a pair of iterators.
Emits a warning if two values disagree.
Definition: Module.h:119
FunctionListType & getFunctionList()
Get the Module&#39;s list of functions.
Definition: Module.h:534
bool getRtLibUseGOT() const
Returns true if PLT should be avoided for RTLib calls.
Definition: Module.cpp:546
const_global_object_iterator global_object_begin() const
Definition: Module.h:673
const_named_metadata_iterator named_metadata_end() const
Definition: Module.h:715
bool isMaterialized() const
Definition: Module.h:507
void setProfileSummary(Metadata *M)
Attach profile summary metadata to this module.
Definition: Module.cpp:534
debug_compile_units_iterator(NamedMDNode *CUs, unsigned Idx)
Definition: Module.h:738
Represents a version number in the form major[.minor[.subminor[.build]]].
Definition: VersionTuple.h:26
Constant * getOrInsertGlobal(StringRef Name, Type *Ty, function_ref< GlobalVariable *()> CreateGlobalCallback)
Look up the specified global in the module symbol table.
Definition: Module.cpp:204
virtual bool isAnalysisRemarkEnabled(StringRef PassName) const
Return true if analysis remarks are enabled, override to provide different implementation.
iterator end()
Definition: Module.h:599
Appends the two values, which are required to be metadata nodes.
Definition: Module.h:141
bool ifunc_empty() const
Definition: Module.h:642
GlobalVariable * getGlobalVariable(StringRef Name, bool AllowInternal=false)
Definition: Module.h:395
void setSourceFileName(StringRef Name)
Set the module&#39;s original source file name.
Definition: Module.h:275
size_t size() const
Definition: Module.h:605
#define I(x, y, z)
Definition: MD5.cpp:58
void setSDKVersion(const VersionTuple &V)
Attach a build SDK version metadata to this module.
Definition: Module.cpp:555
global_value_iterator global_value_begin()
Definition: Module.h:695
iterator_range< debug_compile_units_iterator > debug_compile_units() const
Return an iterator for all DICompileUnits listed in this Module&#39;s llvm.dbg.cu named metadata node and...
Definition: Module.h:780
std::unique_ptr< RandomNumberGenerator > createRNG(const Pass *P) const
Get a RandomNumberGenerator salted for use with this module.
Definition: Module.cpp:92
iterator begin()
Definition: Module.h:597
void appendModuleInlineAsm(StringRef Asm)
Append to the module-scope inline assembly blocks.
Definition: Module.h:294
llvm::Error materialize(GlobalValue *GV)
Make sure the GlobalValue is fully read.
Definition: Module.cpp:394
void setTargetTriple(StringRef T)
Set the target triple.
Definition: Module.h:282
StructType * getTypeByName(StringRef Name) const
Return the type with the specified name, or null if there is none by that name.
Definition: Type.cpp:521
~Module()
The module destructor. This will dropAllReferences.
Definition: Module.cpp:80
void setPIELevel(PIELevel::Level PL)
Set the PIE level (small or large model)
Definition: Module.cpp:512
iterator_range< ifunc_iterator > ifuncs()
Definition: Module.h:644
void setOwnedMemoryBuffer(std::unique_ptr< MemoryBuffer > MB)
Take ownership of the given memory buffer.
Definition: Module.cpp:542
raw_ostream & operator<<(raw_ostream &OS, const APInt &I)
Definition: APInt.h:2038
const std::string & getModuleInlineAsm() const
Get any module-scope inline assembly blocks.
Definition: Module.h:247
void getMDKindNames(SmallVectorImpl< StringRef > &Result) const
Populate client supplied SmallVector with the name for custom metadata IDs registered in this LLVMCon...
Definition: Module.cpp:126
const DiagnosticHandler * getDiagHandlerPtr() const
getDiagHandlerPtr - Returns const raw pointer of DiagnosticHandler set by setDiagnosticHandler.
unsigned getMDKindID(StringRef Name) const
Return a unique non-zero ID for the specified metadata kind.
Definition: Module.cpp:119
unsigned getNumberRegisterParameters() const
Returns the Number of Register ParametersDwarf Version by checking module flags.
Definition: Module.cpp:453
FunctionListType::const_iterator const_iterator
The Function constant iterator.
Definition: Module.h:89
Lightweight error class with error context and mandatory checking.
Definition: Error.h:157
bool named_metadata_empty() const
Definition: Module.h:720
GlobalListType::const_iterator const_global_iterator
The Global Variable constant iterator.
Definition: Module.h:84
const_global_iterator global_begin() const
Definition: Module.h:581
void setPICLevel(PICLevel::Level PL)
Set the PIC level (small or large model)
Definition: Module.cpp:498
This class implements an extremely fast bulk output stream that can only output to a stream...
Definition: raw_ostream.h:45
PICLevel::Level getPICLevel() const
Returns the PIC level (small or large model)
Definition: Module.cpp:488
iterator_range< global_iterator > globals()
Definition: Module.h:586
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:48
A single uniqued string.
Definition: Metadata.h:603
Iterator wrapper that concatenates sequences together.
Definition: STLExtras.h:812
VersionTuple getSDKVersion() const
Get the build SDK version metadata.
Definition: Module.cpp:569
FunctionCallee getOrInsertFunction(StringRef Name, AttributeList AttributeList, Type *RetTy, ArgsTy... Args)
Look up the specified function in the module symbol table.
Definition: Module.h:355
iterator_range< global_value_iterator > global_values()
Definition: Module.h:687
GlobalIFunc * getNamedIFunc(StringRef Name) const
Return the global ifunc in the module with the specified name, of arbitrary type. ...
Definition: Module.cpp:243
Root of the metadata hierarchy.
Definition: Metadata.h:57
GlobalListType::iterator global_iterator
The Global Variable iterator.
Definition: Module.h:82
llvm::Error materializeMetadata()
Definition: Module.cpp:408
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
bool operator!=(const debug_compile_units_iterator &I) const
Definition: Module.h:759
named_metadata_iterator named_metadata_begin()
Definition: Module.h:709
const_global_object_iterator global_object_end() const
Definition: Module.h:676
GVMaterializer * getMaterializer() const
Retrieves the GVMaterializer, if any, for this Module.
Definition: Module.h:506
iterator_range< const_named_metadata_iterator > named_metadata() const
Definition: Module.h:725
iterator_range< alias_iterator > aliases()
Definition: Module.h:626