9#ifndef LLVM_DWARFLINKER_PARALLEL_TYPEPOOL_H
10#define LLVM_DWARFLINKER_PARALLEL_TYPEPOOL_H
38 using Part = std::variant<StringRef, const TypeEntry *>;
51 assert(!
Text.contains(RefMarker) &&
"text would read as a reference");
56 assert(
C != RefMarker &&
"text would read as a reference");
62 size_t size()
const {
return Bytes.size(); }
68 static constexpr char RefMarker =
'\0';
69 static constexpr size_t RefSize = 1 +
sizeof(
const TypeEntry *);
104 std::atomic<DIE *>
Die = {
nullptr};
115 std::atomic<uint64_t>
DiePriority = {std::numeric_limits<uint64_t>::max()};
127 std::atomic<uint32_t>
SortKey = {std::numeric_limits<uint32_t>::max()};
147 llvm::parallel::PerThreadBumpPtrAllocator> {
177 if (Entry->getValue().compare_exchange_strong(
DIE, NewDIE)) {
178 ParentEntry->
getValue().load()->Children.add(Entry);
189 while (!Worklist.
empty()) {
192 Entry->getValue().load()->Children.forEach(
209 return Allocator.getThreadLocalAllocator();
216 LHS->getValue().load()->SortKey.load(std::memory_order_relaxed);
218 RHS->getValue().load()->SortKey.load(std::memory_order_relaxed);
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
This file defines the StringMap class.
This file defines the BumpPtrAllocator interface.
static GCRegistry::Add< ShadowStackGC > C("shadow-stack", "Very portable GC for uncooperative code generators")
This file defines the SmallString class.
ConcurrentHashTableByPtr(llvm::parallel::PerThreadBumpPtrAllocator &Allocator, uint64_t EstimatedSize=100000, size_t ThreadsNum=parallel::strategy.compute_thread_count(), size_t InitialNumberOfBuckets=128)
A structured debug information entry.
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
const ValueTy & getValue() const
StringMapEntry - This is used to represent one value that is inserted into a StringMap.
static StringMapEntry * create(StringRef key, AllocatorTy &allocator, InitTy &&...initVals)
Represent a constant reference to a string, i.e.
This class is a simple list of T structures.
Keeps cloned data for the type DIE.
bool DeclarationParentIsDeclaration
ArrayList< TypeEntry *, 5 > Children
Children for current type.
DIE & getFinalDie() const
Returns copy of type DIE which should be emitted into resulting file.
TypeEntryBody(TypeEntryBody &&RHS)=delete
uint64_t DeclarationDiePriority
std::atomic< uint32_t > SortKey
bool hasOnlyDeclaration() const
Returns true if type die entry has only declaration die.
TypeEntryBody(const TypeEntryBody &RHS)=delete
TypeEntryBody(llvm::parallel::PerThreadBumpPtrAllocator &Allocator)
TypeEntryBody & operator=(const TypeEntryBody &RHS)=delete
std::atomic< DIE * > DeclarationDie
std::atomic< DIE * > Die
TypeEntryBody keeps partially cloned DIEs corresponding to this type.
std::atomic< uint64_t > DiePriority
static TypeEntryBody * create(llvm::parallel::PerThreadBumpPtrAllocator &Allocator)
Creates type DIE for the specified name.
TypeEntryBody & operator=(const TypeEntryBody &&RHS)=delete
A type key is text interleaved with references to other type entries.
void appendRef(const TypeEntry *Entry)
TypeKey & operator+=(char C)
TypeKey & operator+=(StringRef Text)
void truncate(size_t Size)
static Part takePart(StringRef &Key)
Remove the first part of the non-empty key Key and return it.
static std::string expand(StringRef Key)
std::variant< StringRef, const TypeEntry * > Part
A maximal run of text, or a reference.
static int compare(StringRef LHS, StringRef RHS)
Compare LHS and RHS as if every reference were replaced by the key it refers to, so the result does n...
TypePool keeps type descriptors which contain partially cloned DIE correspinding to each type.
BumpPtrAllocator & getThreadLocalAllocator()
Return thread local allocator used by pool.
TypeEntryBody * getOrCreateTypeEntryBody(TypeEntry *Entry, TypeEntry *ParentEntry)
Create or return existing type entry body for the specified Entry.
TypeEntry * insert(StringRef Name)
TypeEntry * getRoot() const
Return root for all type entries.
std::function< bool(const TypeEntry *LHS, const TypeEntry *RHS)> TypesComparator
void sortTypes()
Sort children for each kept type entry.
StringMapEntry< std::atomic< TypeEntryBody * > > TypeEntry
PerThreadAllocator< BumpPtrAllocator > PerThreadBumpPtrAllocator
This is an optimization pass for GlobalISel generic memory operations.
LLVM_ATTRIBUTE_VISIBILITY_DEFAULT AnalysisKey InnerAnalysisManagerProxy< AnalysisManagerT, IRUnitT, ExtraArgTs... >::Key
BumpPtrAllocatorImpl<> BumpPtrAllocator
The standard BumpPtrAllocator which just uses the default template parameters.
void parallelForEach(IterTy Begin, IterTy End, FuncTy Fn)