File indexing completed on 2026-05-10 08:44:08
0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef LLVM_IR_MODULESLOTTRACKER_H
0010 #define LLVM_IR_MODULESLOTTRACKER_H
0011
0012 #include <functional>
0013 #include <memory>
0014 #include <utility>
0015 #include <vector>
0016
0017 namespace llvm {
0018
0019 class Module;
0020 class Function;
0021 class SlotTracker;
0022 class Value;
0023 class MDNode;
0024
0025
0026 class AbstractSlotTrackerStorage {
0027 public:
0028 virtual ~AbstractSlotTrackerStorage();
0029
0030 virtual unsigned getNextMetadataSlot() = 0;
0031
0032 virtual void createMetadataSlot(const MDNode *) = 0;
0033 virtual int getMetadataSlot(const MDNode *) = 0;
0034 };
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044 class ModuleSlotTracker {
0045
0046 std::unique_ptr<SlotTracker> MachineStorage;
0047 bool ShouldCreateStorage = false;
0048 bool ShouldInitializeAllMetadata = false;
0049
0050 const Module *M = nullptr;
0051 const Function *F = nullptr;
0052 SlotTracker *Machine = nullptr;
0053
0054 std::function<void(AbstractSlotTrackerStorage *, const Module *, bool)>
0055 ProcessModuleHookFn;
0056 std::function<void(AbstractSlotTrackerStorage *, const Function *, bool)>
0057 ProcessFunctionHookFn;
0058
0059 public:
0060
0061 ModuleSlotTracker(SlotTracker &Machine, const Module *M,
0062 const Function *F = nullptr);
0063
0064
0065
0066
0067
0068
0069
0070
0071 explicit ModuleSlotTracker(const Module *M,
0072 bool ShouldInitializeAllMetadata = true);
0073
0074
0075 virtual ~ModuleSlotTracker();
0076
0077
0078 SlotTracker *getMachine();
0079
0080 const Module *getModule() const { return M; }
0081 const Function *getCurrentFunction() const { return F; }
0082
0083
0084
0085
0086
0087 void incorporateFunction(const Function &F);
0088
0089
0090
0091
0092
0093
0094 int getLocalSlot(const Value *V);
0095
0096 void setProcessHook(
0097 std::function<void(AbstractSlotTrackerStorage *, const Module *, bool)>);
0098 void setProcessHook(std::function<void(AbstractSlotTrackerStorage *,
0099 const Function *, bool)>);
0100
0101 using MachineMDNodeListType =
0102 std::vector<std::pair<unsigned, const MDNode *>>;
0103
0104 void collectMDNodes(MachineMDNodeListType &L, unsigned LB, unsigned UB) const;
0105 };
0106
0107 }
0108
0109 #endif