File indexing completed on 2026-05-10 08:44:11
0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef LLVM_LINKER_IRMOVER_H
0010 #define LLVM_LINKER_IRMOVER_H
0011
0012 #include "llvm/ADT/ArrayRef.h"
0013 #include "llvm/ADT/DenseSet.h"
0014 #include "llvm/ADT/FunctionExtras.h"
0015 #include <functional>
0016
0017 namespace llvm {
0018 class Error;
0019 class GlobalValue;
0020 class Metadata;
0021 class Module;
0022 class StructType;
0023 class TrackingMDRef;
0024 class Type;
0025
0026 class IRMover {
0027 struct StructTypeKeyInfo {
0028 struct KeyTy {
0029 ArrayRef<Type *> ETypes;
0030 bool IsPacked;
0031 KeyTy(ArrayRef<Type *> E, bool P);
0032 KeyTy(const StructType *ST);
0033 bool operator==(const KeyTy &that) const;
0034 bool operator!=(const KeyTy &that) const;
0035 };
0036 static StructType *getEmptyKey();
0037 static StructType *getTombstoneKey();
0038 static unsigned getHashValue(const KeyTy &Key);
0039 static unsigned getHashValue(const StructType *ST);
0040 static bool isEqual(const KeyTy &LHS, const StructType *RHS);
0041 static bool isEqual(const StructType *LHS, const StructType *RHS);
0042 };
0043
0044
0045 typedef DenseMap<const Metadata *, TrackingMDRef> MDMapT;
0046
0047 public:
0048 class IdentifiedStructTypeSet {
0049
0050 DenseSet<StructType *> OpaqueStructTypes;
0051
0052
0053 DenseSet<StructType *, StructTypeKeyInfo> NonOpaqueStructTypes;
0054
0055 public:
0056 void addNonOpaque(StructType *Ty);
0057 void switchToNonOpaque(StructType *Ty);
0058 void addOpaque(StructType *Ty);
0059 StructType *findNonOpaque(ArrayRef<Type *> ETypes, bool IsPacked);
0060 bool hasType(StructType *Ty);
0061 };
0062
0063 IRMover(Module &M);
0064
0065 typedef std::function<void(GlobalValue &)> ValueAdder;
0066 using LazyCallback =
0067 llvm::unique_function<void(GlobalValue &GV, ValueAdder Add)>;
0068
0069
0070
0071
0072
0073
0074
0075
0076
0077
0078
0079 Error move(std::unique_ptr<Module> Src, ArrayRef<GlobalValue *> ValuesToLink,
0080 LazyCallback AddLazyFor, bool IsPerformingImport);
0081 Module &getModule() { return Composite; }
0082
0083 private:
0084 Module &Composite;
0085 IdentifiedStructTypeSet IdentifiedStructTypes;
0086 MDMapT SharedMDs;
0087 };
0088
0089 }
0090
0091 #endif