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
201  CurrentIntrinsicIds; ///< Keep track of the current unique id count for
202  ///< the specified intrinsic basename.
204  UniquedIntrinsicNames; ///< Keep track of uniqued names of intrinsics
205  ///< based on unnamed types. The combination of
206  ///< ID and FunctionType maps to the extension that
207  ///< is used to make the intrinsic name unique.
208 
209  friend class Constant;
210 
211 /// @}
212 /// @name Constructors
213 /// @{
214 public:
215  /// The Module constructor. Note that there is no default constructor. You
216  /// must provide a name for the module upon construction.
217  explicit Module(StringRef ModuleID, LLVMContext& C);
218  /// The module destructor. This will dropAllReferences.
219  ~Module();
220 
221 /// @}
222 /// @name Module Level Accessors
223 /// @{
224 
225  /// Get the module identifier which is, essentially, the name of the module.
226  /// @returns the module identifier as a string
227  const std::string &getModuleIdentifier() const { return ModuleID; }
228 
229  /// Returns the number of non-debug IR instructions in the module.
230  /// This is equivalent to the sum of the IR instruction counts of each
231  /// function contained in the module.
232  unsigned getInstructionCount() const;
233 
234  /// Get the module's original source file name. When compiling from
235  /// bitcode, this is taken from a bitcode record where it was recorded.
236  /// For other compiles it is the same as the ModuleID, which would
237  /// contain the source file name.
238  const std::string &getSourceFileName() const { return SourceFileName; }
239 
240  /// Get a short "name" for the module.
241  ///
242  /// This is useful for debugging or logging. It is essentially a convenience
243  /// wrapper around getModuleIdentifier().
244  StringRef getName() const { return ModuleID; }
245 
246  /// Get the data layout string for the module's target platform. This is
247  /// equivalent to getDataLayout()->getStringRepresentation().
248  const std::string &getDataLayoutStr() const {
249  return DL.getStringRepresentation();
250  }
251 
252  /// Get the data layout for the module's target platform.
253  const DataLayout &getDataLayout() const;
254 
255  /// Get the target triple which is a string describing the target host.
256  /// @returns a string containing the target triple.
257  const std::string &getTargetTriple() const { return TargetTriple; }
258 
259  /// Get the global data context.
260  /// @returns LLVMContext - a container for LLVM's global information
261  LLVMContext &getContext() const { return Context; }
262 
263  /// Get any module-scope inline assembly blocks.
264  /// @returns a string containing the module-scope inline assembly blocks.
265  const std::string &getModuleInlineAsm() const { return GlobalScopeAsm; }
266 
267  /// Get a RandomNumberGenerator salted for use with this module. The
268  /// RNG can be seeded via -rng-seed=<uint64> and is salted with the
269  /// ModuleID and the provided pass salt. The returned RNG should not
270  /// be shared across threads or passes.
271  ///
272  /// A unique RNG per pass ensures a reproducible random stream even
273  /// when other randomness consuming passes are added or removed. In
274  /// addition, the random stream will be reproducible across LLVM
275  /// versions when the pass does not change.
276  std::unique_ptr<RandomNumberGenerator> createRNG(const StringRef Name) const;
277 
278  /// Return true if size-info optimization remark is enabled, false
279  /// otherwise.
282  "size-info");
283  }
284 
285  /// @}
286  /// @name Module Level Mutators
287  /// @{
288 
289  /// Set the module identifier.
290  void setModuleIdentifier(StringRef ID) { ModuleID = std::string(ID); }
291 
292  /// Set the module's original source file name.
293  void setSourceFileName(StringRef Name) { SourceFileName = std::string(Name); }
294 
295  /// Set the data layout
296  void setDataLayout(StringRef Desc);
297  void setDataLayout(const DataLayout &Other);
298 
299  /// Set the target triple.
300  void setTargetTriple(StringRef T) { TargetTriple = std::string(T); }
301 
302  /// Set the module-scope inline assembly blocks.
303  /// A trailing newline is added if the input doesn't have one.
305  GlobalScopeAsm = std::string(Asm);
306  if (!GlobalScopeAsm.empty() && GlobalScopeAsm.back() != '\n')
307  GlobalScopeAsm += '\n';
308  }
309 
310  /// Append to the module-scope inline assembly blocks.
311  /// A trailing newline is added if the input doesn't have one.
313  GlobalScopeAsm += Asm;
314  if (!GlobalScopeAsm.empty() && GlobalScopeAsm.back() != '\n')
315  GlobalScopeAsm += '\n';
316  }
317 
318 /// @}
319 /// @name Generic Value Accessors
320 /// @{
321 
322  /// Return the global value in the module with the specified name, of
323  /// arbitrary type. This method returns null if a global with the specified
324  /// name is not found.
326 
327  /// Return a unique non-zero ID for the specified metadata kind. This ID is
328  /// uniqued across modules in the current LLVMContext.
329  unsigned getMDKindID(StringRef Name) const;
330 
331  /// Populate client supplied SmallVector with the name for custom metadata IDs
332  /// registered in this LLVMContext.
333  void getMDKindNames(SmallVectorImpl<StringRef> &Result) const;
334 
335  /// Populate client supplied SmallVector with the bundle tags registered in
336  /// this LLVMContext. The bundle tags are ordered by increasing bundle IDs.
337  /// \see LLVMContext::getOperandBundleTagID
339 
340  std::vector<StructType *> getIdentifiedStructTypes() const;
341 
342  /// Return a unique name for an intrinsic whose mangling is based on an
343  /// unnamed type. The Proto represents the function prototype.
344  std::string getUniqueIntrinsicName(StringRef BaseName, Intrinsic::ID Id,
345  const FunctionType *Proto);
346 
347 /// @}
348 /// @name Function Accessors
349 /// @{
350 
351  /// Look up the specified function in the module symbol table. Four
352  /// possibilities:
353  /// 1. If it does not exist, add a prototype for the function and return it.
354  /// 2. Otherwise, if the existing function has the correct prototype, return
355  /// the existing function.
356  /// 3. Finally, the function exists but has the wrong prototype: return the
357  /// function with a constantexpr cast to the right prototype.
358  ///
359  /// In all cases, the returned value is a FunctionCallee wrapper around the
360  /// 'FunctionType *T' passed in, as well as a 'Value*' either of the Function or
361  /// the bitcast to the function.
364 
366 
367  /// Look up the specified function in the module symbol table. If it does not
368  /// exist, add a prototype for the function and return it. This function
369  /// guarantees to return a constant of pointer to the specified function type
370  /// or a ConstantExpr BitCast of that type if the named function has a
371  /// different type. This version of the method takes a list of
372  /// function arguments, which makes it easier for clients to use.
373  template <typename... ArgsTy>
376  ArgsTy... Args) {
377  SmallVector<Type*, sizeof...(ArgsTy)> ArgTys{Args...};
378  return getOrInsertFunction(Name,
379  FunctionType::get(RetTy, ArgTys, false),
380  AttributeList);
381  }
382 
383  /// Same as above, but without the attributes.
384  template <typename... ArgsTy>
386  ArgsTy... Args) {
387  return getOrInsertFunction(Name, AttributeList{}, RetTy, Args...);
388  }
389 
390  // Avoid an incorrect ordering that'd otherwise compile incorrectly.
391  template <typename... ArgsTy>
394  FunctionType *Invalid, ArgsTy... Args) = delete;
395 
396  /// Look up the specified function in the module symbol table. If it does not
397  /// exist, return null.
399 
400 /// @}
401 /// @name Global Variable Accessors
402 /// @{
403 
404  /// Look up the specified global variable in the module symbol table. If it
405  /// does not exist, return null. If AllowInternal is set to true, this
406  /// function will return types that have InternalLinkage. By default, these
407  /// types are not returned.
409  return getGlobalVariable(Name, false);
410  }
411 
412  GlobalVariable *getGlobalVariable(StringRef Name, bool AllowInternal) const;
413 
415  bool AllowInternal = false) {
416  return static_cast<const Module *>(this)->getGlobalVariable(Name,
417  AllowInternal);
418  }
419 
420  /// Return the global variable in the module with the specified name, of
421  /// arbitrary type. This method returns null if a global with the specified
422  /// name is not found.
424  return getGlobalVariable(Name, true);
425  }
427  return const_cast<GlobalVariable *>(
428  static_cast<const Module *>(this)->getNamedGlobal(Name));
429  }
430 
431  /// Look up the specified global in the module symbol table.
432  /// If it does not exist, invoke a callback to create a declaration of the
433  /// global and return it. The global is constantexpr casted to the expected
434  /// type if necessary.
435  Constant *
437  function_ref<GlobalVariable *()> CreateGlobalCallback);
438 
439  /// Look up the specified global in the module symbol table. If required, this
440  /// overload constructs the global variable using its constructor's defaults.
442 
443 /// @}
444 /// @name Global Alias Accessors
445 /// @{
446 
447  /// Return the global alias in the module with the specified name, of
448  /// arbitrary type. This method returns null if a global with the specified
449  /// name is not found.
451 
452 /// @}
453 /// @name Global IFunc Accessors
454 /// @{
455 
456  /// Return the global ifunc in the module with the specified name, of
457  /// arbitrary type. This method returns null if a global with the specified
458  /// name is not found.
460 
461 /// @}
462 /// @name Named Metadata Accessors
463 /// @{
464 
465  /// Return the first NamedMDNode in the module with the specified name. This
466  /// method returns null if a NamedMDNode with the specified name is not found.
467  NamedMDNode *getNamedMetadata(const Twine &Name) const;
468 
469  /// Return the named MDNode in the module with the specified name. This method
470  /// returns a new NamedMDNode if a NamedMDNode with the specified name is not
471  /// found.
473 
474  /// Remove the given NamedMDNode from this module and delete it.
475  void eraseNamedMetadata(NamedMDNode *NMD);
476 
477 /// @}
478 /// @name Comdat Accessors
479 /// @{
480 
481  /// Return the Comdat in the module with the specified name. It is created
482  /// if it didn't already exist.
484 
485 /// @}
486 /// @name Module Flags Accessors
487 /// @{
488 
489  /// Returns the module flags in the provided vector.
491 
492  /// Return the corresponding value if Key appears in module flags, otherwise
493  /// return null.
495 
496  /// Returns the NamedMDNode in the module that represents module-level flags.
497  /// This method returns null if there are no module-level flags.
499 
500  /// Returns the NamedMDNode in the module that represents module-level flags.
501  /// If module-level flags aren't found, it creates the named metadata that
502  /// contains them.
504 
505  /// Add a module-level flag to the module-level flags metadata. It will create
506  /// the module-level flags named metadata if it doesn't already exist.
507  void addModuleFlag(ModFlagBehavior Behavior, StringRef Key, Metadata *Val);
508  void addModuleFlag(ModFlagBehavior Behavior, StringRef Key, Constant *Val);
509  void addModuleFlag(ModFlagBehavior Behavior, StringRef Key, uint32_t Val);
510  void addModuleFlag(MDNode *Node);
511  /// Like addModuleFlag but replaces the old module flag if it already exists.
512  void setModuleFlag(ModFlagBehavior Behavior, StringRef Key, Metadata *Val);
513 
514  /// @}
515  /// @name Materialization
516  /// @{
517 
518  /// Sets the GVMaterializer to GVM. This module must not yet have a
519  /// Materializer. To reset the materializer for a module that already has one,
520  /// call materializeAll first. Destroying this module will destroy
521  /// its materializer without materializing any more GlobalValues. Without
522  /// destroying the Module, there is no way to detach or destroy a materializer
523  /// without materializing all the GVs it controls, to avoid leaving orphan
524  /// unmaterialized GVs.
525  void setMaterializer(GVMaterializer *GVM);
526  /// Retrieves the GVMaterializer, if any, for this Module.
527  GVMaterializer *getMaterializer() const { return Materializer.get(); }
528  bool isMaterialized() const { return !getMaterializer(); }
529 
530  /// Make sure the GlobalValue is fully read.
532 
533  /// Make sure all GlobalValues in this Module are fully read and clear the
534  /// Materializer.
536 
538 
539 /// @}
540 /// @name Direct access to the globals list, functions list, and symbol table
541 /// @{
542 
543  /// Get the Module's list of global variables (constant).
544  const GlobalListType &getGlobalList() const { return GlobalList; }
545  /// Get the Module's list of global variables.
546  GlobalListType &getGlobalList() { return GlobalList; }
547 
549  return &Module::GlobalList;
550  }
551 
552  /// Get the Module's list of functions (constant).
553  const FunctionListType &getFunctionList() const { return FunctionList; }
554  /// Get the Module's list of functions.
555  FunctionListType &getFunctionList() { return FunctionList; }
557  return &Module::FunctionList;
558  }
559 
560  /// Get the Module's list of aliases (constant).
561  const AliasListType &getAliasList() const { return AliasList; }
562  /// Get the Module's list of aliases.
563  AliasListType &getAliasList() { return AliasList; }
564 
566  return &Module::AliasList;
567  }
568 
569  /// Get the Module's list of ifuncs (constant).
570  const IFuncListType &getIFuncList() const { return IFuncList; }
571  /// Get the Module's list of ifuncs.
572  IFuncListType &getIFuncList() { return IFuncList; }
573 
575  return &Module::IFuncList;
576  }
577 
578  /// Get the Module's list of named metadata (constant).
579  const NamedMDListType &getNamedMDList() const { return NamedMDList; }
580  /// Get the Module's list of named metadata.
581  NamedMDListType &getNamedMDList() { return NamedMDList; }
582 
584  return &Module::NamedMDList;
585  }
586 
587  /// Get the symbol table of global variable and function identifiers
588  const ValueSymbolTable &getValueSymbolTable() const { return *ValSymTab; }
589  /// Get the Module's symbol table of global variable and function identifiers.
590  ValueSymbolTable &getValueSymbolTable() { return *ValSymTab; }
591 
592  /// Get the Module's symbol table for COMDATs (constant).
593  const ComdatSymTabType &getComdatSymbolTable() const { return ComdatSymTab; }
594  /// Get the Module's symbol table for COMDATs.
595  ComdatSymTabType &getComdatSymbolTable() { return ComdatSymTab; }
596 
597 /// @}
598 /// @name Global Variable Iteration
599 /// @{
600 
601  global_iterator global_begin() { return GlobalList.begin(); }
602  const_global_iterator global_begin() const { return GlobalList.begin(); }
603  global_iterator global_end () { return GlobalList.end(); }
604  const_global_iterator global_end () const { return GlobalList.end(); }
605  size_t global_size () const { return GlobalList.size(); }
606  bool global_empty() const { return GlobalList.empty(); }
607 
609  return make_range(global_begin(), global_end());
610  }
612  return make_range(global_begin(), global_end());
613  }
614 
615 /// @}
616 /// @name Function Iteration
617 /// @{
618 
619  iterator begin() { return FunctionList.begin(); }
620  const_iterator begin() const { return FunctionList.begin(); }
621  iterator end () { return FunctionList.end(); }
622  const_iterator end () const { return FunctionList.end(); }
623  reverse_iterator rbegin() { return FunctionList.rbegin(); }
624  const_reverse_iterator rbegin() const{ return FunctionList.rbegin(); }
625  reverse_iterator rend() { return FunctionList.rend(); }
626  const_reverse_iterator rend() const { return FunctionList.rend(); }
627  size_t size() const { return FunctionList.size(); }
628  bool empty() const { return FunctionList.empty(); }
629 
631  return make_range(begin(), end());
632  }
634  return make_range(begin(), end());
635  }
636 
637 /// @}
638 /// @name Alias Iteration
639 /// @{
640 
641  alias_iterator alias_begin() { return AliasList.begin(); }
642  const_alias_iterator alias_begin() const { return AliasList.begin(); }
643  alias_iterator alias_end () { return AliasList.end(); }
644  const_alias_iterator alias_end () const { return AliasList.end(); }
645  size_t alias_size () const { return AliasList.size(); }
646  bool alias_empty() const { return AliasList.empty(); }
647 
649  return make_range(alias_begin(), alias_end());
650  }
652  return make_range(alias_begin(), alias_end());
653  }
654 
655 /// @}
656 /// @name IFunc Iteration
657 /// @{
658 
659  ifunc_iterator ifunc_begin() { return IFuncList.begin(); }
660  const_ifunc_iterator ifunc_begin() const { return IFuncList.begin(); }
661  ifunc_iterator ifunc_end () { return IFuncList.end(); }
662  const_ifunc_iterator ifunc_end () const { return IFuncList.end(); }
663  size_t ifunc_size () const { return IFuncList.size(); }
664  bool ifunc_empty() const { return IFuncList.empty(); }
665 
667  return make_range(ifunc_begin(), ifunc_end());
668  }
670  return make_range(ifunc_begin(), ifunc_end());
671  }
672 
673  /// @}
674  /// @name Convenience iterators
675  /// @{
676 
677  using global_object_iterator =
682 
685 
686  using global_value_iterator =
692 
695 
696  /// @}
697  /// @name Named Metadata Iteration
698  /// @{
699 
700  named_metadata_iterator named_metadata_begin() { return NamedMDList.begin(); }
702  return NamedMDList.begin();
703  }
704 
705  named_metadata_iterator named_metadata_end() { return NamedMDList.end(); }
707  return NamedMDList.end();
708  }
709 
710  size_t named_metadata_size() const { return NamedMDList.size(); }
711  bool named_metadata_empty() const { return NamedMDList.empty(); }
712 
715  }
718  }
719 
720  /// An iterator for DICompileUnits that skips those marked NoDebug.
722  NamedMDNode *CUs;
723  unsigned Idx;
724 
725  void SkipNoDebugCUs();
726 
727  public:
728  using iterator_category = std::input_iterator_tag;
730  using difference_type = std::ptrdiff_t;
731  using pointer = value_type *;
733 
734  explicit debug_compile_units_iterator(NamedMDNode *CUs, unsigned Idx)
735  : CUs(CUs), Idx(Idx) {
736  SkipNoDebugCUs();
737  }
738 
740  ++Idx;
741  SkipNoDebugCUs();
742  return *this;
743  }
744 
747  ++Idx;
748  return T;
749  }
750 
752  return Idx == I.Idx;
753  }
754 
756  return Idx != I.Idx;
757  }
758 
759  DICompileUnit *operator*() const;
760  DICompileUnit *operator->() const;
761  };
762 
764  auto *CUs = getNamedMetadata("llvm.dbg.cu");
765  return debug_compile_units_iterator(CUs, 0);
766  }
767 
769  auto *CUs = getNamedMetadata("llvm.dbg.cu");
770  return debug_compile_units_iterator(CUs, CUs ? CUs->getNumOperands() : 0);
771  }
772 
773  /// Return an iterator for all DICompileUnits listed in this Module's
774  /// llvm.dbg.cu named metadata node and aren't explicitly marked as
775  /// NoDebug.
777  auto *CUs = getNamedMetadata("llvm.dbg.cu");
778  return make_range(
780  debug_compile_units_iterator(CUs, CUs ? CUs->getNumOperands() : 0));
781  }
782 /// @}
783 
784  /// Destroy ConstantArrays in LLVMContext if they are not used.
785  /// ConstantArrays constructed during linking can cause quadratic memory
786  /// explosion. Releasing all unused constants can cause a 20% LTO compile-time
787  /// slowdown for a large application.
788  ///
789  /// NOTE: Constants are currently owned by LLVMContext. This can then only
790  /// be called where all uses of the LLVMContext are understood.
792 
793 /// @name Utility functions for printing and dumping Module objects
794 /// @{
795 
796  /// Print the module to an output stream with an optional
797  /// AssemblyAnnotationWriter. If \c ShouldPreserveUseListOrder, then include
798  /// uselistorder directives so that use-lists can be recreated when reading
799  /// the assembly.
801  bool ShouldPreserveUseListOrder = false,
802  bool IsForDebug = false) const;
803 
804  /// Dump the module to stderr (for debugging).
805  void dump() const;
806 
807  /// This function causes all the subinstructions to "let go" of all references
808  /// that they are maintaining. This allows one to 'delete' a whole class at
809  /// a time, even though there may be circular references... first all
810  /// references are dropped, and all use counts go to zero. Then everything
811  /// is delete'd for real. Note that no operations are valid on an object
812  /// that has "dropped all references", except operator delete.
813  void dropAllReferences();
814 
815 /// @}
816 /// @name Utility functions for querying Debug information.
817 /// @{
818 
819  /// Returns the Number of Register ParametersDwarf Version by checking
820  /// module flags.
821  unsigned getNumberRegisterParameters() const;
822 
823  /// Returns the Dwarf Version by checking module flags.
824  unsigned getDwarfVersion() const;
825 
826  /// Returns the DWARF format by checking module flags.
827  bool isDwarf64() const;
828 
829  /// Returns the CodeView Version by checking module flags.
830  /// Returns zero if not present in module.
831  unsigned getCodeViewFlag() const;
832 
833 /// @}
834 /// @name Utility functions for querying and setting PIC level
835 /// @{
836 
837  /// Returns the PIC level (small or large model)
839 
840  /// Set the PIC level (small or large model)
842 /// @}
843 
844 /// @}
845 /// @name Utility functions for querying and setting PIE level
846 /// @{
847 
848  /// Returns the PIE level (small or large model)
850 
851  /// Set the PIE level (small or large model)
853 /// @}
854 
855  /// @}
856  /// @name Utility function for querying and setting code model
857  /// @{
858 
859  /// Returns the code model (tiny, small, kernel, medium or large model)
861 
862  /// Set the code model (tiny, small, kernel, medium or large)
864  /// @}
865 
866  /// @name Utility functions for querying and setting PGO summary
867  /// @{
868 
869  /// Attach profile summary metadata to this module.
871 
872  /// Returns profile summary metadata. When IsCS is true, use the context
873  /// sensitive profile summary.
874  Metadata *getProfileSummary(bool IsCS) const;
875  /// @}
876 
877  /// Returns whether semantic interposition is to be respected.
878  bool getSemanticInterposition() const;
879 
880  /// Set whether semantic interposition is to be respected.
881  void setSemanticInterposition(bool);
882 
883  /// Returns true if PLT should be avoided for RTLib calls.
884  bool getRtLibUseGOT() const;
885 
886  /// Set that PLT should be avoid for RTLib calls.
887  void setRtLibUseGOT();
888 
889  /// Get/set whether synthesized functions should get the uwtable attribute.
890  bool getUwtable() const;
891  void setUwtable();
892 
893  /// Get/set whether synthesized functions should get the "frame-pointer"
894  /// attribute.
897 
898  /// @name Utility functions for querying and setting the build SDK version
899  /// @{
900 
901  /// Attach a build SDK version metadata to this module.
902  void setSDKVersion(const VersionTuple &V);
903 
904  /// Get the build SDK version metadata.
905  ///
906  /// An empty version is returned if no such metadata is attached.
907  VersionTuple getSDKVersion() const;
908  /// @}
909 
910  /// Take ownership of the given memory buffer.
911  void setOwnedMemoryBuffer(std::unique_ptr<MemoryBuffer> MB);
912 
913  /// Set the partial sample profile ratio in the profile summary module flag,
914  /// if applicable.
916 };
917 
918 /// Given "llvm.used" or "llvm.compiler.used" as a global name, collect the
919 /// initializer elements of that global in a SmallVector and return the global
920 /// itself.
921 GlobalVariable *collectUsedGlobalVariables(const Module &M,
922  SmallVectorImpl<GlobalValue *> &Vec,
923  bool CompilerUsed);
924 
925 /// An raw_ostream inserter for modules.
927  M.print(O, nullptr);
928  return O;
929 }
930 
931 // Create wrappers for C Binding types (see CBindingWrapping.h).
933 
934 /* LLVMModuleProviderRef exists for historical reasons, but now just holds a
935  * Module.
936  */
938  return reinterpret_cast<Module*>(MP);
939 }
940 
941 } // end namespace llvm
942 
943 #endif // LLVM_IR_MODULE_H
llvm::Module::global_values
iterator_range< global_value_iterator > global_values()
Definition: Module.cpp:420
llvm::Module::appendModuleInlineAsm
void appendModuleInlineAsm(StringRef Asm)
Append to the module-scope inline assembly blocks.
Definition: Module.h:312
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:663
GlobalIFunc.h
llvm
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:423
llvm::Module::getModuleFlagsMetadata
NamedMDNode * getModuleFlagsMetadata() const
Returns the NamedMDNode in the module that represents module-level flags.
Definition: Module.cpp:334
llvm::Module::setFramePointer
void setFramePointer(FramePointerKind Kind)
Definition: Module.cpp:685
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:1949
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:1386
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:112
llvm::Module::getInstructionCount
unsigned getInstructionCount() const
Returns the number of non-debug IR instructions in the module.
Definition: Module.cpp:574
llvm::Module::named_metadata_empty
bool named_metadata_empty() const
Definition: Module.h:711
llvm::ProfileSummary::Kind
Kind
Definition: ProfileSummary.h:47
llvm::Module::ModuleFlagEntry::Behavior
ModFlagBehavior Behavior
Definition: Module.h:166
Metadata.h
FunctionType
Definition: ItaniumDemangle.h:643
llvm::GVMaterializer
Definition: GVMaterializer.h:28
llvm::Module::isDwarf64
bool isDwarf64() const
Returns the DWARF format by checking module flags.
Definition: Module.cpp:562
llvm::Module::ifunc_end
const_ifunc_iterator ifunc_end() const
Definition: Module.h:662
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:280
ProfileSummary.h
llvm::Module::dump
void dump() const
Dump the module to stderr (for debugging).
Definition: AsmWriter.cpp:4772
StringRef.h
llvm::Module::ifuncs
iterator_range< ifunc_iterator > ifuncs()
Definition: Module.h:666
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:734
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:567
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:663
llvm::Module::getAliasList
AliasListType & getAliasList()
Get the Module's list of aliases.
Definition: Module.h:563
llvm::GlobalVariable
Definition: GlobalVariable.h:40
llvm::Module::ifunc_end
ifunc_iterator ifunc_end()
Definition: Module.h:661
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:265
llvm::Module::begin
const_iterator begin() const
Definition: Module.h:620
llvm::Module::getUwtable
bool getUwtable() const
Get/set whether synthesized functions should get the uwtable attribute.
Definition: Module.cpp:672
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:710
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:776
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:615
llvm::AttributeList
Definition: Attributes.h:385
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:689
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:640
STLExtras.h
llvm::Module::getNamedMDList
const NamedMDListType & getNamedMDList() const
Get the Module's list of named metadata (constant).
Definition: Module.h:579
llvm::Module::debug_compile_units_iterator::difference_type
std::ptrdiff_t difference_type
Definition: Module.h:730
llvm::Module::rbegin
const_reverse_iterator rbegin() const
Definition: Module.h:624
llvm::Module::end
iterator end()
Definition: Module.h:621
llvm::Module::aliases
iterator_range< const_alias_iterator > aliases() const
Definition: Module.h:651
llvm::concat_iterator
Iterator wrapper that concatenates sequences together.
Definition: STLExtras.h:875
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:645
llvm::Module::getGlobalList
const GlobalListType & getGlobalList() const
Get the Module's list of global variables (constant).
Definition: Module.h:544
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:622
llvm::Module::setPIELevel
void setPIELevel(PIELevel::Level PL)
Set the PIE level (small or large model)
Definition: Module.cpp:611
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:728
llvm::Module::getSDKVersion
VersionTuple getSDKVersion() const
Get the build SDK version metadata.
Definition: Module.cpp:703
llvm::Module::debug_compile_units_iterator::operator++
debug_compile_units_iterator operator++(int)
Definition: Module.h:745
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:565
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:668
llvm::Module::setModuleIdentifier
void setModuleIdentifier(StringRef ID)
Set the module identifier.
Definition: Module.h:290
llvm::Module::getNamedMDList
NamedMDListType & getNamedMDList()
Get the Module's list of named metadata.
Definition: Module.h:581
llvm::Module::named_metadata_begin
const_named_metadata_iterator named_metadata_begin() const
Definition: Module.h:701
llvm::Module::setSemanticInterposition
void setSemanticInterposition(bool)
Set whether semantic interposition is to be respected.
Definition: Module.cpp:655
llvm::Module::rend
reverse_iterator rend()
Definition: Module.h:625
llvm::Module::alias_begin
alias_iterator alias_begin()
Definition: Module.h:641
llvm::Module::globals
iterator_range< global_iterator > globals()
Definition: Module.h:608
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:705
llvm::Module::empty
bool empty() const
Definition: Module.h:628
llvm::Module::setCodeModel
void setCodeModel(CodeModel::Model CL)
Set the code model (tiny, small, kernel, medium or large)
Definition: Module.cpp:625
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:588
llvm::GlobalObject
Definition: GlobalObject.h:28
llvm::Module::named_metadata
iterator_range< named_metadata_iterator > named_metadata()
Definition: Module.h:713
llvm::Module::global_end
const_global_iterator global_end() const
Definition: Module.h:604
llvm::AMDGPU::PALMD::Key
Key
PAL metadata keys.
Definition: AMDGPUMetadata.h:481
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:678
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:633
llvm::Module::getAliasList
const AliasListType & getAliasList() const
Get the Module's list of aliases (constant).
Definition: Module.h:561
llvm::Module::getComdatSymbolTable
const ComdatSymTabType & getComdatSymbolTable() const
Get the Module's symbol table for COMDATs (constant).
Definition: Module.h:593
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:644
llvm::unwrap
Attribute unwrap(LLVMAttributeRef Attr)
Definition: Attributes.h:244
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:739
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:248
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:304
StringMap.h
llvm::Comdat
Definition: Comdat.h:31
llvm::Metadata
Root of the metadata hierarchy.
Definition: Metadata.h:62
llvm::Module::setTargetTriple
void setTargetTriple(StringRef T)
Set the target triple.
Definition: Module.h:300
llvm::lltok::Kind
Kind
Definition: LLToken.h:18
llvm::Module::getFramePointer
FramePointerKind getFramePointer() const
Get/set whether synthesized functions should get the "frame-pointer" attribute.
Definition: Module.cpp:679
llvm::Module::rend
const_reverse_iterator rend() const
Definition: Module.h:626
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:601
llvm::Module::rbegin
reverse_iterator rbegin()
Definition: Module.h:623
llvm::Module::AppendUnique
@ AppendUnique
Appends the two values, which are required to be metadata nodes.
Definition: Module.h:146
llvm::Module::getUniqueIntrinsicName
std::string getUniqueIntrinsicName(StringRef BaseName, Intrinsic::ID Id, const FunctionType *Proto)
Return a unique name for an intrinsic whose mangling is based on an unnamed type.
Definition: Module.cpp:476
llvm::CodeModel::Model
Model
Definition: CodeGen.h:28
llvm::Module::ifunc_begin
const_ifunc_iterator ifunc_begin() const
Definition: Module.h:660
llvm::function_ref
An efficient, type-erasing, non-owning reference to a callable.
Definition: STLExtras.h:168
llvm::LLVMContext::getDiagHandlerPtr
const DiagnosticHandler * getDiagHandlerPtr() const
getDiagHandlerPtr - Returns const raw pointer of DiagnosticHandler set by setDiagnosticHandler.
Definition: LLVMContext.cpp:343
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:648
llvm::Module::getOrInsertFunction
FunctionCallee getOrInsertFunction(StringRef Name, Type *RetTy, ArgsTy... Args)
Same as above, but without the attributes.
Definition: Module.h:385
llvm::Module::ifunc_empty
bool ifunc_empty() const
Definition: Module.h:664
llvm::RISCVFenceField::O
@ O
Definition: RISCVBaseInfo.h:132
llvm::GlobalValue
Definition: GlobalValue.h:44
llvm::Module::getName
StringRef getName() const
Get a short "name" for the module.
Definition: Module.h:244
llvm::Module::setPICLevel
void setPICLevel(PICLevel::Level PL)
Set the PIC level (small or large model)
Definition: Module.cpp:597
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:547
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:533
llvm::Module::begin
iterator begin()
Definition: Module.h:619
llvm::Module::debug_compile_units_end
debug_compile_units_iterator debug_compile_units_end() const
Definition: Module.h:768
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:606
llvm::Module::getSublistAccess
static IFuncListType Module::* getSublistAccess(GlobalIFunc *)
Definition: Module.h:574
llvm::Module::getGlobalList
GlobalListType & getGlobalList()
Get the Module's list of global variables.
Definition: Module.h:546
llvm::LLVMContext
This is an important class for using LLVM in a threaded context.
Definition: LLVMContext.h:68
llvm::DenseMap
Definition: DenseMap.h:714
llvm::Module::global_end
global_iterator global_end()
Definition: Module.h:603
I
#define I(x, y, z)
Definition: MD5.cpp:59
llvm::Module::alias_begin
const_alias_iterator alias_begin() const
Definition: Module.h:642
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:1313
llvm::Module::getValueSymbolTable
ValueSymbolTable & getValueSymbolTable()
Get the Module's symbol table of global variable and function identifiers.
Definition: Module.h:590
llvm::Module::getSublistAccess
static GlobalListType Module::* getSublistAccess(GlobalVariable *)
Definition: Module.h:548
llvm::Module::ifuncs
iterator_range< const_ifunc_iterator > ifuncs() const
Definition: Module.h:669
llvm::Module::functions
iterator_range< iterator > functions()
Definition: Module.h:630
llvm::Module::getOrInsertComdat
Comdat * getOrInsertComdat(StringRef Name)
Return the Comdat in the module with the specified name.
Definition: Module.cpp:581
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:293
llvm::FramePointerKind
FramePointerKind
Definition: CodeGen.h:70
llvm::Module::getModuleIdentifier
const std::string & getModuleIdentifier() const
Get the module identifier which is, essentially, the name of the module.
Definition: Module.h:227
iterator_range.h
llvm::Module::debug_compile_units_iterator::operator!=
bool operator!=(const debug_compile_units_iterator &I) const
Definition: Module.h:755
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:763
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:897
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:555
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:4531
llvm::Module::setOwnedMemoryBuffer
void setOwnedMemoryBuffer(std::unique_ptr< MemoryBuffer > MB)
Take ownership of the given memory buffer.
Definition: Module.cpp:659
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
llvm::Module::debug_compile_units_iterator::iterator_category
std::input_iterator_tag iterator_category
Definition: Module.h:728
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
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:602
llvm::Module::getFunctionList
const FunctionListType & getFunctionList() const
Get the Module's list of functions (constant).
Definition: Module.h:553
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:238
llvm::Module::getSublistAccess
static FunctionListType Module::* getSublistAccess(Function *)
Definition: Module.h:556
llvm::Module::getGlobalVariable
GlobalVariable * getGlobalVariable(StringRef Name) const
Look up the specified global variable in the module symbol table.
Definition: Module.h:408
llvm::Module::alias_end
alias_iterator alias_end()
Definition: Module.h:643
llvm::Module::getNamedGlobal
GlobalVariable * getNamedGlobal(StringRef Name)
Definition: Module.h:426
llvm::Module::alias_empty
bool alias_empty() const
Definition: Module.h:646
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:645
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:570
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:528
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:700
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:659
llvm::Module::getContext
LLVMContext & getContext() const
Get the global data context.
Definition: Module.h:261
Function.h
llvm::Module::global_size
size_t global_size() const
Definition: Module.h:605
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:527
llvm::Module::getDwarfVersion
unsigned getDwarfVersion() const
Returns the Dwarf Version by checking module flags.
Definition: Module.cpp:555
llvm::Module::getGlobalVariable
GlobalVariable * getGlobalVariable(StringRef Name, bool AllowInternal=false)
Definition: Module.h:414
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:601
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:587
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:743
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:7809
llvm::PIELevel::Level
Level
Definition: CodeGen.h:37
llvm::Module::globals
iterator_range< const_global_iterator > globals() const
Definition: Module.h:611
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:374
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:716
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:257
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:706
llvm::Module::getComdatSymbolTable
ComdatSymTabType & getComdatSymbolTable()
Get the Module's symbol table for COMDATs.
Definition: Module.h:595
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:583
llvm::AMDGPU::HSAMD::Kernel::Key::Args
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
Definition: AMDGPUMetadata.h:389
llvm::Module::setProfileSummary
void setProfileSummary(Metadata *M, ProfileSummary::Kind Kind)
Attach profile summary metadata to this module.
Definition: Module.cpp:633
llvm::Module::getIFuncList
IFuncListType & getIFuncList()
Get the Module's list of ifuncs.
Definition: Module.h:572
llvm::AMDGPU::VGPRIndexMode::Id
Id
Definition: SIDefines.h:221
SymbolTableListTraits.h
llvm::Module::debug_compile_units_iterator
An iterator for DICompileUnits that skips those marked NoDebug.
Definition: Module.h:721
llvm::MDString
A single uniqued string.
Definition: Metadata.h:611
llvm::GlobalIFunc
Definition: GlobalIFunc.h:32
llvm::Module::setUwtable
void setUwtable()
Definition: Module.cpp:677
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:751
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:1167
llvm::FunctionType
Class to represent function types.
Definition: DerivedTypes.h:102
llvm::Intrinsic::ID
unsigned ID
Definition: TargetTransformInfo.h:38
llvm::Module::size
size_t size() const
Definition: Module.h:627