14#ifndef LLVM_IR_FUNCTIONLOCALMETADATA_H
15#define LLVM_IR_FUNCTIONLOCALMETADATA_H
51template <
typename IndexedType>
class FLIndex {
63 assert(InIndex < std::numeric_limits<IndexType>::max() &&
64 "Hit maximum index limit!");
66 operator bool()
const {
return Index; }
74 Index.Index = RawIndex;
155 return LHS.isEquivalent(
RHS);
171 static_assert(
sizeof(*this) ==
sizeof(
uint64_t));
173 std::memcpy(&Result,
this,
sizeof(Result));
220class MDFunctionLocalContext :
public MDNode {
225 setNonDebug(NonDebug);
230 ~MDFunctionLocalContext() =
default;
240 void setNonDebug(
bool IsNonDebug) {
SubclassData1 = IsNonDebug; }
256 bool NonDebug =
false);
285 assert(Idx &&
"Attempted to fetch a Scope with an empty index!");
286 return Scopes[Idx.get()];
290 assert(Idx &&
"Attempted to fetch a Scope with an empty index!");
292 return Scopes[Idx.get()];
293 return InlinedCalls[InlinedAt.
get()].getInlinee()->getScope(Idx);
296 assert(Idx &&
"Attempted to fetch a SrcLoc with an empty index!");
297 return SrcLocs[Idx.get()];
301 assert(Idx &&
"Attempted to fetch a SrcLoc with an empty index!");
303 return SrcLocs[Idx.get()];
304 return InlinedCalls[InlinedAt.
get()].getInlinee()->getSrcLoc(Idx);
307 assert(Idx &&
"Attempted to fetch an InlinedCall with an empty index!");
308 return InlinedCalls[Idx.get()];
318 if (!InlinedCallIdx) {
321 "Atom group limit reached!");
325 return InlinedCalls[InlinedCallIdx.
get()].getNewAtomGroup();
330 "New atom group exceeds limit!");
334 InlinedCalls[InlinedCallIdx.
get()].MaxAtomGroup = std::max(
335 InlinedCalls[InlinedCallIdx.
get()].MaxAtomGroup, NewWaterline);
340 return InlinedCalls[InlinedCallIdx.
get()].MaxAtomGroup;
345 Scopes.push_back(Scope);
346 return Scopes.size() - 1;
354 for (
uint16_t Idx = 0; Idx < Scopes.size(); ++Idx)
355 if (Scopes[Idx] == Scope)
362 SrcLocs.push_back(SrcLoc);
363 return SrcLocs.size() - 1;
375 for (
uint32_t Idx = 0; Idx < SrcLocs.size(); ++Idx)
376 if (SrcLocs[Idx] == SrcLoc)
387 bool UniquableMayExist =
true) {
388 if (InlinedCall.
Uniquable && UniquableMayExist) {
389 for (
uint16_t Idx = 0; Idx < InlinedCalls.size(); ++Idx) {
391 InlinedCalls[Idx].MaxAtomGroup = std::max(
392 InlinedCall.
MaxAtomGroup, InlinedCalls[Idx].MaxAtomGroup);
397 InlinedCalls.push_back(InlinedCall);
398 return InlinedCalls.size() - 1;
405 "FLInlinedCall to be inlined!");
427 auto [ScopeIt, Inserted] = ScopeMap.try_emplace(InsertedScope);
429 ScopeIt->second = FLContext->insertScope(InsertedScope);
430 return ScopeIt->second;
437 FLSrcLoc InsertedSrcLoc(Line, Column, ScopeIdx);
438 auto [SrcLocIt, Inserted] = SrcLocMap.try_emplace(InsertedSrcLoc);
440 SrcLocIt->second = FLContext->insertSrcLoc(InsertedSrcLoc);
441 return SrcLocIt->second;
449 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.
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
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 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
uint16_t getNewAtomGroup()
FLInlinedCall getInlinedAt(const MDFunctionLocalContext *FLCtx) const
Returns the FLInlinedCall that this call was inlined at; only valid if isInlined().
static constexpr uint16_t MaxAllowedAtomGroup
Unique FLMD, just a wrapper around a DILocalScope.
FLScope(DILocalScope *Scope)
friend hash_code hash_value(const FLScope &Scope)
const DILocalScope * get() const
bool operator==(const FLScope &Other) const
uint64_t asRawInt() const
friend hash_code hash_value(const FLSrcLoc &SrcLoc)
bool operator==(const FLSrcLoc &Other) const
FLSrcLoc(uint32_t Line, uint16_t Column, FLIndex< FLScope > ScopeIdx)
FLIndex< FLScope > ScopeIdx