14#ifndef LLVM_IR_FUNCTIONLOCALMETADATA_H
15#define LLVM_IR_FUNCTIONLOCALMETADATA_H
52template <
typename IndexedType>
class FLIndex {
64 assert(InIndex < std::numeric_limits<IndexType>::max() &&
65 "Hit maximum index limit!");
67 operator bool()
const {
return Index; }
75 Index.Index = RawIndex;
153 const Module *M =
nullptr)
const;
159 return LHS.isEquivalent(
RHS);
175 static_assert(
sizeof(*this) ==
sizeof(
uint64_t));
177 std::memcpy(&Result,
this,
sizeof(Result));
188 const Module *M =
nullptr)
const;
211 const Module *M =
nullptr)
const;
230class MDFunctionLocalContext :
public MDNode {
235 setNonDebug(NonDebug);
240 ~MDFunctionLocalContext() =
default;
250 void setNonDebug(
bool IsNonDebug) {
SubclassData1 = IsNonDebug; }
267 bool NonDebug =
false);
296 assert(Idx &&
"Attempted to fetch a Scope with an empty index!");
297 return Scopes[Idx.get()];
301 assert(Idx &&
"Attempted to fetch a Scope with an empty index!");
303 return Scopes[Idx.get()];
304 return InlinedCalls[InlinedAt.
get()].getInlinee()->getScope(Idx);
307 assert(Idx &&
"Attempted to fetch a SrcLoc with an empty index!");
308 return SrcLocs[Idx.get()];
312 assert(Idx &&
"Attempted to fetch a SrcLoc with an empty index!");
314 return SrcLocs[Idx.get()];
315 return InlinedCalls[InlinedAt.
get()].getInlinee()->getSrcLoc(Idx);
318 assert(Idx &&
"Attempted to fetch an InlinedCall with an empty index!");
319 return InlinedCalls[Idx.get()];
329 if (!InlinedCallIdx) {
332 "Atom group limit reached!");
336 return InlinedCalls[InlinedCallIdx.
get()].getNewAtomGroup();
341 "New atom group exceeds limit!");
345 InlinedCalls[InlinedCallIdx.
get()].MaxAtomGroup = std::max(
346 InlinedCalls[InlinedCallIdx.
get()].MaxAtomGroup, NewWaterline);
351 return InlinedCalls[InlinedCallIdx.
get()].MaxAtomGroup;
356 Scopes.push_back(Scope);
357 return Scopes.size() - 1;
365 for (
uint16_t Idx = 0; Idx < Scopes.size(); ++Idx)
366 if (Scopes[Idx] == Scope)
373 SrcLocs.push_back(SrcLoc);
374 return SrcLocs.size() - 1;
386 for (
uint32_t Idx = 0; Idx < SrcLocs.size(); ++Idx)
387 if (SrcLocs[Idx] == SrcLoc)
398 bool UniquableMayExist =
true) {
399 if (InlinedCall.
Uniquable && UniquableMayExist) {
400 for (
uint16_t Idx = 0; Idx < InlinedCalls.size(); ++Idx) {
402 InlinedCalls[Idx].MaxAtomGroup = std::max(
403 InlinedCall.
MaxAtomGroup, InlinedCalls[Idx].MaxAtomGroup);
408 InlinedCalls.push_back(InlinedCall);
409 return InlinedCalls.size() - 1;
417 const Module *M =
nullptr)
const;
423 "FLInlinedCall to be inlined!");
445 auto [ScopeIt, Inserted] = ScopeMap.try_emplace(InsertedScope);
447 ScopeIt->second = FLContext->insertScope(InsertedScope);
448 return ScopeIt->second;
455 FLSrcLoc InsertedSrcLoc(Line, Column, ScopeIdx);
456 auto [SrcLocIt, Inserted] = SrcLocMap.try_emplace(InsertedSrcLoc);
458 SrcLocIt->second = FLContext->insertSrcLoc(InsertedSrcLoc);
459 return SrcLocIt->second;
467 return getSrcLoc(Line, Column, ScopeIdx);
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
static GCRegistry::Add< ShadowStackGC > C("shadow-stack", "Very portable GC for uncooperative code generators")
This file defines the DenseMap class.
This file defines the SmallVector class.
Represent a constant reference to an array (0 or more elements consecutively in memory),...
Subprogram description. Uses SubclassData1.
Small wrapper class for an FLMD index, which may be "no index".
bool operator!=(const FLIndex &Other) const
bool operator==(const FLIndex &Other) const
friend hash_code hash_value(const FLIndex< IndexedType > &Idx)
typename detail::HasFLIndex< IndexedType >::IndexType IndexType
static FLIndex fromRaw(IndexType RawIndex)
FLIndex(IndexType InIndex)
FLIndex< FLSrcLoc > getSrcLoc(uint32_t Line, uint16_t Column, FLIndex< FLScope > ScopeIdx)
FLIndex< FLSrcLoc > getSrcLocWithScope(uint32_t Line, uint16_t Column, const DILocalScope *Scope)
FLIndex< FLScope > getScope(const DILocalScope *Scope)
LLVM_ABI FLMDBuilder(MDFunctionLocalContext *FLContext, const DISubprogram *SP)
This is an important class for using LLVM in a threaded context.
Storage class for function-local metadata objects.
ArrayRef< FLInlinedCall > getInlinedCalls() const
FLSrcLoc getSrcLoc(FLIndex< FLSrcLoc > Idx) const
LLVM_ABI void getUsedMDNodes(SmallVectorImpl< const MDNode * > &Nodes) const
static bool classof(const Metadata *MD)
TempMDFunctionLocalContext clone() const
uint16_t getMaxAtomGroup() const
uint16_t getAtomGroupWaterline(FLIndex< FLInlinedCall > InlinedCallIdx)
FLIndex< FLSrcLoc > getOrInsertSrcLoc(FLSrcLoc SrcLoc)
Returns the existing index of SrcLoc, or else inserts it and returns its new index.
void setMaxAtomGroup(uint16_t NewAtomGroup)
Generally this shouldn't be called directly; prefer updateAtomGroupWaterline, including any relevant ...
FLInlinedCall getInlinedCall(FLIndex< FLInlinedCall > Idx) const
FLIndex< FLScope > getOrInsertScope(FLScope Scope)
Returns the existing index of Scope, or else inserts it and returns its new index.
LLVM_ABI void printShort(raw_ostream &OS, const Module *M=nullptr) const
Prints a shortened version of this FLContext, where only the number of entries in each storage array ...
TempMDFunctionLocalContext cloneImpl() const
FLIndex< FLInlinedCall > insertInlinedCall(FLInlinedCall InlinedCall, bool UniquableMayExist=true)
Returns the existing index of a uniquable InlinedCall, or else inserts it and returns its new index.
FLSrcLoc getSrcLoc(FLIndex< FLSrcLoc > Idx, FLIndex< FLInlinedCall > InlinedAt) const
friend class LLVMContextImpl
FLIndex< FLSrcLoc > insertSrcLoc(FLSrcLoc SrcLoc)
Inserts a new FLSrcLoc SrcLoc and returns its index.
ArrayRef< FLScope > getScopes() const
void updateAtomGroupWaterline(FLIndex< FLInlinedCall > InlinedCallIdx, uint16_t NewWaterline)
ArrayRef< FLSrcLoc > getSrcLocs() const
FLScope getScope(FLIndex< FLScope > Idx, FLIndex< FLInlinedCall > InlinedAt) const
FLIndex< FLScope > insertScope(FLScope Scope)
Inserts a new FLScope Scope and returns its index.
FLScope getScope(FLIndex< FLScope > Idx) const
static LLVM_ABI MDFunctionLocalContext * getDistinct(LLVMContext &Context, bool NonDebug=false)
uint16_t getNewAtomGroup(FLIndex< FLInlinedCall > InlinedCallIdx)
static constexpr uint16_t MaxAllowedAtomGroup
Manage lifetime of a slot tracker for printing IR.
A Module instance is used to store all the information related to an LLVM module.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
An opaque object representing a hash code.
This class implements an extremely fast bulk output stream that can only output to a stream.
This provides a very simple, boring adaptor for a begin and end iterator into a range type.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
A self-contained host- and target-independent arbitrary-precision floating-point software implementat...
This is an optimization pass for GlobalISel generic memory operations.
hash_code hash_value(const FixedPointSemantics &Val)
hash_code hash_combine(const Ts &...args)
Combine values into a single hash_code.
static bool isEqual(FLIndex< IndexedType > LHS, FLIndex< IndexedType > RHS)
static unsigned getHashValue(FLIndex< IndexedType > DL)
static unsigned getHashValue(FLInlinedCall IC)
static bool isEqual(FLInlinedCall LHS, FLInlinedCall RHS)
static unsigned getHashValue(FLScope Scope)
static bool isEqual(FLScope LHS, FLScope RHS)
static unsigned getHashValue(FLSrcLoc SrcLoc)
static bool isEqual(FLSrcLoc LHS, FLSrcLoc RHS)
An information struct used to provide DenseMap with the various necessary components for a given valu...
bool isInlined() const
Returns true if the location of this FLInlinedCall is inlined.
FLInlinedCall(FLIndex< FLSrcLoc > SrcLocIdx, FLIndex< FLInlinedCall > InlinedAtIdx, MDFunctionLocalContext *InlineeContext, bool Uniquable, uint16_t MaxAtomGroup=0)
FLIndex< FLInlinedCall > InlinedAtIdx
friend hash_code hash_value(const FLInlinedCall &IC)
MDFunctionLocalContext * getInlinee() const
MDFunctionLocalContext * InlineeContext
FLIndex< FLSrcLoc > SrcLocIdx
bool isEquivalent(const FLInlinedCall &Other) const
LLVM_ABI void print(raw_ostream &OS, ModuleSlotTracker &MST, const Module *M=nullptr) const
uint16_t getNewAtomGroup()
FLInlinedCall getInlinedAt(const MDFunctionLocalContext *FLCtx) const
Returns the FLInlinedCall that this call was inlined at; only valid if isInlined().
LLVM_ABI void print(raw_ostream &OS, const Module *M=nullptr) const
static constexpr uint16_t MaxAllowedAtomGroup
Unique FLMD, just a wrapper around a DILocalScope.
LLVM_ABI void print(raw_ostream &OS, ModuleSlotTracker &MST, const Module *M=nullptr) const
FLScope(DILocalScope *Scope)
friend hash_code hash_value(const FLScope &Scope)
const DILocalScope * get() const
LLVM_ABI void print(raw_ostream &OS, const Module *M=nullptr) const
bool operator==(const FLScope &Other) const
uint64_t asRawInt() const
friend hash_code hash_value(const FLSrcLoc &SrcLoc)
LLVM_ABI void print(raw_ostream &OS, const Module *M=nullptr) const
LLVM_ABI void print(raw_ostream &OS, ModuleSlotTracker &MST, const Module *M=nullptr) const
bool operator==(const FLSrcLoc &Other) const
FLSrcLoc(uint32_t Line, uint16_t Column, FLIndex< FLScope > ScopeIdx)
FLIndex< FLScope > ScopeIdx