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