File indexing completed on 2026-05-10 08:43:57
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015 #ifndef LLVM_IR_COMDAT_H
0016 #define LLVM_IR_COMDAT_H
0017
0018 #include "llvm-c/Types.h"
0019 #include "llvm/ADT/SmallPtrSet.h"
0020 #include "llvm/Support/CBindingWrapping.h"
0021
0022 namespace llvm {
0023
0024 class GlobalObject;
0025 class raw_ostream;
0026 class StringRef;
0027 template <typename ValueTy> class StringMapEntry;
0028
0029
0030
0031
0032
0033 class Comdat {
0034 public:
0035 enum SelectionKind {
0036 Any,
0037 ExactMatch,
0038 Largest,
0039 NoDeduplicate,
0040 SameSize,
0041 };
0042
0043 Comdat(const Comdat &) = delete;
0044 Comdat(Comdat &&C);
0045
0046 SelectionKind getSelectionKind() const { return SK; }
0047 void setSelectionKind(SelectionKind Val) { SK = Val; }
0048 StringRef getName() const;
0049 void print(raw_ostream &OS, bool IsForDebug = false) const;
0050 void dump() const;
0051 const SmallPtrSetImpl<GlobalObject *> &getUsers() const { return Users; }
0052
0053 private:
0054 friend class Module;
0055 friend class GlobalObject;
0056
0057 Comdat();
0058 void addUser(GlobalObject *GO);
0059 void removeUser(GlobalObject *GO);
0060
0061
0062 StringMapEntry<Comdat> *Name = nullptr;
0063 SelectionKind SK = Any;
0064
0065 SmallPtrSet<GlobalObject *, 2> Users;
0066 };
0067
0068
0069 DEFINE_SIMPLE_CONVERSION_FUNCTIONS(Comdat, LLVMComdatRef)
0070
0071 inline raw_ostream &operator<<(raw_ostream &OS, const Comdat &C) {
0072 C.print(OS);
0073 return OS;
0074 }
0075
0076 }
0077
0078 #endif