1//===-- llvm/IR/ModuleSlotTracker.h -----------------------------*- C++ -*-===//
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
7//===----------------------------------------------------------------------===//
9#ifndef LLVM_IR_MODULESLOTTRACKER_H
10#define LLVM_IR_MODULESLOTTRACKER_H
26/// Abstract interface of slot tracker storage.
37/// Manage lifetime of a slot tracker for printing IR.
39/// Wrapper around the \a SlotTracker used internally by \a AsmWriter. This
40/// class allows callers to share the cost of incorporating the metadata in a
41/// module or a function.
43/// If the IR changes from underneath \a ModuleSlotTracker, strings like
44/// "<badref>" will be printed, or, worse, the wrong slots entirely.
46 /// Storage for a slot tracker.
47 std::unique_ptr<SlotTracker> MachineStorage;
48 bool ShouldCreateStorage =
false;
49 bool ShouldInitializeAllMetadata =
false;
58 ProcessFunctionHookFn;
61 /// Wrap a preinitialized SlotTracker.
65 /// Construct a slot tracker from a module.
67 /// If \a M is \c nullptr, uses a null slot tracker. Otherwise, initializes
68 /// a slot tracker, and initializes all metadata slots. \c
69 /// ShouldInitializeAllMetadata defaults to true because this is expected to
70 /// be shared between multiple callers, and otherwise MDNode references will
73 bool ShouldInitializeAllMetadata =
true);
75 /// Destructor to clean up storage.
78 /// Lazily creates a slot tracker.
84 /// Incorporate the given function.
86 /// Purge the currently incorporated function and incorporate \c F. If \c F
87 /// is currently incorporated, this is a no-op.
88 void incorporateFunction(
const Function &
F);
90 /// Return the slot number of the specified local value.
92 /// A function that defines this value should be incorporated prior to calling
94 /// Return -1 if the value is not in the function's SlotTracker.
95 int getLocalSlot(
const Value *V);
103 std::vector<std::pair<unsigned, const MDNode *>>;
108}
// end namespace llvm
Abstract interface of slot tracker storage.
virtual unsigned getNextMetadataSlot()=0
virtual int getMetadataSlot(const MDNode *)=0
virtual ~AbstractSlotTrackerStorage()
virtual void createMetadataSlot(const MDNode *)=0
const Module * getModule() const
ModuleSlotTracker(SlotTracker &Machine, const Module *M, const Function *F=nullptr)
Wrap a preinitialized SlotTracker.
virtual ~ModuleSlotTracker()
Destructor to clean up storage.
std::vector< std::pair< unsigned, const MDNode * > > MachineMDNodeListType
void collectMDNodes(MachineMDNodeListType &L, unsigned LB, unsigned UB) const
SlotTracker * getMachine()
Lazily creates a slot tracker.
const Function * getCurrentFunction() const
A Module instance is used to store all the information related to an LLVM module.
This class provides computation of slot numbers for LLVM Assembly writing.
LLVM Value Representation.
This is an optimization pass for GlobalISel generic memory operations.