16#ifndef LLVM_CGDATA_STABLEFUNCTIONMAP_H
17#define LLVM_CGDATA_STABLEFUNCTIONMAP_H
25#include <unordered_map>
97 std::once_flag LazyLoadFlag;
133 bool contains(HashFuncsMapType::key_type FunctionHash)
const {
134 return HashToFuncs.count(FunctionHash) > 0;
142 at(HashFuncsMapType::key_type FunctionHash)
const;
162 void insert(std::unique_ptr<StableFunctionEntry> FuncEntry) {
163 assert(!Finalized &&
"Cannot insert after finalization");
164 HashToFuncs[FuncEntry->Hash].Entries.emplace_back(std::move(FuncEntry));
167 void deserializeLazyLoadingEntry(HashFuncsMapType::iterator It)
const;
170 void deserializeLazyLoadingEntries()
const;
172 bool isLazilyLoaded()
const {
return (
bool)Buffer; }
177 SmallVector<std::string> IdToName;
179 StringMap<unsigned> NameToId;
181 bool Finalized =
false;
186 std::shared_ptr<MemoryBuffer> Buffer;
188 bool ReadStableFunctionMapNames =
true;
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
This file defines the StringMap class.
This file defines the DenseMap class.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
StringRef - Represent a constant reference to a string, i.e.
The instances of the Type class are immutable: once they are created, they are never changed.
This is an optimization pass for GlobalISel generic memory operations.
std::pair< IndexPair, stable_hash > IndexPairHash
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
Implement std::hash so that hash_code can be used in STL containers.
The structure of the serialized stable function map is as follows:
In addition to the deserialized StableFunctionEntry, the struct stores the offsets of corresponding s...
StableFunctionEntries Entries
The actual storage of deserialized stable function entries.
An efficient form of StableFunction for fast look-up.
StableFunctionEntry(stable_hash Hash, unsigned FunctionNameId, unsigned ModuleNameId, unsigned InstCount, std::unique_ptr< IndexOperandHashMapType > IndexOperandHashMap)
stable_hash Hash
The combined stable hash of the function.
std::unique_ptr< IndexOperandHashMapType > IndexOperandHashMap
A map from an IndexPair to a stable_hash which was skipped.
unsigned InstCount
The number of instructions.
unsigned FunctionNameId
Id of the function name.
unsigned ModuleNameId
Id of the module name.
std::unordered_map< stable_hash, EntryStorage > HashFuncsMapType
LLVM_ABI size_t size(SizeType Type=UniqueHashCount) const
LLVM_ABI void insert(const StableFunction &Func)
Insert a StableFunction object into the function map.
SmallVector< std::unique_ptr< StableFunctionEntry > > StableFunctionEntries
ArrayRef< std::string > getNames() const
Get the NameToId vector for serialization.
LLVM_ABI void merge(const StableFunctionMap &OtherMap)
Merge a OtherMap into this function map.
LLVM_ABI std::optional< std::string > getNameForId(unsigned Id) const
Get the name associated with a given ID.
const HashFuncsMapType & getFunctionMap() const
Get the HashToFuncs map for serialization.
LLVM_ABI unsigned getIdOrCreateForName(StringRef Name)
Get an existing ID associated with the given name or create a new ID if it doesn't exist.
bool contains(HashFuncsMapType::key_type FunctionHash) const
A stable function is a function with a stable hash while tracking the locations of ignored operands a...
unsigned InstCount
The number of instructions.
StableFunction(stable_hash Hash, const std::string FunctionName, const std::string ModuleName, unsigned InstCount, IndexOperandHashVecType &&IndexOperandHashes)
stable_hash Hash
The combined stable hash of the function.
IndexOperandHashVecType IndexOperandHashes
A vector of pairs of IndexPair and operand hash which was skipped.
std::string FunctionName
The name of the function.
std::string ModuleName
The name of the module the function is in.