File indexing completed on 2026-05-10 08:44:08
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014 #ifndef LLVM_IR_MODULE_H
0015 #define LLVM_IR_MODULE_H
0016
0017 #include "llvm-c/Types.h"
0018 #include "llvm/ADT/STLExtras.h"
0019 #include "llvm/ADT/StringMap.h"
0020 #include "llvm/ADT/StringRef.h"
0021 #include "llvm/ADT/iterator_range.h"
0022 #include "llvm/IR/Attributes.h"
0023 #include "llvm/IR/Comdat.h"
0024 #include "llvm/IR/DataLayout.h"
0025 #include "llvm/IR/Function.h"
0026 #include "llvm/IR/GlobalAlias.h"
0027 #include "llvm/IR/GlobalIFunc.h"
0028 #include "llvm/IR/GlobalVariable.h"
0029 #include "llvm/IR/Metadata.h"
0030 #include "llvm/IR/ProfileSummary.h"
0031 #include "llvm/IR/SymbolTableListTraits.h"
0032 #include "llvm/Support/CBindingWrapping.h"
0033 #include "llvm/Support/CodeGen.h"
0034 #include <cstddef>
0035 #include <cstdint>
0036 #include <iterator>
0037 #include <memory>
0038 #include <optional>
0039 #include <string>
0040 #include <vector>
0041
0042 namespace llvm {
0043
0044 class Error;
0045 class FunctionType;
0046 class GVMaterializer;
0047 class LLVMContext;
0048 class MemoryBuffer;
0049 class ModuleSummaryIndex;
0050 class RandomNumberGenerator;
0051 class StructType;
0052 class VersionTuple;
0053
0054
0055
0056
0057
0058
0059
0060
0061
0062
0063
0064
0065 class LLVM_ABI Module {
0066
0067
0068 public:
0069
0070 using GlobalListType = SymbolTableList<GlobalVariable>;
0071
0072 using FunctionListType = SymbolTableList<Function>;
0073
0074 using AliasListType = SymbolTableList<GlobalAlias>;
0075
0076 using IFuncListType = SymbolTableList<GlobalIFunc>;
0077
0078 using NamedMDListType = ilist<NamedMDNode>;
0079
0080 using ComdatSymTabType = StringMap<Comdat>;
0081
0082 using NamedMDSymTabType = StringMap<NamedMDNode *>;
0083
0084
0085 using global_iterator = GlobalListType::iterator;
0086
0087 using const_global_iterator = GlobalListType::const_iterator;
0088
0089
0090 using iterator = FunctionListType::iterator;
0091
0092 using const_iterator = FunctionListType::const_iterator;
0093
0094
0095 using reverse_iterator = FunctionListType::reverse_iterator;
0096
0097 using const_reverse_iterator = FunctionListType::const_reverse_iterator;
0098
0099
0100 using alias_iterator = AliasListType::iterator;
0101
0102 using const_alias_iterator = AliasListType::const_iterator;
0103
0104
0105 using ifunc_iterator = IFuncListType::iterator;
0106
0107 using const_ifunc_iterator = IFuncListType::const_iterator;
0108
0109
0110 using named_metadata_iterator = NamedMDListType::iterator;
0111
0112 using const_named_metadata_iterator = NamedMDListType::const_iterator;
0113
0114
0115 enum ModFlagBehavior {
0116
0117
0118 Error = 1,
0119
0120
0121
0122 Warning = 2,
0123
0124
0125
0126
0127
0128
0129
0130
0131 Require = 3,
0132
0133
0134
0135
0136 Override = 4,
0137
0138
0139 Append = 5,
0140
0141
0142
0143
0144 AppendUnique = 6,
0145
0146
0147 Max = 7,
0148
0149
0150 Min = 8,
0151
0152
0153 ModFlagBehaviorFirstVal = Error,
0154 ModFlagBehaviorLastVal = Min
0155 };
0156
0157
0158
0159 static bool isValidModFlagBehavior(Metadata *MD, ModFlagBehavior &MFB);
0160
0161 struct ModuleFlagEntry {
0162 ModFlagBehavior Behavior;
0163 MDString *Key;
0164 Metadata *Val;
0165
0166 ModuleFlagEntry(ModFlagBehavior B, MDString *K, Metadata *V)
0167 : Behavior(B), Key(K), Val(V) {}
0168 };
0169
0170
0171
0172
0173 private:
0174 LLVMContext &Context;
0175
0176 GlobalListType GlobalList;
0177 FunctionListType FunctionList;
0178 AliasListType AliasList;
0179 IFuncListType IFuncList;
0180 NamedMDListType NamedMDList;
0181 std::string GlobalScopeAsm;
0182 std::unique_ptr<ValueSymbolTable> ValSymTab;
0183 ComdatSymTabType ComdatSymTab;
0184 std::unique_ptr<MemoryBuffer>
0185 OwnedMemoryBuffer;
0186
0187 std::unique_ptr<GVMaterializer>
0188 Materializer;
0189 std::string ModuleID;
0190 std::string SourceFileName;
0191
0192 std::string TargetTriple;
0193
0194 NamedMDSymTabType NamedMDSymTab;
0195 DataLayout DL;
0196 StringMap<unsigned>
0197 CurrentIntrinsicIds;
0198
0199 DenseMap<std::pair<Intrinsic::ID, const FunctionType *>, unsigned>
0200 UniquedIntrinsicNames;
0201
0202
0203
0204
0205
0206 NamedMDNode *ModuleFlags = nullptr;
0207
0208 friend class Constant;
0209
0210
0211
0212
0213 public:
0214
0215
0216
0217 bool IsNewDbgInfoFormat;
0218
0219
0220
0221
0222 void removeDebugIntrinsicDeclarations();
0223
0224
0225 void convertToNewDbgValues() {
0226 for (auto &F : *this) {
0227 F.convertToNewDbgValues();
0228 }
0229 IsNewDbgInfoFormat = true;
0230 }
0231
0232
0233 void convertFromNewDbgValues() {
0234 for (auto &F : *this) {
0235 F.convertFromNewDbgValues();
0236 }
0237 IsNewDbgInfoFormat = false;
0238 }
0239
0240 void setIsNewDbgInfoFormat(bool UseNewFormat) {
0241 if (UseNewFormat && !IsNewDbgInfoFormat)
0242 convertToNewDbgValues();
0243 else if (!UseNewFormat && IsNewDbgInfoFormat)
0244 convertFromNewDbgValues();
0245 }
0246 void setNewDbgInfoFormatFlag(bool NewFlag) {
0247 for (auto &F : *this) {
0248 F.setNewDbgInfoFormatFlag(NewFlag);
0249 }
0250 IsNewDbgInfoFormat = NewFlag;
0251 }
0252
0253
0254
0255 explicit Module(StringRef ModuleID, LLVMContext& C);
0256
0257 ~Module();
0258
0259
0260 Module &operator=(Module &&Other);
0261
0262
0263
0264
0265
0266
0267
0268 const std::string &getModuleIdentifier() const { return ModuleID; }
0269
0270
0271
0272
0273 unsigned getInstructionCount() const;
0274
0275
0276
0277
0278
0279 const std::string &getSourceFileName() const { return SourceFileName; }
0280
0281
0282
0283
0284
0285 StringRef getName() const { return ModuleID; }
0286
0287
0288
0289 const std::string &getDataLayoutStr() const {
0290 return DL.getStringRepresentation();
0291 }
0292
0293
0294 const DataLayout &getDataLayout() const { return DL; }
0295
0296
0297
0298 const std::string &getTargetTriple() const { return TargetTriple; }
0299
0300
0301
0302 LLVMContext &getContext() const { return Context; }
0303
0304
0305
0306 const std::string &getModuleInlineAsm() const { return GlobalScopeAsm; }
0307
0308
0309
0310
0311
0312
0313
0314
0315
0316
0317 std::unique_ptr<RandomNumberGenerator> createRNG(const StringRef Name) const;
0318
0319
0320
0321 bool shouldEmitInstrCountChangedRemark() {
0322 return getContext().getDiagHandlerPtr()->isAnalysisRemarkEnabled(
0323 "size-info");
0324 }
0325
0326
0327
0328
0329
0330
0331 void setModuleIdentifier(StringRef ID) { ModuleID = std::string(ID); }
0332
0333
0334 void setSourceFileName(StringRef Name) { SourceFileName = std::string(Name); }
0335
0336
0337 void setDataLayout(StringRef Desc);
0338 void setDataLayout(const DataLayout &Other);
0339
0340
0341 void setTargetTriple(StringRef T) { TargetTriple = std::string(T); }
0342
0343
0344
0345 void setModuleInlineAsm(StringRef Asm) {
0346 GlobalScopeAsm = std::string(Asm);
0347 if (!GlobalScopeAsm.empty() && GlobalScopeAsm.back() != '\n')
0348 GlobalScopeAsm += '\n';
0349 }
0350
0351
0352
0353 void appendModuleInlineAsm(StringRef Asm) {
0354 GlobalScopeAsm += Asm;
0355 if (!GlobalScopeAsm.empty() && GlobalScopeAsm.back() != '\n')
0356 GlobalScopeAsm += '\n';
0357 }
0358
0359
0360
0361
0362
0363
0364
0365
0366 GlobalValue *getNamedValue(StringRef Name) const;
0367
0368
0369 unsigned getNumNamedValues() const;
0370
0371
0372
0373 unsigned getMDKindID(StringRef Name) const;
0374
0375
0376
0377 void getMDKindNames(SmallVectorImpl<StringRef> &Result) const;
0378
0379
0380
0381
0382 void getOperandBundleTags(SmallVectorImpl<StringRef> &Result) const;
0383
0384 std::vector<StructType *> getIdentifiedStructTypes() const;
0385
0386
0387
0388 std::string getUniqueIntrinsicName(StringRef BaseName, Intrinsic::ID Id,
0389 const FunctionType *Proto);
0390
0391
0392
0393
0394
0395
0396
0397
0398
0399
0400
0401
0402
0403
0404
0405 FunctionCallee getOrInsertFunction(StringRef Name, FunctionType *T,
0406 AttributeList AttributeList);
0407
0408 FunctionCallee getOrInsertFunction(StringRef Name, FunctionType *T);
0409
0410
0411
0412 template <typename... ArgsTy>
0413 FunctionCallee getOrInsertFunction(StringRef Name,
0414 AttributeList AttributeList, Type *RetTy,
0415 ArgsTy... Args) {
0416 SmallVector<Type*, sizeof...(ArgsTy)> ArgTys{Args...};
0417 return getOrInsertFunction(Name,
0418 FunctionType::get(RetTy, ArgTys, false),
0419 AttributeList);
0420 }
0421
0422
0423 template <typename... ArgsTy>
0424 FunctionCallee getOrInsertFunction(StringRef Name, Type *RetTy,
0425 ArgsTy... Args) {
0426 return getOrInsertFunction(Name, AttributeList{}, RetTy, Args...);
0427 }
0428
0429
0430 template <typename... ArgsTy>
0431 FunctionCallee
0432 getOrInsertFunction(StringRef Name, AttributeList AttributeList,
0433 FunctionType *Invalid, ArgsTy... Args) = delete;
0434
0435
0436
0437 Function *getFunction(StringRef Name) const;
0438
0439
0440
0441
0442
0443
0444
0445
0446
0447 GlobalVariable *getGlobalVariable(StringRef Name) const {
0448 return getGlobalVariable(Name, false);
0449 }
0450
0451 GlobalVariable *getGlobalVariable(StringRef Name, bool AllowInternal) const;
0452
0453 GlobalVariable *getGlobalVariable(StringRef Name,
0454 bool AllowInternal = false) {
0455 return static_cast<const Module *>(this)->getGlobalVariable(Name,
0456 AllowInternal);
0457 }
0458
0459
0460
0461
0462 const GlobalVariable *getNamedGlobal(StringRef Name) const {
0463 return getGlobalVariable(Name, true);
0464 }
0465 GlobalVariable *getNamedGlobal(StringRef Name) {
0466 return const_cast<GlobalVariable *>(
0467 static_cast<const Module *>(this)->getNamedGlobal(Name));
0468 }
0469
0470
0471
0472
0473
0474 Constant *
0475 getOrInsertGlobal(StringRef Name, Type *Ty,
0476 function_ref<GlobalVariable *()> CreateGlobalCallback);
0477
0478
0479
0480 Constant *getOrInsertGlobal(StringRef Name, Type *Ty);
0481
0482
0483
0484
0485
0486
0487
0488
0489 GlobalAlias *getNamedAlias(StringRef Name) const;
0490
0491
0492
0493
0494
0495
0496
0497
0498 GlobalIFunc *getNamedIFunc(StringRef Name) const;
0499
0500
0501
0502
0503
0504
0505
0506 NamedMDNode *getNamedMetadata(StringRef Name) const;
0507
0508
0509
0510
0511 NamedMDNode *getOrInsertNamedMetadata(StringRef Name);
0512
0513
0514 void eraseNamedMetadata(NamedMDNode *NMD);
0515
0516
0517
0518
0519
0520
0521
0522 Comdat *getOrInsertComdat(StringRef Name);
0523
0524
0525
0526
0527
0528
0529 void getModuleFlagsMetadata(SmallVectorImpl<ModuleFlagEntry> &Flags) const;
0530
0531
0532
0533 Metadata *getModuleFlag(StringRef Key) const;
0534
0535
0536
0537 NamedMDNode *getModuleFlagsMetadata() const { return ModuleFlags; }
0538
0539
0540
0541
0542 NamedMDNode *getOrInsertModuleFlagsMetadata();
0543
0544
0545
0546 void addModuleFlag(ModFlagBehavior Behavior, StringRef Key, Metadata *Val);
0547 void addModuleFlag(ModFlagBehavior Behavior, StringRef Key, Constant *Val);
0548 void addModuleFlag(ModFlagBehavior Behavior, StringRef Key, uint32_t Val);
0549 void addModuleFlag(MDNode *Node);
0550
0551 void setModuleFlag(ModFlagBehavior Behavior, StringRef Key, Metadata *Val);
0552 void setModuleFlag(ModFlagBehavior Behavior, StringRef Key, Constant *Val);
0553 void setModuleFlag(ModFlagBehavior Behavior, StringRef Key, uint32_t Val);
0554
0555
0556
0557
0558
0559
0560
0561
0562
0563
0564
0565
0566 void setMaterializer(GVMaterializer *GVM);
0567
0568 GVMaterializer *getMaterializer() const { return Materializer.get(); }
0569 bool isMaterialized() const { return !getMaterializer(); }
0570
0571
0572 llvm::Error materialize(GlobalValue *GV);
0573
0574
0575
0576 llvm::Error materializeAll();
0577
0578 llvm::Error materializeMetadata();
0579
0580
0581 void removeGlobalVariable(GlobalVariable *GV) { GlobalList.remove(GV); }
0582
0583 void eraseGlobalVariable(GlobalVariable *GV) { GlobalList.erase(GV); }
0584
0585
0586 void insertGlobalVariable(GlobalVariable *GV) {
0587 insertGlobalVariable(GlobalList.end(), GV);
0588 }
0589
0590
0591 void insertGlobalVariable(GlobalListType::iterator Where, GlobalVariable *GV) {
0592 GlobalList.insert(Where, GV);
0593 }
0594
0595
0596
0597 private:
0598
0599
0600
0601
0602
0603 const GlobalListType &getGlobalList() const { return GlobalList; }
0604
0605 GlobalListType &getGlobalList() { return GlobalList; }
0606
0607 static GlobalListType Module::*getSublistAccess(GlobalVariable*) {
0608 return &Module::GlobalList;
0609 }
0610 friend class llvm::SymbolTableListTraits<llvm::GlobalVariable>;
0611
0612 public:
0613
0614 const FunctionListType &getFunctionList() const { return FunctionList; }
0615
0616 FunctionListType &getFunctionList() { return FunctionList; }
0617 static FunctionListType Module::*getSublistAccess(Function*) {
0618 return &Module::FunctionList;
0619 }
0620
0621
0622 void removeAlias(GlobalAlias *Alias) { AliasList.remove(Alias); }
0623
0624 void eraseAlias(GlobalAlias *Alias) { AliasList.erase(Alias); }
0625
0626 void insertAlias(GlobalAlias *Alias) { AliasList.insert(AliasList.end(), Alias); }
0627
0628
0629
0630
0631 void removeIFunc(GlobalIFunc *IFunc) { IFuncList.remove(IFunc); }
0632
0633 void eraseIFunc(GlobalIFunc *IFunc) { IFuncList.erase(IFunc); }
0634
0635 void insertIFunc(GlobalIFunc *IFunc) { IFuncList.push_back(IFunc); }
0636
0637
0638
0639
0640 void removeNamedMDNode(NamedMDNode *MDNode) { NamedMDList.remove(MDNode); }
0641
0642 void eraseNamedMDNode(NamedMDNode *MDNode) { NamedMDList.erase(MDNode); }
0643
0644 void insertNamedMDNode(NamedMDNode *MDNode) {
0645 NamedMDList.push_back(MDNode);
0646 }
0647
0648
0649
0650 private:
0651
0652 const AliasListType &getAliasList() const { return AliasList; }
0653
0654 AliasListType &getAliasList() { return AliasList; }
0655
0656 static AliasListType Module::*getSublistAccess(GlobalAlias*) {
0657 return &Module::AliasList;
0658 }
0659 friend class llvm::SymbolTableListTraits<llvm::GlobalAlias>;
0660
0661
0662 const IFuncListType &getIFuncList() const { return IFuncList; }
0663
0664 IFuncListType &getIFuncList() { return IFuncList; }
0665
0666 static IFuncListType Module::*getSublistAccess(GlobalIFunc*) {
0667 return &Module::IFuncList;
0668 }
0669 friend class llvm::SymbolTableListTraits<llvm::GlobalIFunc>;
0670
0671
0672 const NamedMDListType &getNamedMDList() const { return NamedMDList; }
0673
0674 NamedMDListType &getNamedMDList() { return NamedMDList; }
0675
0676 static NamedMDListType Module::*getSublistAccess(NamedMDNode*) {
0677 return &Module::NamedMDList;
0678 }
0679
0680 public:
0681
0682 const ValueSymbolTable &getValueSymbolTable() const { return *ValSymTab; }
0683
0684 ValueSymbolTable &getValueSymbolTable() { return *ValSymTab; }
0685
0686
0687 const ComdatSymTabType &getComdatSymbolTable() const { return ComdatSymTab; }
0688
0689 ComdatSymTabType &getComdatSymbolTable() { return ComdatSymTab; }
0690
0691
0692
0693
0694
0695 global_iterator global_begin() { return GlobalList.begin(); }
0696 const_global_iterator global_begin() const { return GlobalList.begin(); }
0697 global_iterator global_end () { return GlobalList.end(); }
0698 const_global_iterator global_end () const { return GlobalList.end(); }
0699 size_t global_size () const { return GlobalList.size(); }
0700 bool global_empty() const { return GlobalList.empty(); }
0701
0702 iterator_range<global_iterator> globals() {
0703 return make_range(global_begin(), global_end());
0704 }
0705 iterator_range<const_global_iterator> globals() const {
0706 return make_range(global_begin(), global_end());
0707 }
0708
0709
0710
0711
0712
0713 iterator begin() { return FunctionList.begin(); }
0714 const_iterator begin() const { return FunctionList.begin(); }
0715 iterator end () { return FunctionList.end(); }
0716 const_iterator end () const { return FunctionList.end(); }
0717 reverse_iterator rbegin() { return FunctionList.rbegin(); }
0718 const_reverse_iterator rbegin() const{ return FunctionList.rbegin(); }
0719 reverse_iterator rend() { return FunctionList.rend(); }
0720 const_reverse_iterator rend() const { return FunctionList.rend(); }
0721 size_t size() const { return FunctionList.size(); }
0722 bool empty() const { return FunctionList.empty(); }
0723
0724 iterator_range<iterator> functions() {
0725 return make_range(begin(), end());
0726 }
0727 iterator_range<const_iterator> functions() const {
0728 return make_range(begin(), end());
0729 }
0730
0731
0732
0733
0734
0735 alias_iterator alias_begin() { return AliasList.begin(); }
0736 const_alias_iterator alias_begin() const { return AliasList.begin(); }
0737 alias_iterator alias_end () { return AliasList.end(); }
0738 const_alias_iterator alias_end () const { return AliasList.end(); }
0739 size_t alias_size () const { return AliasList.size(); }
0740 bool alias_empty() const { return AliasList.empty(); }
0741
0742 iterator_range<alias_iterator> aliases() {
0743 return make_range(alias_begin(), alias_end());
0744 }
0745 iterator_range<const_alias_iterator> aliases() const {
0746 return make_range(alias_begin(), alias_end());
0747 }
0748
0749
0750
0751
0752
0753 ifunc_iterator ifunc_begin() { return IFuncList.begin(); }
0754 const_ifunc_iterator ifunc_begin() const { return IFuncList.begin(); }
0755 ifunc_iterator ifunc_end () { return IFuncList.end(); }
0756 const_ifunc_iterator ifunc_end () const { return IFuncList.end(); }
0757 size_t ifunc_size () const { return IFuncList.size(); }
0758 bool ifunc_empty() const { return IFuncList.empty(); }
0759
0760 iterator_range<ifunc_iterator> ifuncs() {
0761 return make_range(ifunc_begin(), ifunc_end());
0762 }
0763 iterator_range<const_ifunc_iterator> ifuncs() const {
0764 return make_range(ifunc_begin(), ifunc_end());
0765 }
0766
0767
0768
0769
0770
0771 using global_object_iterator =
0772 concat_iterator<GlobalObject, iterator, global_iterator>;
0773 using const_global_object_iterator =
0774 concat_iterator<const GlobalObject, const_iterator,
0775 const_global_iterator>;
0776
0777 iterator_range<global_object_iterator> global_objects();
0778 iterator_range<const_global_object_iterator> global_objects() const;
0779
0780 using global_value_iterator =
0781 concat_iterator<GlobalValue, iterator, global_iterator, alias_iterator,
0782 ifunc_iterator>;
0783 using const_global_value_iterator =
0784 concat_iterator<const GlobalValue, const_iterator, const_global_iterator,
0785 const_alias_iterator, const_ifunc_iterator>;
0786
0787 iterator_range<global_value_iterator> global_values();
0788 iterator_range<const_global_value_iterator> global_values() const;
0789
0790
0791
0792
0793
0794 named_metadata_iterator named_metadata_begin() { return NamedMDList.begin(); }
0795 const_named_metadata_iterator named_metadata_begin() const {
0796 return NamedMDList.begin();
0797 }
0798
0799 named_metadata_iterator named_metadata_end() { return NamedMDList.end(); }
0800 const_named_metadata_iterator named_metadata_end() const {
0801 return NamedMDList.end();
0802 }
0803
0804 size_t named_metadata_size() const { return NamedMDList.size(); }
0805 bool named_metadata_empty() const { return NamedMDList.empty(); }
0806
0807 iterator_range<named_metadata_iterator> named_metadata() {
0808 return make_range(named_metadata_begin(), named_metadata_end());
0809 }
0810 iterator_range<const_named_metadata_iterator> named_metadata() const {
0811 return make_range(named_metadata_begin(), named_metadata_end());
0812 }
0813
0814
0815 class debug_compile_units_iterator {
0816 NamedMDNode *CUs;
0817 unsigned Idx;
0818
0819 void SkipNoDebugCUs();
0820
0821 public:
0822 using iterator_category = std::input_iterator_tag;
0823 using value_type = DICompileUnit *;
0824 using difference_type = std::ptrdiff_t;
0825 using pointer = value_type *;
0826 using reference = value_type &;
0827
0828 explicit debug_compile_units_iterator(NamedMDNode *CUs, unsigned Idx)
0829 : CUs(CUs), Idx(Idx) {
0830 SkipNoDebugCUs();
0831 }
0832
0833 debug_compile_units_iterator &operator++() {
0834 ++Idx;
0835 SkipNoDebugCUs();
0836 return *this;
0837 }
0838
0839 debug_compile_units_iterator operator++(int) {
0840 debug_compile_units_iterator T(*this);
0841 ++Idx;
0842 return T;
0843 }
0844
0845 bool operator==(const debug_compile_units_iterator &I) const {
0846 return Idx == I.Idx;
0847 }
0848
0849 bool operator!=(const debug_compile_units_iterator &I) const {
0850 return Idx != I.Idx;
0851 }
0852
0853 DICompileUnit *operator*() const;
0854 DICompileUnit *operator->() const;
0855 };
0856
0857 debug_compile_units_iterator debug_compile_units_begin() const {
0858 auto *CUs = getNamedMetadata("llvm.dbg.cu");
0859 return debug_compile_units_iterator(CUs, 0);
0860 }
0861
0862 debug_compile_units_iterator debug_compile_units_end() const {
0863 auto *CUs = getNamedMetadata("llvm.dbg.cu");
0864 return debug_compile_units_iterator(CUs, CUs ? CUs->getNumOperands() : 0);
0865 }
0866
0867
0868
0869
0870 iterator_range<debug_compile_units_iterator> debug_compile_units() const {
0871 auto *CUs = getNamedMetadata("llvm.dbg.cu");
0872 return make_range(
0873 debug_compile_units_iterator(CUs, 0),
0874 debug_compile_units_iterator(CUs, CUs ? CUs->getNumOperands() : 0));
0875 }
0876
0877
0878
0879
0880
0881
0882
0883
0884
0885 void dropTriviallyDeadConstantArrays();
0886
0887
0888
0889
0890
0891
0892
0893
0894 void print(raw_ostream &OS, AssemblyAnnotationWriter *AAW,
0895 bool ShouldPreserveUseListOrder = false,
0896 bool IsForDebug = false) const;
0897
0898
0899 void dump() const;
0900
0901
0902
0903
0904
0905
0906
0907 void dropAllReferences();
0908
0909
0910
0911
0912
0913
0914
0915 unsigned getNumberRegisterParameters() const;
0916
0917
0918 unsigned getDwarfVersion() const;
0919
0920
0921 bool isDwarf64() const;
0922
0923
0924
0925 unsigned getCodeViewFlag() const;
0926
0927
0928
0929
0930
0931
0932 PICLevel::Level getPICLevel() const;
0933
0934
0935 void setPICLevel(PICLevel::Level PL);
0936
0937
0938
0939
0940
0941
0942
0943 PIELevel::Level getPIELevel() const;
0944
0945
0946 void setPIELevel(PIELevel::Level PL);
0947
0948
0949
0950
0951
0952
0953
0954 std::optional<CodeModel::Model> getCodeModel() const;
0955
0956
0957 void setCodeModel(CodeModel::Model CL);
0958
0959
0960
0961
0962
0963
0964
0965 std::optional<uint64_t> getLargeDataThreshold() const;
0966
0967
0968 void setLargeDataThreshold(uint64_t Threshold);
0969
0970
0971
0972
0973
0974
0975 void setProfileSummary(Metadata *M, ProfileSummary::Kind Kind);
0976
0977
0978
0979 Metadata *getProfileSummary(bool IsCS) const;
0980
0981
0982
0983 bool getSemanticInterposition() const;
0984
0985
0986 void setSemanticInterposition(bool);
0987
0988
0989 bool getRtLibUseGOT() const;
0990
0991
0992 void setRtLibUseGOT();
0993
0994
0995
0996 bool getDirectAccessExternalData() const;
0997 void setDirectAccessExternalData(bool Value);
0998
0999
1000 UWTableKind getUwtable() const;
1001 void setUwtable(UWTableKind Kind);
1002
1003
1004
1005 FramePointerKind getFramePointer() const;
1006 void setFramePointer(FramePointerKind Kind);
1007
1008
1009 StringRef getStackProtectorGuard() const;
1010 void setStackProtectorGuard(StringRef Kind);
1011
1012
1013
1014
1015 StringRef getStackProtectorGuardReg() const;
1016 void setStackProtectorGuardReg(StringRef Reg);
1017
1018
1019 StringRef getStackProtectorGuardSymbol() const;
1020 void setStackProtectorGuardSymbol(StringRef Symbol);
1021
1022
1023 int getStackProtectorGuardOffset() const;
1024 void setStackProtectorGuardOffset(int Offset);
1025
1026
1027 unsigned getOverrideStackAlignment() const;
1028 void setOverrideStackAlignment(unsigned Align);
1029
1030 unsigned getMaxTLSAlignment() const;
1031
1032
1033
1034
1035
1036 void setSDKVersion(const VersionTuple &V);
1037
1038
1039
1040
1041 VersionTuple getSDKVersion() const;
1042
1043
1044
1045 void setOwnedMemoryBuffer(std::unique_ptr<MemoryBuffer> MB);
1046
1047
1048
1049 void setPartialSampleProfileRatio(const ModuleSummaryIndex &Index);
1050
1051
1052
1053
1054
1055 StringRef getDarwinTargetVariantTriple() const;
1056
1057
1058
1059 void setDarwinTargetVariantTriple(StringRef T);
1060
1061
1062
1063
1064 VersionTuple getDarwinTargetVariantSDKVersion() const;
1065
1066
1067 void setDarwinTargetVariantSDKVersion(VersionTuple Version);
1068 };
1069
1070
1071
1072
1073 GlobalVariable *collectUsedGlobalVariables(const Module &M,
1074 SmallVectorImpl<GlobalValue *> &Vec,
1075 bool CompilerUsed);
1076
1077
1078 inline raw_ostream &operator<<(raw_ostream &O, const Module &M) {
1079 M.print(O, nullptr);
1080 return O;
1081 }
1082
1083
1084 DEFINE_SIMPLE_CONVERSION_FUNCTIONS(Module, LLVMModuleRef)
1085
1086
1087
1088
1089 inline Module *unwrap(LLVMModuleProviderRef MP) {
1090 return reinterpret_cast<Module*>(MP);
1091 }
1092
1093 }
1094
1095 #endif