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