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